Commit Graph

1062 Commits

Author SHA1 Message Date
Mike Jolley fdbe4e7c54 Remove legacy handling on the PHP side (https://github.com/woocommerce/woocommerce-blocks/pull/7978) 2022-12-22 17:04:54 +01:00
Alba Rincón a223af0ad5 Add 'Customer Account' block (https://github.com/woocommerce/woocommerce-blocks/pull/7876)
* Add empty 'Customer Account' block

* Add edit to render the block on the editor

* Add Customer Account icon to @woocommerce/icons library

This icon is used in the Customer Account block.

* Use customerAccount icon in the Customer Account block

* Add Block Settings to Customer Account block

Add Typography and Color settings to the Customer Account block that can be used during Edit mode.

* Add Customer Account style icons

This adds the customer account style icons to be used by the customer account block.

* Render the block in the frontend

* Add Display setting to the Customer Account block

This setting allow users to choose if they want to include an icon with the customer account link.

* Add icon style selector to Display settings

This adds an icon style selector in which users can choose the customer account link icon.

* Display on the frontend depending on the icon style

* Rename attributes

* Refactor block rendering

* Improve styling

* Make the account link dynamic

* Add alignment menu

* Get dashboardUrl with getSettings and add fallback

* Add link to account settings

* Add tests

* Fix test

* Change display title

* Split css file

* Switch to SSR

* Add styles to the front end

* Address latest feedback

* Remove experimental flag

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2022-12-22 16:01:01 +01:00
Tung Du b3ea73f3bb Revert woocommerce/woocommerce-blocks#7504 for ProductButton.php to avoid loading unnecessary JS files (https://github.com/woocommerce/woocommerce-blocks/pull/7966) 2022-12-22 09:05:54 +07:00
Alex Florisca 828ba01142 Bump version strings to 9.2.0-dev 2022-12-20 12:01:22 +00:00
github-actions[bot] 29dae38ba3 Release: 9.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7977)
* Empty commit for release pull request

* Update readme.txt

* Update WC versions

* Testing instructions for release 9.2.0

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
2022-12-20 11:41:14 +00:00
Alba Rincón 5b095eb1a2 Fix overriding `archive-product` when saving a fallback template (https://github.com/woocommerce/woocommerce-blocks/pull/7975)
* Fix overriding archive-product when saving a fallback template

* Add comment
2022-12-19 15:31:00 +01:00
Tung Du b02b7f9348 Product Query: Add product visibility query support (https://github.com/woocommerce/woocommerce-blocks/pull/7951) 2022-12-19 21:05:16 +07:00
Mike Jolley 0e1b05b92a Update MD editor config (https://github.com/woocommerce/woocommerce-blocks/pull/7968)
* Remove MD from editor config. Prettier handles formatting.

* Resave docs

* Update MD files
2022-12-19 12:06:48 +00:00
Thomas Roberts ebe05700ab Add notice on quantity change and update `wc/store/cart` to use thunks (https://github.com/woocommerce/woocommerce-blocks/pull/7938)
* Add receiveCart thunk

* Add mapCartResponseToCart helper

* Add getItemsPendingQuantityUpdate selector

* Update cart resolvers to be thunks

* Remove RECEIVE_CART action and replace with SET_CART_DATA

receiveCart will turn into a thunk.

* Add notifyQuantityChanges functions

* Remove receiveCart from action type definition, replace with setCartData

* Move apiFetchWithHeaders out of controls

This will just be a normal function since we'll be updating actions to thunks which will use this instead of a control.

* Include thunks in actions file

* Update receiveCart action to setCartData

* Update applyCoupon action to a thunk

* Update useStoreCartCoupons to get action from correct place

* Update StoreCartCoupon types

* Add types for Thunk and ThunkReturnType in mapped-types

* Change applyCoupon to a thunk

* Get applyCoupon, removeCoupon, receiveApplyingCoupon from useDispatch

This is to separate the concerns of actions vs. selectors. Previously the actions were fetched during useSelect which is not a pattern we use anywhere else in the codebase. Since we updated the MapToDispatch type, we can now get correctly typed thunks from the data store.

* Improve apiFetchWithHeaders typings

* Convert removeCoupon from generator to thunk

* Add applyCoupon and removeCoupon to CartAction type

* Remove unused old-style type-def

* Add receiveApplyingCoupon & receiveRemovingCoupon to StoreCartCoupon

* Correct issues with StoreCartCoupon type

These were not intended to reflect the actions in data store, rather the functions offered by the useStoreCartCoupons hook.

* Update applyExtensionCartUpdate to a thunk

* Update addItemToCart to thunk

* Add ResolveSelectFromMap type that works with thunks

* Add CartDispatchFromMap and CartResolveSelectFromMap types

We can add this to all data stores to get them working with thunks properly.

* Add docs and update generic name in ResolveSelectFromMap

* Add correct types for thunk resolvers in cart data store

* Update removeItemFromCart to thunk

* Update apiFetchWithHeaders to use generic

* Update selectShippingRate to thunk

* Update resolver tests to test correct thunk functionality

* Update updateCustomerData to thunk

* Update reducer test to reflect new action name

* Update comments on CartDispatchFromMap and CartResolveSelectFromMap

* Add quantity_limits to preview cart

* Make notices speak when shown

* Remove copilot comment

* Add isWithinQuantityLimits function

This is because we shouldn't show a notice if the quantity limits change, but the item's quantity is still OK.

* Add tests for notifyQuantityChanges

* Show notice when multiple_of is updated

* Update test to test for multiple_of changes

* Remove empty export

* Remove controls from cart data store

Not needed anymore since the exported value from the shared-controls file was empty.

* Export a control and async function for apiFetchWithHeaders

This is required because async functions cannot be called from sync generators.

* Use control version of apiFetchWithHeaders in the collections store

* Improve comments and remove incorrect TypeScript

* Update assets/js/data/cart/actions.ts

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update ResolveSelectFromMap to include selectors too

* Update TS in actions

* Use finally to remove duplicate code

* remove item pending delete/qty update after action runs in all cases

This will also reset the state when the request to remove it/change quantity errors

* Remove unnecessary type from param.

Not needed because we have TS now. The description can stay though, it is useful.

* Update snackbar wording to use active voice

* Remove old WP version check

* Set max quantity to high number instead of null

This would only happen in a niche case, and would require several TS changes to fix, so it's better to set it as a number here. 9999 should be high enough, and is the default quantity limit set below in get_product_quantity_limit

* Set code on woocommerce_rest_cart_invalid_key to 409

This is so the cart is returned in the response, so the client can update.

* Fix typo in comment and add CartSelectFromMap

* Remove unnecessary docblock

* Add getItemsPendingDelete selector

This is needed so we can show a notice for items that are unexpectedly removed from the cart. We need to know which ones are pending delete so we can skip showing the notice for them.

* Add type for notifyQuantityChanges args and change args to object

* Add notifyIfRemoved function

This will check items that have been removed and show a notice for them.

* Fix TS in receiveCart & pass itemsPendingDelete to notifyQuantiyChanges

* Update wording on removal notice

* Update types for notifyQuantityChanges args

* Update tests to reflect new wording and args being an object

* Check item is truth before running comparison of keys

* Update tests for unexpectedly and expectedly removed items

* Ignore print_r to satisfy phpcs

* Update PHP tests to reflect correct response code when deleting items

* Remove unnecessary controls and dispatch events directly from thunk

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-12-16 08:06:37 -08:00
Mike Jolley 5625ea46cd Correct data table (https://github.com/woocommerce/woocommerce-blocks/pull/7935) 2022-12-16 10:23:58 +00:00
Luigi c86502ecff Merge branch 'release/9.1.0' of https://github.com/woocommerce/woocommerce-blocks into trunk 2022-12-15 10:09:40 +01:00
github-actions[bot] 0fde3c761f Release: 9.1.1 (https://github.com/woocommerce/woocommerce-blocks/pull/7948)
* Empty commit for release pull request

* Update the readme file with 9.1.1 release changes

* Product Query: Add `Sorted by title` preset. (https://github.com/woocommerce/woocommerce-blocks/pull/7949)

* Add `Sort by title` preset.

* sorted, thanks @nerrad

* Update the readme file with woocommerce/woocommerce-blocks#7949 changes

* 9.1.1 Release: Add testing docs

* Atomic Block: fix ancestor definition (https://github.com/woocommerce/woocommerce-blocks/pull/7947)

* Fix the incorrect layout of Rating and Price in Classic Template and Products block (https://github.com/woocommerce/woocommerce-blocks/pull/7932)

* Fix the incorrect layout of Rating and Price in Classic Template

There were styles required in Rating Filter that were added globally and influenced the layout of Rating in Products block as well as Classic template. The styles were moved to the Rating Filter block

* Add dropdown version of Filter by Stock Status (https://github.com/woocommerce/woocommerce-blocks/pull/7831)

* Extend Filter by Stock Editor options with dropdown and single/multiple choice

* Add dropdown implementation for Filter by Stock Status

* Adjust font-sizes to the rest of the filters

* Add tests to Filter by Stock: dropdown and list variants

* Change test file extension from .js to .tsx, so it handles types as well

* Add E2E test to Filter by Stock checking if display style can be toggled

* When typing in Filter by Stock dropdown, handle the space so it highlights the suggestions

* Change the name of the filter blocks in the test files

* Remove unnecessary waiting step in E2E test for Filter by Stock

toMatchElement waits for an element for 30s by itself, hence waitForSelector usage was removed

* Improve the STOCK_STATUS_OPTIONS type handling

* Extract onDropdownChange function instead of inline arrow function

* Fix overlaping dropdown content with the wrapper when Filter by Stock was set to single

* Product Query: Add patterns (https://github.com/woocommerce/woocommerce-blocks/pull/7857)

* Product Query: First attempt at adding patterns

* Product Query: Update patterns and the default block template

* Product Query: And new and update existing patterns

* Product Query: Adjust layout of the Minimal Product Row pattern

* Product Query: Update pattern names

* Product Query: Polish spaces between blocks inside the patterns

* Product Query patterns: Link product titles and improve spacing between product elements

* Product Query patterns: Button font-size update

* Product Query patterns: Center the pagination

* Product Query patterns: Center the pagination for the default pattern

* Product Query patterns: Remove an empty column

* Product Query patterns: Remove an empty column from the product list with 1:1 images pattern

* Add dropdown version of Filter by Rating (https://github.com/woocommerce/woocommerce-blocks/pull/7771)

* Rename the setting section to match Filter by Attribute

* Add Display Style toggle to the block settings

* Set list as a default value of displayStyle for Filter by Rating

* Add dropdown variant of Filter by Rating

* Extend the Editor settings with selectType: single or multiple

* Adjust the styles of a FormTokenField to other dropdown

* Align Editor settings order and wording between Filter by Attribute and Rating

* Fix the issue with cut off corners of dropdown borders

* Provide translated screen reader messages and placeholder

* Revert the label property, which is necessary to display checkbox list

* Make classname for Rating component optional and remove styling in Filter by Rating

* Cover the case when filter with zero products needs string methods for comparison

* Handle Typescript errors and add ts-ignore annotations when necessary

* Remove explicit key prop assignment in Rating component

* Remove leftover property in type definition

* Refactor JSX element extension with custom properties to more robust way with object copy

* Filter by rating tests (https://github.com/woocommerce/woocommerce-blocks/pull/7845)

* Filter by Rating tests:
  - List single
  - List multiple
  - Dropdown single
  - Dropdown multiple

* Adjust the font-size of Filter by Rating dropdown to the rest of the filters

* Fix E2E tests after the Editor settings label has been changed

* Improve sorting in Filter by Rating dropdown

With this change the order of options is always descending: in the chips, suggestions, active filters and URL

* Change the name of the filter blocks in the test files

* Prevent single dropdown input to overflow the wrapper

The issue is fixed in three filters, hence a new shared styles file is created at the path assets/js/blocks/shared/styles/style.css

* Remove the unused styles of active options in Filter by Rating

Chosen options in Filter by Rating list have been bolded. That was the only filter that was doing it. Class was removed, but not the styles themselves which became obsolete. Removing the leftover styles then

* Change the approach of shared styles to fix the dropdown issue in filters

Instead of using direct classes, rewrite it to mixin and include in the filters

* Fix the Filter by Rating with Products block

The problem was with the Products block, that there was incorrect initial value of product ratings query

* Align the logic of getting the filters from URL for Filter by Rating with Filter by Stock

Co-authored-by: Luigi Teschio <gigitux@gmail.com>

* Product Query - Enable "Inherit Query from template" option (https://github.com/woocommerce/woocommerce-blocks/pull/7641)

* Add Inherit Query from template option

* Update label

* Product Elements: Fix block settings (https://github.com/woocommerce/woocommerce-blocks/pull/7914)

* Product Elements: Fix block settings

* Rating: Fix inactive star color

* Product Rating: Fix color inheritance

* StyleAttributesUtils: Fix PHP notices and invalid CSS output (https://github.com/woocommerce/woocommerce-blocks/pull/7909)

* StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes woocommerce/woocommerce-blocks#7899.

* StyleAttributesUtils: Fix border radius and width support

* StyleAttributesUtils: Fix border radius and border color support

* StyleAttributesUtils: Include additional checks to deal with PHP warnings

* StyleAttributesUtils: Improve the custom border array check

* Update MiniCart.php to fix price total amount on page load prices are including tax (https://github.com/woocommerce/woocommerce-blocks/pull/7832)

* Update MiniCart.php

Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is active. Currently displaying wrong amount total on page load if items are already in the basket.

* Update MiniCart.php

Removed white spaces?

* Update MiniCart.php

Fixed IF statement

* Remove whitespace at end of line

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Product Query: implement compatibility with Filter by Rating block (https://github.com/woocommerce/woocommerce-blocks/pull/7792)

* Product Query: implement compatibility with Filter by Rating block woocommerce/woocommerce-blocks#7631

Product Query: implement compatibility with Filter by Rating block

* address feedback

* address feedback

* add comment

* add new zip file link

* add missing class

* add testing instructions about woocommerce/woocommerce-blocks#7947

* add new zip file link

* Update docs/internal-developers/testing/releases/911.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update docs/internal-developers/testing/releases/911.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update docs/internal-developers/testing/releases/911.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update docs/internal-developers/testing/releases/911.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Update docs/internal-developers/testing/releases/911.md

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: kmanijak <karol.manijak@automattic.com>
Co-authored-by: Luke O'Regan <oregan.luke@gmail.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-12-15 10:02:35 +01:00
Daniel Dudzic 179287f0be Product Query: Add patterns (https://github.com/woocommerce/woocommerce-blocks/pull/7857)
* Product Query: First attempt at adding patterns

* Product Query: Update patterns and the default block template

* Product Query: And new and update existing patterns

* Product Query: Adjust layout of the Minimal Product Row pattern

* Product Query: Update pattern names

* Product Query: Polish spaces between blocks inside the patterns

* Product Query patterns: Link product titles and improve spacing between product elements

* Product Query patterns: Button font-size update

* Product Query patterns: Center the pagination

* Product Query patterns: Center the pagination for the default pattern

* Product Query patterns: Remove an empty column

* Product Query patterns: Remove an empty column from the product list with 1:1 images pattern
2022-12-13 14:53:26 +01:00
Luigi Teschio 306ce007d0 Product Query - Enable "Inherit Query from template" option (https://github.com/woocommerce/woocommerce-blocks/pull/7641)
* Add Inherit Query from template option

* Update label
2022-12-12 16:06:25 +01:00
Daniel Dudzic 0249011551 Product Elements: Fix block settings (https://github.com/woocommerce/woocommerce-blocks/pull/7914)
* Product Elements: Fix block settings

* Rating: Fix inactive star color

* Product Rating: Fix color inheritance
2022-12-12 15:53:42 +01:00
Daniel Dudzic bdbee5cbf8 StyleAttributesUtils: Fix PHP notices and invalid CSS output (https://github.com/woocommerce/woocommerce-blocks/pull/7909)
* StyleAttributesUtils: Fix PHP notices and invalid CSS output. Closes woocommerce/woocommerce-blocks#7899.

* StyleAttributesUtils: Fix border radius and width support

* StyleAttributesUtils: Fix border radius and border color support

* StyleAttributesUtils: Include additional checks to deal with PHP warnings

* StyleAttributesUtils: Improve the custom border array check
2022-12-12 12:43:41 +01:00
Luigi Teschio 1f96800326 Fix Markdown lint errors (https://github.com/woocommerce/woocommerce-blocks/pull/7912) 2022-12-12 10:20:47 +01:00
Luke O'Regan cd82fa28a5 Update MiniCart.php to fix price total amount on page load prices are including tax (https://github.com/woocommerce/woocommerce-blocks/pull/7832)
* Update MiniCart.php

Added an update to the '$cart_contents_total' variable on the 'get_cart_price_markup' function if $cart->display_prices_including_tax is active. Currently displaying wrong amount total on page load if items are already in the basket.

* Update MiniCart.php

Removed white spaces?

* Update MiniCart.php

Fixed IF statement

* Remove whitespace at end of line

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-12-09 17:36:28 +01:00
Mike Jolley 4616d4e1d9 Clarify that the extend class in Store API is for schema (https://github.com/woocommerce/woocommerce-blocks/pull/7858) 2022-12-09 13:32:12 +00:00
github-actions[bot] dbde4876fc Release: 9.1.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7854)
* Empty commit for release pull request

* add changelog

* add testing notes

* rename stuff

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2022-12-07 14:06:20 +01:00
Luigi Teschio 9436488da4 Product Query: implement compatibility with Filter by Rating block (https://github.com/woocommerce/woocommerce-blocks/pull/7792)
* Product Query: implement compatibility with Filter by Rating block woocommerce/woocommerce-blocks#7631

Product Query: implement compatibility with Filter by Rating block

* address feedback

* address feedback

* add comment
2022-12-07 12:32:31 +01:00
Nadir Seghir 79a3d397c2 Bumping version strings to new version. 2022-12-06 15:41:29 +01:00
Tung Du f35bbd7b0e Fix: Product Query editor preview with Stock Status setting (https://github.com/woocommerce/woocommerce-blocks/pull/7682)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-05 09:14:17 +07:00
Daniel Dudzic e1a0866e4a Product Price: Hide alignment setting for the All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/7825) 2022-12-02 18:05:53 +01:00
Daniel Dudzic 3d64bfe69c Rating: Add support for alignment setting (https://github.com/woocommerce/woocommerce-blocks/pull/7790)
* Rating: Add support for alignment setting

* Rating: Fix PHP warning

* Rating: Fix linting error

* Rating: Update StyleAtributesUtils.php

* Product Rating: Escape alignment class

* Product Rating: Hide alignment setting for the All Products block
2022-12-02 17:11:26 +01:00
Daniel Dudzic b6303c8493 Add to Cart: Add support for the alignment setting (https://github.com/woocommerce/woocommerce-blocks/pull/7816)
* Add to Cart: Add support for the alignment setting

* Add to Cart button: Hide alignment setting for the All Products block
2022-12-02 15:17:22 +01:00
Manish Menaria dd40d2bfce Revert "Add product query support for Product Summary block (https://github.com/woocommerce/woocommerce-blocks/pull/7774)" (https://github.com/woocommerce/woocommerce-blocks/pull/7818)
This reverts commit 3b131f6d35.
2022-12-02 17:11:57 +05:30
Manish Menaria 830ea38a82 Revert "Adds product query support for Category list block (https://github.com/woocommerce/woocommerce-blocks/pull/7675)" (https://github.com/woocommerce/woocommerce-blocks/pull/7819)
This reverts commit c263ba83d4.
2022-12-02 17:11:44 +05:30
Luigi Teschio 34140b197f Mini Cart: load wc-blocks-registry package at the load of the page instead of lazy load it (https://github.com/woocommerce/woocommerce-blocks/pull/7813) 2022-12-01 18:31:24 +01:00
Lucio Giannotta 4e340ee3ed Product Query: make sure request params are set when enhancing REST query (https://github.com/woocommerce/woocommerce-blocks/pull/7796)
This fixes a bug in which in certain cases Products wouldn't load in the editor because the Product Query
block was doing some REST API request with some invalid parameters.
2022-12-01 16:42:25 +01:00
Daniel Dudzic 936979dc33 Product Price: Fix alignment setting on the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/7795)
* Product Price: Fix alignment setting on the frontend

* Product Price: Remove the Feature plugin flag from the alignment setting

* Product Price: Code clean-up

* Product Price: Fix PHP warning
2022-12-01 14:51:44 +01:00
Manish Menaria 70619b5cdb Escape values just before rendering (https://github.com/woocommerce/woocommerce-blocks/pull/7797)
* Escape all values in output of Product category list

* Escape all values in output of Product Sale Badge

* Escape values before rendering

Whenever you’re rendering data, make sure to properly escape it. Escaping output prevents XSS (Cross-site scripting) attacks.

* Remove unnecessary space

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-12-01 17:51:01 +05:30
Manish Menaria 3b131f6d35 Add product query support for Product Summary block (https://github.com/woocommerce/woocommerce-blocks/pull/7774)
* Add product query support for Product Summary block

On the client side, when the Product Summary block is used within the product query block, the markup will be rendered on the server side - No javascript related to Product Summary block will be rendered.

* Update variable names for clarity & readability

* Escape all values in output string

* Fix custom style not working

More info: https://github.com/woocommerce/woocommerce-blocks/pull/7774#discussion_r1035909243
2022-12-01 17:37:41 +05:30
Manish Menaria 0d851fdb29 Add product query support for Stock indicator block (https://github.com/woocommerce/woocommerce-blocks/pull/7734)
* Add product query support for Stock indicator block

On the client side, when the Stock indicator block is used within the product query block, the markup will be rendered on the server side - No javascript related to Stock indicator block will be rendered.

* Escape all values in output string

Whenever we are rendering data, we should escape it. Escaping output prevents XSS (Cross-site scripting) attacks.

* Change $is_on_backorder type & escape just before printing

For more info:
https://github.com/woocommerce/woocommerce-blocks/pull/7734#discussion_r1035971939
https://github.com/woocommerce/woocommerce-blocks/pull/7734#discussion_r1035975712
2022-12-01 17:14:05 +05:30
Lucio Giannotta 181838bfdf Product Query: Add support for filtering by attributes within the block (https://github.com/woocommerce/woocommerce-blocks/pull/7743) 2022-11-29 14:44:52 +01:00
Tung Du 653e838d79 Refactor `ProductQuery::merge_queries` to accept multiple queries (https://github.com/woocommerce/woocommerce-blocks/pull/7697) 2022-11-29 10:13:57 +07:00
Luigi Teschio 58423a2025 Product Query - add support for the global query (https://github.com/woocommerce/woocommerce-blocks/pull/7382)
* Product Query: Fix pagination issue

* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Price Block

* fix query relation

* fix on sale query

* Product Query - Add support for the Filter By Attributes block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Attributes block

* fix bugged pagination and on-sale filter after refactor

* address feedback

* Product Query - Add support for the Filter By Stock Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Stock Block

* Fix filter blocks: the data (e.g: max price or stock-status) match the variation woocommerce/woocommerce-blocks#7245

fix filter blocks: the data (e.g: max price or stock-status) match the variation

* rename allowControls to allowedControls

* add support to the global query

* fix eslint error

* bot: update checkstyle.xml

* Update src/BlockTypes/ProductQuery.php

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* fix global query generation

* bot: update checkstyle.xml

* try: refactor merge_queries

* remove debug code

* fix: unpack assoc array php 7.4

* try: refactor merge_queries to take any form of input without unpacking
and preparing the input arrays

* add missing query vars

* add feature flag

* updates comment

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-11-28 15:31:31 +01:00
Manish Menaria c263ba83d4 Adds product query support for Category list block (https://github.com/woocommerce/woocommerce-blocks/pull/7675)
* Adds product query support for Category list block

On the client side, when the Category list block is used within the
product query bloc, the markup will be rendered on the server side -
No javascript related to Category list block will be rendered.

* bot: update checkstyle.xml

* Fix extra space after the category link

I used the solution from following link: https://css-tricks.com/fighting-the-space-between-inline-block-elements/#aa-remove-the-spaces

Here is the content from the above link:

The reason you get the spaces is because, well, you have spaces between the elements (a line break and a few tabs counts as a space, just to be clear). Minimized HTML will solve this problem, or one of these tricks:

```CSS
<ul>
  <li>
   one</li><li>
   two</li><li>
   three</li>
</ul>
```

or

```CSS
<ul>
  <li>one</li
  ><li>two</li
  ><li>three</li>
</ul>
```

or with comments…

```CSS
<ul>
  <li>one</li><!--
  --><li>two</li><!--
  --><li>three</li>
</ul>
```

They’re all pretty funky, but it does the trick.

* Fix custom style doesn't work on the frontend side

For more info, check this comment on the PR:
https://github.com/woocommerce/woocommerce-blocks/pull/7675#pullrequestreview-1179267957

In summary, user can set the custom styles like text color, link color, font size, font weight, line height using the editor sidebar.
These styles weren't showing on the frontend side.

* Add support for additional CSS class(es)

* Fix "custom style -> link color" not working

To understand the issue in more details please check following comment:
https://github.com/woocommerce/woocommerce-blocks/pull/7675#issuecomment-1319822535

* Fix classname undefined issue

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-28 11:47:27 +05:30
Alba Rincón 304f2c3c23 Make `Products by category/tag/attribute` fallback to the `Product catalog` template (https://github.com/woocommerce/woocommerce-blocks/pull/7712)
* Add archive-product to the hierarchy

* Fallback to archive-product and get titles from blocks if the templates from theme don't have one

* Rename function

* Fix comment

* Add fallbacks to the db and blocks versions

* Add missing product attribute blockified template

* Update docs

* Add comment and fix comment type on wp_template

* Replate template name if we know the template in blocks

* Add comment and fix linting error

* Fix archive-product template

* Clone the fallback template from db to show them in the template lsit

* Return the fallback template when querying for a single template

* Remove unneeded condition

* Use wp function instead of gutenberg one

* Fix tests

* Fix tests on Product Catalog templates

It was checking a single product for the customization, but it should check the /shop page

* Disable tests related with deleteAllTemplates function
2022-11-24 16:45:39 +01:00
Lucio Giannotta 55face4338 Product Query: Add order by “Top rated” as a preset (https://github.com/woocommerce/woocommerce-blocks/pull/7715)
* Add safety guard to `extend_rest_query_allowed_params`
2022-11-23 20:28:17 +01:00
Daniel Dudzic 81d0994213 Post 9.0.0 release version bump (https://github.com/woocommerce/woocommerce-blocks/pull/7737) 2022-11-23 18:01:04 +01:00
Manish Menaria 983ecc03d7 Add product query support for Sale badge block (https://github.com/woocommerce/woocommerce-blocks/pull/7709)
* Add product query support for Sale badge block

On the client side, when the Sale badge block is used within the product query block, the markup will be rendered on the server side - No javascript related to Sale badge block will be rendered.

* Add support for additional CSS class(es)

ADDITIONAL CSS CLASS(ES)(available in advanced toggle in sidebar) should be added to the container div

* Convert preset to css variable for padding

We are getting padding value in preset format like this:
"var:preset|spacing|50"
Therefore I added a function to convert it to CSS variable like this:
"var(--wp--preset--spacing--50)"

i.e. "var:preset|spacing|50" -> "var(--wp--preset--spacing--50)"

* Add reference for preset to css variable conversion logic
2022-11-23 17:12:55 +05:30
github-actions[bot] ed192ab48e Release: 9.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7725)
* Empty commit for release pull request

* Update compatibility sections and add release 9.0.0 changelog

* Add testing instructions for the 9.0.0 release

* Update testing instructions for the 9.0.0 release

* Remove testing instructions for an unmerged PR

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
2022-11-23 12:37:31 +01:00
Lucio Giannotta 04c689b0ff Product Query: Add order by “best selling” as a preset (https://github.com/woocommerce/woocommerce-blocks/pull/7687)
* Add support for “Popular Presets” for PQ block

This commits achieves the following:

* Adds a section in the inspector control called “Popular Presets”,
which contains a dropdown with popular presets.
* Adds support for the first preset: “Best selling products”.
By selecting this, users can sort products by total sales.
* Switches the order of the custom inspector controls and the default
Query Loop inspector controls: our controls will be now on top
as per the latest design spec (see pdnLyh-2By-p2).
* Restricts the allowed Query parameters to the sort orders we want to
allow according to the latest design spec (disabling title and date).
* Removes the core “Order By” dropdown.
* Refactor `setCustomQueryAttribute` to `setQueryAttribute` because
since a few iterations, our custom query attributes are not deeply nested
anymore, and this function can be used for the normal query too.
* Add back-end support for sorting by Best Selling via the Product Query block
* Adds the `popularity` value as an allowed value for `orderby` on
`product` REST API calls.
* Handles the query differently if the `orderby` value is one among the
custom ones.
2022-11-21 19:21:58 +01:00
Luigi Teschio 21beb29442 Product Query - Add e2e tests for the filter by price block (https://github.com/woocommerce/woocommerce-blocks/pull/7351)
* Product Query - Add e2e tests for the Filter By Price block

* fix comment

* remove not used import

* update description

* update functions after merge

* improve check
2022-11-18 16:44:39 +01:00
Raluca Stan 98480c4dc2 Update cart.md (https://github.com/woocommerce/woocommerce-blocks/pull/7700)
* Update cart.md

Add information on how to add extra data to the /add-item request

* Update src/StoreApi/docs/cart.md

Co-authored-by: Niels Lange <info@nielslange.de>

* Update src/StoreApi/docs/cart.md

Co-authored-by: Niels Lange <info@nielslange.de>
2022-11-18 12:16:26 +01:00
Saad Tarhi a5970697ea Fix missing translations in inspector — Cross-Sells Block (https://github.com/woocommerce/woocommerce-blocks/pull/7616)
* Fix CartCrossSellsBlock inspector's translation

* Fix CartCrossSellsProductsBlock inspector's translation

* bot: update checkstyle.xml

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2022-11-17 14:41:15 +01:00
Alba Rincón 87510929b5 Create the `Products by Attribute` template (https://github.com/woocommerce/woocommerce-blocks/pull/7660)
* Create the `Products by Attribute` template

* bot: update checkstyle.xml

* Fix typo

* Rename template to `taxonomy-product_attribute`

* Rename test template file

* bot: update checkstyle.xml

* Fix test enabling archives for shade attribute

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-16 14:37:41 +01:00
kmanijak 5e1896d98a Fix: skewed placeholder of product image - issuewoocommerce/woocommerce-blocks#7553 (https://github.com/woocommerce/woocommerce-blocks/pull/7651)
* Fix typo in HTML markup of ProductImage block placeholder

Typo caused rendering of incorrect HTML attributes: width and height of Product Image placeholder that were anyway ignored by the browser

* Remove inline styles (width and height) from ImagePlaceholder in ProductElements > Image block

Inline height took precedence over the inherited styles which made the placeholder image skewed (in loading and loaded state). Removal of those styles allows the ImagePlaceholder to adapt the height to the available space keeping the ratio or inherit the styles from the parent

* Remove inline styles (width and height) from placeholder image in ProductImage.php block

Inline styles applied to the placeholder image of ProductImage block were overriden by other styles with higher specificity, which made them redundant. Additionally, corresponding styles were removed from the placeholder image from Editor code as they caused UI glitches. Additional proof that it's safe to remove them is in the first commit in this branch, the purpose of which was to fix those styles as there was a typo which corrupted them and eventually inline width and height were ignored by the browser and not applied to the element

* Add test to check placeholder image renders without width and height inline attributes

This is to prevent adding inline width and height attributes so the sizing of the placeholder image is controlled by the inherited styles or element styles, in the same way as a regular product image

* Fix TypeScript errors in the block test file of Product Image

* Add generic alt text to placeholder image

Alt text added in this commit is a generic text, not description of the actual image. That's because the image itself is set externally through the settings and may change over time

* Revert adding placeholder image alt text and add comments to make the empty alt explicit

After a Github discussion: https://github.com/woocommerce/woocommerce-blocks/pull/7651\#discussion_r1019560494 it was decided the placeholder should NOT have alt text as it serves the purpose of decorative image. According to the guidelines decorative images should not have alt text: https://www.w3.org/WAI/tutorials/images/decorative/. Comments were added also to other places where it happens

* bot: update checkstyle.xml

Co-authored-by: Karol Manijak <karolm@Karols-MacBook-Pro.local>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-16 10:25:40 +01:00
Alba Rincón 54c65287ed Fix error when trying to access the queried object when it's null (https://github.com/woocommerce/woocommerce-blocks/pull/7664)
* Fix error when trying to access the queried object when it's null.

* Check if the `slug` exists

* Use the taxonomy name instead of the slug, otherwise it returns false
2022-11-11 17:16:40 +01:00
Albert Juhé Lluveras 4c06377e47 Display correct block template when filtering by attribute (https://github.com/woocommerce/woocommerce-blocks/pull/7640) 2022-11-11 11:32:40 +01:00
Daniel W. Robert 37a6b2ef63 Add Product Query Support for Atomic SKU Block (https://github.com/woocommerce/woocommerce-blocks/pull/7385)
* Add attributes, settings, and editor PQ settings.

- Adds isDescendentOfQueryLoop attribute and sets up usage in editor.
- Connects Context (via useContext) in editor.
- Sets up necessary hierarchy in block index file settings.

* Update parent inner blocks config.

Reassign parent array to ancestor array which allows for blocks to be
included with more flexibility - i.e., added within groups that are
children of the ancestor block.

* Add dynamic render function for PQ support.

* Update to use correct classnames on PHP side.

SSR markup was accidentally using rating classname instead of sku so it
was not applying the proper text transform seen in the editor.

* Rename BlockAttributes type to Attributes

This keeps things consistent with the type naming on the other blocks.

* Remove redundant spread of sharedConfig object.

We don't need to spread the `sharedConfig` object into the `blockConfig`
object when defining `blockConfig` since we spread/merge these two
objects when registering the block via `registerExperimentalBlockType`.

* bot: update checkstyle.xml

* bot: update checkstyle.xml

* Empty commit to trigger checks.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-11-10 13:32:07 -05:00
Paulo Arromba 7eeabeea69 Updated rate-limiting example snippet (https://github.com/woocommerce/woocommerce-blocks/pull/7650) 2022-11-10 11:39:46 +00:00
Tarun Vijwani 4f75d12188 Add woocommerce_blocks_loaded hook information to actions doc (https://github.com/woocommerce/woocommerce-blocks/pull/7600)
* Add woocommerce_blocks_loaded hook information to actions doc

* add docs to woocommerce_blocks_loaded hook inline

* fix docs

* Switch to updated wp-hooks/generator package

* Prevent syntax error in doc script from storeapi.php

* Remove footer from internal docs and examples

* Doc footer script should ignore examples and internal developer docs

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-11-10 09:52:04 +01:00
Paulo Arromba f857afae0f Add PHP8 Unit Testing (https://github.com/woocommerce/woocommerce-blocks/pull/7528)
* fixed method sig

* Updated to @wordpress/env@5.5.0 and set default PHP 7.4 for wp-env.

* updated Coding Standards flow to use PHP 8.0

* Added comment to E2E flows explaining what PHP version is used

* Revert "Updated to @wordpress/env@5.5.0 and set default PHP 7.4 for wp-env."

This reverts commit 696cd7f42edc9d9726b777cf4f83a501a6d63936.

* Added comment to Unit test flows explaining what PHP version is used.
Specified PHP version on .wp-env.json

* Fixed composer-lock.json version.

* Updated tests to run on PHP Unit 9.2.6

* Updated tests to run on PHP 8

* Reverted test, mismatched results between local and pipeline

* Removed Todo

* Updated platform overrides

* Update Migrationb tests with Mockery for PHP8 compat

* try at PHP unit flow matrix

* Fix blocks.ini invalid config

* Temp disable E2E

* Downgraded woocommerce/woocommerce-sniffs as it introduced new sniffs we should be handling on a different PR

* re-enable E2E tests

* blocks.ini fix

* revert blocks.ini fix

* Update @wordpress/env

* remove .htaccess mapping

* Fix permissions for tests

* Debug permissions

* Attempt at perm fix

* Attempt at perm fix

* Downgraded @wordpress/env

* Another attempt at upgrade @wordpress/env

* Attempt at cleaning wp-env before run

* Attempt at destroying wp-env before run. Disabled E2E.

* Attempt at destroying wp-env before run.

* debug wp-env data

* attempt at deleting wp-env data (destroy won't work due to prompt)

* re-enable E2E

* Fix deprecation warnings

* Cleaned wp-env data for E2E

* Fix perms for E2E

* Updated RateLimitsTests

* debug

* Force 7.4 for wp-env

* Run sh outside of npm

* Reverted E2E flow

* reverted wp-env-config.sh debug test

* reverted .wp-env.json phpVersion force

* Update tests/php/StoreApi/Utilities/ProductQueryFilters.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartExtensions.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartItems.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Products.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/ProductCollectionData.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Batch.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Checkout.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/CartCoupons.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/ProductAttributes.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Update tests/php/StoreApi/Routes/Cart.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* downgraded @wordpress/env to v4

* Reverted back to reflection class for pivate attribs manipulation on tests

* reverted JS unit testing job name

* Update tests/php/StoreApi/Formatters/TestMoneyFormatter.php

Co-authored-by: Mike Jolley <mike.jolley@me.com>

* Typo fix

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-11-09 15:28:08 +00:00
Alba Rincón 013ce2b9af Update to next dev version 2022-11-08 13:36:59 +01:00
github-actions[bot] 371f5980bb Release: 8.9.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7596)
* Empty commit for release pull request

* Update readme changelog

* Bump versions

* Bump versions

* Fix the minimum_supported_wp_version

* Update readme.txt

* Add testing instructions

* Change Filter Wrapper to Filter Block

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Remove Light from test instructions

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Fix version

Co-authored-by: Tung Du <dinhtungdu@gmail.com>

* Remove experimental section

* Improve formatting of instructions

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-11-08 13:30:03 +01:00
Mike Jolley 3c6a365697 Store API: Add missing documentation for reviews, categories, and tags (https://github.com/woocommerce/woocommerce-blocks/pull/7519)
* Update index

* Add missing docs
2022-11-07 10:37:00 +00:00
Mike Jolley 07a612f575 Experiment: Add Rate Limits to Store API (https://github.com/woocommerce/woocommerce-blocks/pull/5962)
* Add rate limiting to cart endpoints based on session

* Handle nonce and rate checks in permission_callback

* Rate limit checkout only

* Debug

* Unused AbstractRoute

* Code standards

* Modify core rate limit table

* Add rate limit at rest api level, not route level

* Rate limit helper

* Remove rate limit from routes

* Usused dep

* Remove custom error logic no longer needed

* Remove dependency

* Remove custom permission_callback

* Hash IP and handle null

* Remove error response handler

* revert error_to_response changes

* Remove add_response_headers

* Remove IDENTIFIER

* Remove white space

* Increase limit

* Missing class comment

* Move rate limiting code within store api codebase

* white space

* Fix return type

* Check rate limit expiry greater than now

* Remove x- prefix

* reorder functions

* remove table

* pass request to add_nonce_headers

* return early and avoid elseif on AbstractCartRoute:get_response()

* Refactor get_ip_address() before implementing options for functionality

* Change rate limit to 5 requests

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Change rate limit window to 60 seconds

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Disable rate limiting by default

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* Updated limits comment

* Example for Forwarded header

* Updated "woocommerce_store_api_enable_rate_limit_check" filter doc

* Added filter for the Store API rate limit check proxy support

* Add an action here that carries over the IP address being blocked.

* Added logic around setting the action_id, and returns an error when ip cannot be determined for users not logged in.

* Renamed action for limit exceeded.

* Common rate limiting header naming prefix, and fixed comment typos.

* Doc for Rate Limiting (wip)

* Example for Rate Limiting docs

* Remove private IP range block for rate limiting

* Refactored get_response() to add nonce headers to response instead of request

* Disable batching for Checkout calls to prevent bypassing Rate Limiting.

* Removed redundant arg.

* package-lock.json update

* Removed repeated func calls.

* Fix failing tests.

* Tests wip.

* Request limit and timeframe are now constants for RateLimits utility class.

* Tests for Rate Limit headers.

* Reverted PHPUnit config to enable all tests again.

* Update src/StoreApi/Authentication.php comment wording

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Removed possibly unnecessary get_ip_address() call.

* Changed wording on comment for get_ip_address() method.

* Simplified validate_ip() method.

* Fixed wrong header entry for "Forwarded" check.

* Unit testing for Authentication::get_ip_address()

* Comment explaining the reason to use ReflectionClass for testing get_ip_address().

* Support for error output outside batch request.

* MD linting.

* Refactor to implement options through a single filter.

* fixed md lint error and config file

* reverted accidental default func arg value removal

* re-enabled batch support for checkout

* action for limit exceed now also triggered in case we can't resolve the IP.

* Doc tweak.

* Return unresolved IP address when REMOTE_ADDR isn't set with proxy support disabled.

* Group unresolved ips for rate limiting

* Fixed bug where current limit wasn't properly initialized.

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-11-04 15:53:00 +00:00
Niels Lange 5300530428 Update ProductSchema description for attributes (https://github.com/woocommerce/woocommerce-blocks/pull/7495) 2022-11-03 11:16:01 +07:00
Luigi Teschio 27f9c746ea [Product Query] Fix filter block data counter (https://github.com/woocommerce/woocommerce-blocks/pull/7257)
* Product Query: Fix pagination issue

* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Price Block

* fix query relation

* fix on sale query

* Product Query - Add support for the Filter By Attributes block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Attributes block

* fix bugged pagination and on-sale filter after refactor

* address feedback

* Product Query - Add support for the Filter By Stock Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Stock Block

* Fix filter blocks: the data (e.g: max price or stock-status) match the variation woocommerce/woocommerce-blocks#7245

fix filter blocks: the data (e.g: max price or stock-status) match the variation

* disable phcs rules on top of the file

* replace parameter name

* fix eslint error
2022-11-02 10:03:23 +01:00
Luigi Teschio bec05d1062 [Product Query] Add support for the Filter Products By Stock block (https://github.com/woocommerce/woocommerce-blocks/pull/7251)
* Product Query: Fix pagination issue

* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Price Block

* fix query relation

* fix on sale query

* Product Query - Add support for the Filter By Attributes block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Attributes block

* fix bugged pagination and on-sale filter after refactor

* address feedback

* Product Query - Add support for the Filter By Stock Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Stock Block

* address feedback
2022-11-02 09:49:48 +01:00
Daniel W. Robert fdc07e5a96 Add Product Query Support for Atomic Rating Block (https://github.com/woocommerce/woocommerce-blocks/pull/7352)
* Add PQ support for client-side.

Set up the block for PQ support and add necessary adjustments for the
editor. Will address dynamic save functionality in a following commit.

* Add dynamic render function for PQ support.

* Add dynamic render callback for SSR.

* Remove client-side Save function.

* Add PQ Context interface to shared type defs.

* Convert all block JS files to TS.

* Remove commented import from block file.

* Add typecasting to block function params.

As a workaround, added a general Record type but left a TODO to revisit
the proper object, as there is a mismatch in the shape of the default
object property types and the actual types.

* Update inserter behavior.

Allows for the ability to add the rating block from in the inserter
(as long as it's an inner block of the listed parents in the config).
Also disables the placeholder product selector from being rendered
unnecessarily (i.e., when the context ID is present).

* Update parent inner blocks config.

Reassign parent array to ancestor array which allows for blocks to be
included with more flexibility - i.e., added within groups that are
children of the ancestor block.

* Add productID to rating Attributes interface.

* TS type casting and import adustments.

Some adjustments to utilize types that we already have available, along
with some syntax adjustments and more sensible import tweaks.

* Update type-casting to use ProductResponseItem

Instead of using the generic Record, we can utilize the
ProductResponseItem interface and set an omission for the average_rating
property until that is corrected to properly reflect the API response.

* Add alias to blocks dir for imports.

Allows us to use exports from the blocks dir as "external" imports. This
way we do not need to write long, relative import paths (which can be
fragile in the long run).
2022-10-31 14:56:17 -04:00
Luigi Teschio 87d527cf2c Fix Mini Cart Block global styles woocommerce/woocommerce-blocks#7379 (https://github.com/woocommerce/woocommerce-blocks/pull/7515)
* Fix Mini Cart Block global styles woocommerce/woocommerce-blocks#7379

Fix Mini Cart Block global styles

* add font_size
2022-10-31 11:47:01 +01:00
Daniel Dudzic aaa408e8dd Product button: Fix 'In cart' button localization. (https://github.com/woocommerce/woocommerce-blocks/pull/7504)
Fixes woocommerce/woocommerce-blocks#7494.

Co-authored-by: Niels Lange <info@nielslange.de>
2022-10-29 01:42:07 +02:00
Luigi Teschio 030ebf8142 Fix inconsistent button styling with TT3 (https://github.com/woocommerce/woocommerce-blocks/pull/7516)
* fix inconsistent button styling with TT3

* use wc_wp_theme_get_element_class_name

* add check to be sure that wc_wp_theme_get_element_class_name function exists
2022-10-28 19:07:56 +02:00
Lucio Giannotta af557b0281 Add Stock Status setting to Product Query Block (https://github.com/woocommerce/woocommerce-blocks/pull/7397)
* Add Stock Status to Product Query block filters

Creates a new Tools Panel called “Product filters” where we can neatly
organize our product specific settings. Eventually, this panel could be
merged with the core “Filters” panel; however, at the time of this
commit, this is impossible (see WordPress/gutenbergwoocommerce/woocommerce-blocks#43684 for a PoC).

Also moved the “On Sale” setting under this newly created panel.

* Add `resetAll` callback for the new Tools Panel

Tools Panels come with a “Reset All” functionality, that's supposed to
return all the settings to their original state.

In our case, things are a bit more complicated, as the original state
is dependant on the current variation, so it can't be hard-coded like it
is on the core block.
2022-10-27 19:40:10 +02:00
Seghir Nadir 030b6f05a8 Calculate cart totals after running extensions (https://github.com/woocommerce/woocommerce-blocks/pull/7490)
* calculate cart totals afer running extensions

* update totlas call in CartUpdateCustomer

* test that cart is recalcing
2022-10-27 15:29:27 +01:00
Luigi Teschio 1a9e5cfe13 [Product Query] Add support for the Filter Products By Attributes block (https://github.com/woocommerce/woocommerce-blocks/pull/7186)
* Product Query: Fix pagination issue

* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Price Block

* fix query relation

* fix on sale query

* Product Query - Add support for the Filter By Attributes block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Attributes block

* fix bugged pagination and on-sale filter after refactor

* address feedback

* address feedback
2022-10-26 16:53:01 +02:00
Tung Du 6d636181c7 Performance: preload store pages (https://github.com/woocommerce/woocommerce-blocks/pull/6898) 2022-10-26 10:28:28 +07:00
Thomas Roberts 9408e7a42e Update version numbers following release 2022-10-25 13:28:59 +01:00
Thomas Roberts c7ad51cf34 Bumping version strings to new version. 2022-10-25 12:45:41 +01:00
Mike Jolley 350571a705 Replace wc()->api->get_endpoint_data with item response from the cart schema class. (https://github.com/woocommerce/woocommerce-blocks/pull/7361)
`wc()->api->get_endpoint_data` works, however, because it encodes and decodes from JSON, objects are lost and converted into arrays.

For the API is this not a problem, because they are output to JSON in the same way. For consumers however, they may be expecting object type.

We can fix this by getting the response data from the Cart Schema class directly.
2022-10-21 15:20:29 +01:00
Tung Du 8b17d35bb8 fix deep array sort (https://github.com/woocommerce/woocommerce-blocks/pull/7403) 2022-10-14 15:22:16 +01:00
Mike Jolley 0588cfbeba Introduce woocommerce_store_api_add_to_cart_data (https://github.com/woocommerce/woocommerce-blocks/pull/7252) 2022-10-14 13:30:23 +01:00
Mike Jolley 51c94eada5 Prevent resource hinting when cart/checkout blocks are not in use (https://github.com/woocommerce/woocommerce-blocks/pull/7364)
* Skip resource hinting on admin requests woocommerce/woocommerce-blocks#7215

* Output resource hinting only when using cart/checkout blocks on cart/checkout pages woocommerce/woocommerce-blocks#7216
2022-10-14 13:13:22 +01:00
Paulo Arromba 9cc3004f69 Updated version to 8.8.0-dev (https://github.com/woocommerce/woocommerce-blocks/pull/7372) 2022-10-12 11:31:28 +01:00
Tung Du bdac9355fe Fix: Product Query: Update the Editor preview when custom attributes are changed (https://github.com/woocommerce/woocommerce-blocks/pull/7366) 2022-10-12 17:27:31 +07:00
github-actions[bot] c5fcc339d1 Release: 8.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7355)
* Empty commit for release pull request

* Updated changelog.

* Minor lint fix.

* 8.7.0 Testing instructions

* Updated and tidy docs/internal-developers/testing/releases/README.md

* Add filter-link-button mixin (https://github.com/woocommerce/woocommerce-blocks/pull/7357)

* Set default style to link-button mixin

It was identified that we currently have 3 different behaviors for links used in the application. In issue woocommerce/woocommerce-blocks#1778, it was discussed a set of good practices that we should follow in order to obtain consistency between links.

Currently, the link-button mixin is already used by the 'Clear all' button in the Active Filters block, so the idea was to increment it with a common pattern (font size small, font-weight normal, underlined by default and not underlined when on hover) that can be reused by other components (for example FilterResetButton).

* Change link-button mixin to make it attend the expected default style for links

* Replace text-button with link-button mixin in FilterResetButton component

* Add new mixin for links in filter blocks

* Revert change to link-button mixin to prevent it to affect link buttons on Checkout page

* Add filter-link-button mixin that can be used in filter blocks

* Remove link-button styles that were moved to filter-link-button mixin

By default, link-button mixin styles should have only styles from the text-button mixin and also be underlined.

The styles for link button in filter blocks should reside in filter-link-button mixin.

* Cherry picked Add filter-link-button mixin woocommerce/woocommerce-blocks#7357 and updated testing instructions

* Re-added woocommerce/woocommerce-blocks#7273 to changelog

* Correct block name and description (https://github.com/woocommerce/woocommerce-blocks/pull/7354)

* Correct block name and description

* remove duplicated description for controls blocks

* remove duplicated title and desc

* Revert "remove duplicated description for controls blocks"

This reverts commit ed5417eb0e5191ed2f1def2a04c9e724fe70856a.

* removed woocommerce/woocommerce-blocks#7338 from testing instructions and changelog

* Updated testing zip package.

* Minor formatting fix on the release instructions

* change any to or below the express payment method on cart (https://github.com/woocommerce/woocommerce-blocks/pull/7369)

* Updated zip.

* Add temporary workaround to fix inserting Cart block in WordPress.com (https://github.com/woocommerce/woocommerce-blocks/pull/7367)

* remove problematic actions as deps

* add inline docs

* add todo comment

* Cherry picked: Fix a problem that causes an infinite loop when inserting Cart block in wordpress.com (7367)

* Updated testing zip.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-10-12 11:03:38 +01:00
Darren Ethier b6e178fade Fix error with usage of Cart::deep_sort_with_accents (https://github.com/woocommerce/woocommerce-blocks/pull/6896)
* implement fix and tests

* fix linting issue

* fix tests

* doh add missing semi-colon

* fix tests

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2022-10-11 15:36:54 +01:00
Daniel Dudzic 2252557ac1 Products by Rating: Add block transform for the legacy rating widget (https://github.com/woocommerce/woocommerce-blocks/pull/7338)
* Products by Rating: Add legacy rating widget deprecation
* Products by Rating: Hide legacy Product Ratings widget
2022-10-10 11:48:45 +02:00
Daniel W. Robert 4b6f3cae7e Add Product Query Support for Atomic Price Block (https://github.com/woocommerce/woocommerce-blocks/pull/7199)
* Add attributes, settings, and editor PQ settings.

- Adds isDescendentOfQueryLoop attribute and sets up usage in editor.
- Connects Context (via useContext) in editor.
- Sets up necessary hierarchy in block index file settings.

* Add server-side rendered product price.

Adds the SSR output for the atomic Price block for PQ support.

* Remove Save attribute from JS index.

To allow for the block to be SSR, we need to remove the Save
attrubite/function on the JS side and allow for the PHP class to handle
it on the backend.

* Update PHP asset register method for added clarity

* Adjust block attr/context spreading for clarity.
2022-10-07 12:08:33 -04:00
Tom Cafferkey 872788e13c Convert filter blocks to inner blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6978)
* register filter wrapper block

* register block variation

* rename the active filters wrapper

* prevent 404 error

* Revert "prevent 404 error"

This reverts commit 8b6cb7c6658b2a5a99b890b67f1dce8c1c51cdbf.

* render parent wrapper block

* support price filter block

* hide the active filter block from inserter

* swap the title of wrapper and inner filter block for active filters

* hide the legacy heading for the price filter

* update block title and description for active filters and price filter

* remove heading control for price filter

* remove heading control for active filters

* update pattern

* try: upgrade button

* limit the number of inner block to 2

* prevent removing the inner filter block

* Revert "prevent removing the inner filter block"

This reverts commit 83b7feed78a7a7f50fd5799d1706faa9f2fc9050.

* convert stock filter to inner block

* refactor block upgrade button to share between filter blocks

* update default heading

* update pattern

* update icon and title

* Fix stock filter error by importing translations package

* Upgrade Active Filters name to Active Filter Controls

* Add upgrade support to price filter

* Convert attribute filter to inner block (https://github.com/woocommerce/woocommerce-blocks/pull/7101)

* wip: convert attribute filter to inner block

* fix: render inner attribute filter block on the front end

* refactor: inner block wrapper, extract the attribute parsing logic into a utility

Co-authored-by: Tom Cafferkey <tjcafferkey@gmail.com>

* Set correct attribute on the new filter blocks when they are upgraded

* Use the Warning component to display the upgrade message so it is consistent with Gutenberg

* address code review

* better detect legacy block to show the upgrade notice

* rename UpgradeToolbarButton to UpgradeNotice

* add upgrade notice to the stock filter block

* rename InnerBlockWrapper to BlockWrapper

* attribute-filter: control wrapper visibility

* passing block attributes down to inner active filters control block

* fix styling of inner attribute filter control block

* passing attribute to inner price filter control block

* passing down the attribute to inner stock filter control block

* remove unneccessary parsing

* use default scope for variations

* fix default attribute values

* use default block appender

* fix: lock control blocks

* remove dynamic title code from attribute filter block

* register active filters as variation and set it to the default that overrides the base block

* fix isActive for default variation

* fix: isActive logic for the active filters block

* register side effect

* fix ts error

* e2e: fix active filters block backend test

* e2e: fix frontend active filters test

* e2e: fix attribute filter test

* e2e: fix price filter test

* e2e: fix stock filter test

* e2e: update fixture

* e2e: fix attribute filter test

* remove invalid test

* e2e: update heading selector for price filter in backend test

* e2e: fixe backend price filter heading test

* fix: patterns i18n

* fix: heading level when upgrading the block

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-10-07 16:00:19 +01:00
Tarun Vijwani 75d6e84552 Hide the shipping address form from the Checkout when the "Force shipping to the customer billing address" is enabled (https://github.com/woocommerce/woocommerce-blocks/pull/7268)
* Hide shipping address form from the Checkout when forced billing address is enabled.

* Update shipping address when billing address is changed

* Display shipping options

* Fixed needs shipping condition

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-10-07 08:50:26 +01:00
Alex Florisca ce68c6ef40 Return 424 instead of 400 when checkout payment fails (https://github.com/woocommerce/woocommerce-blocks/pull/7273)
* Return 424 instead of 400 when checkout payment fails

* Change status for 424 to 402
2022-10-05 10:50:05 +01:00
Daniel W. Robert 3cfc4ec44c Minor Refactor to Prod Image Backend Render Functions (https://github.com/woocommerce/woocommerce-blocks/pull/7247)
* Refactor Product Image anchor render function.

Move closing tag for the anchor into the render function and pass badge
and image output into anchor children as args.

Also removes duplicate border radius logic from anchor render function,
as it is already present on the class render method.

* Clean up sprintf args.

* Replace deprecated placeholder function.

The `woocommerce_placeholder_img_src` function has been depricated since
v3.0. This replaces that function with the `wc_placeholder_img_src`
function.
2022-10-03 19:48:51 -04:00
Mike Jolley 6f93c5cf1b Store API - Cart JWT tokens/session handling (https://github.com/woocommerce/woocommerce-blocks/pull/5953)
* Re-apply token support

* Updated nonce headers

* Updated package-lock.json

* test commit to debug failing git hooks

* Revert "test commit to debug failing git hooks"

This reverts commit e64086b0a7aede154705be09c7b3433b08bc1e34.

* JsonWebToken utility class for generating and validating HS256 JWT tokens. Removed third-party JWT library.

* Add ext-hash to composer (required by hash_hmac())

* Removed unnecessary method param.

* Tests for retrieving cart contents via Cart-Token

* Removed token tests ( we can't properly test cart token functionality until we refactor the way it intercepts calls to replace the session object )

* Abstracted payload from JsonWebToken class. We can now use it to encode custom payloads and reuse them wherever we want.

* Fixed missing check for token expiration in the payload.

* MD lint error and config fix

* Update composer.lock

* Fixed bug using the wrong nonce header.

* Refactor to properly save session data based on cart token.

* Refactored DB queries to properly use prepared statement

* Removed underscore prefix for class attributes

* Fixed spaces instead of tabs indenting composer.json. Cleaned up .editorconfig

* Cleaned up borked .md comments.

* Comment for WP_SETUP_CONFIG check.

* Reverted SQL prepared statement for including table names.

* Used hash_equals() for signature comparison. Renamed some wrongly named properties.

* Updated composer.lock

* Reverted some accidentally removed lines on some documentation files.

* Reverted accidentally removed line on docs/internal-developers/testing/releases/404.md

* Changed param type from mixed to

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-10-03 11:49:32 +01:00
Mik 6d5f4dbe7a Support a GT tracking ID (https://github.com/woocommerce/woocommerce-blocks/pull/7213) 2022-09-30 06:54:20 +01:00
Daniel Dudzic 8ae19b5a42 Add a Products by Rating filter block (https://github.com/woocommerce/woocommerce-blocks/pull/7048)
* Add interactivity to the Product by Rating filter block

* Fix block with the latest repo changes

* Product by Rating: Code tidying up

* Add an experimental build gate and update block title and description

* Remove redundant title and description

* Add support for the CheckboxList component in the Products by Rating block

* Products by Rating: Minor code clean-up

* Active Filters: Fix the Clear All button for Ratings. Closes #woocommerce/woocommerce-blocks#7172

* Products by Rating: Add misc TS fixes
2022-09-28 23:12:14 +02:00
Luigi Teschio 790dbd3765 Remove qm/debug action (https://github.com/woocommerce/woocommerce-blocks/pull/7240)
Remove qm/debug action
2022-09-28 15:58:07 +02:00
Luigi Teschio 222407cb93 [Product Query] Add support for the Filter By Price Block (https://github.com/woocommerce/woocommerce-blocks/pull/7162)
* Product Query: Fix pagination issue

* Product Query - Add support for the Filter By Price Block woocommerce/woocommerce-blocks#6790

Product Query - Add support for the Filter By Price Block

* fix query relation

* fix on sale query

* fix bugged pagination and on-sale filter after refactor

* fix reload page when the Filter By Price block is used with All Products block

* use array_intersect instead of array_merge
2022-09-28 15:44:20 +02:00
Alex Florisca d13d5b3fdd Feature: Data Store Migration - Payments (https://github.com/woocommerce/woocommerce-blocks/pull/6619)
* Move paymentMethodDataProvider into a data store (https://github.com/woocommerce/woocommerce-blocks/pull/6208)

* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type

* Add default state for PaymentMethod data store

* Add preliminary action types

* Add preliminary action dispatchers

* Create payment method data store

* Add preliminary reducers for payment method data store

* Add preliminary selectors for payment method data store

* Add reducers/actions for registering payment methods

* Export payment method data store key

* Add test for payment method data reducers

* Add shouldSavePaymentMethod selector

* Add store key as constant

* Add more action types for registering and initializing payment methods

* Get active payment method from data store instead of from context

* Add registered methods to default state of payment method data store

* Dispatch name of registered payment method to payment method data store

* Remove setShouldSavePayment from payment method dispatcher and types

* Get payment methods from registry instead of payment context

* Add available payment methods to store

* Add function to check whether payment methods are allowed to be used

* Add selector to check if payments are initialised

* Remove resolvers and add controls to payment method data store

* Change type of payment requirements to string[]

* Turn addRegistered and addRegisteredExpress into generators

This is so we can check each payment method's validity before adding it to the list of available payment methods

* Add action type for setting express payments as initialized

* Only select from available methods in payment method options

* Remove argument from addRegisteredPaymentMethod in payment method registry

* Rename folder and store name to not contain the word data

* Add selectors for express payment methods and their initialisation

* Delete controls again in favour of thunks

* Rename payment-method-data to payment-methdods

* Create new setDefaultPaymentMethod function

This will set the payment method when the cart loads.

* Add CustomerPaymentMethodConfiguration type

* Make getAvailableExpressPaymentMethods return correct data

* Check express methods and normal methods when cart changes

* Add action for setting active express payment methods

* Handle express methods in checkPaymentMethodCanPay

* Hide express payments area if none are available

* Add selector for paymentMethodData

* Add customer data to default state and add selector for it

* Add setPaymentStatus action and reducer case

* Set the default payment method when one isn't selected

* Correct types on getCustomerPaymentMethods

* Set status in data store alongside context status

* Comment out active gateway selection - remove later

* Set status in express payment methods in data store

* Use correct key in payment method data context

* Directly check payment methods from the list in blocks-registry

* Add semicolon to import statement

* Fix payment method data state call

* Get paymentMethodData from store not context

* Fix linting issues

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>

* Rebase on the update/checkout-data-store branch & Fix failed payments (https://github.com/woocommerce/woocommerce-blocks/pull/6587)

* Add checkout data store

* wip on checkout data store

* CheckoutContext now uses the checkout store

* Investigated and removed setting the redirectUrl on the default state

* update extension and address hooks to use checkout data store

* use checkout data store in checkout-processor and use-checkout-button

* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity

* Remove useCheckoutContext from shipping provider

* Remove isCalculating from state

* Removed useCheckoutContext from lots of places

* Remove useCheckoutContext from checkout-payment-block

* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block

* add isCart selector and action and update the checkoutstate context

* Fixed redirectUrl bug by using thunks

* Remove dispatchActions from checkout-state

* Change SET_HAS_ERROR action to be neater

* Thomas' feedback

* Tidy up

* Oops, deleted things I shouldn't have

* Typescript

* Fix types

* Fix tests

* Remove isCart

* Update docs and remove unecessary getRedirectUrl() selector

* set correct type for preloadedCheckoutData

* Remove duplicate Address type

* Fix missing addresses from type-defs index

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Revert feedback changes

* REvert feedback formatting

* Update docs formatting

* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type

* Add default state for PaymentMethod data store

* Add preliminary action types

* Add preliminary action dispatchers

* Create payment method data store

* Add preliminary reducers for payment method data store

* Add preliminary selectors for payment method data store

* Add reducers/actions for registering payment methods

* Export payment method data store key

* Add test for payment method data reducers

* Add shouldSavePaymentMethod selector

* Add store key as constant

* Add more action types for registering and initializing payment methods

* Get active payment method from data store instead of from context

* Add registered methods to default state of payment method data store

* Dispatch name of registered payment method to payment method data store

* Remove setShouldSavePayment from payment method dispatcher and types

* Get payment methods from registry instead of payment context

* Add available payment methods to store

* Add function to check whether payment methods are allowed to be used

* Add selector to check if payments are initialised

* Remove resolvers and add controls to payment method data store

* Change type of payment requirements to string[]

* Turn addRegistered and addRegisteredExpress into generators

This is so we can check each payment method's validity before adding it to the list of available payment methods

* Add action type for setting express payments as initialized

* Only select from available methods in payment method options

* Remove argument from addRegisteredPaymentMethod in payment method registry

* Rename folder and store name to not contain the word data

* Add selectors for express payment methods and their initialisation

* Delete controls again in favour of thunks

* Rename payment-method-data to payment-methdods

* Create new setDefaultPaymentMethod function

This will set the payment method when the cart loads.

* Add CustomerPaymentMethodConfiguration type

* Make getAvailableExpressPaymentMethods return correct data

* Check express methods and normal methods when cart changes

* Add action for setting active express payment methods

* Handle express methods in checkPaymentMethodCanPay

* Hide express payments area if none are available

* Add selector for paymentMethodData

* Add customer data to default state and add selector for it

* Add setPaymentStatus action and reducer case

* Set the default payment method when one isn't selected

* Correct types on getCustomerPaymentMethods

* Set status in data store alongside context status

* Comment out active gateway selection - remove later

* Set status in express payment methods in data store

* Directly check payment methods from the list in blocks-registry

* Add semicolon to import statement

* Fix payment method data state call

* Get paymentMethodData from store not context

* Add addPaymentMethodData action/reducer case

* Update payment method on payment success

* Add 'getCurrentStatus' selector

* Remove the temporary solution

For getting payment method data into the data store

* Prevent the 'success' context action from being dispatched

* Update the "setPaymentStatus" data store action

Accept status as an object instead of string

* Fix the "currentStatus" reducer state update value

* Get payment data into data store

* Set the correct payment status to data store

* Get the success status of payment from data store

* Use store data in the payment dispatchers

Replace the React useReducers action in the payment dispatchers file with
the payment method data store

* Get payment status from data store

* Use data store for the payment error status

* Use payment data store failed status

* Use payment data store for the isFinished status

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>

* Fix merge conflict error

* Set & get the provider's state from our data store instead of React's useReducer (https://github.com/woocommerce/woocommerce-blocks/pull/6588)

* Add checkout data store

* wip on checkout data store

* CheckoutContext now uses the checkout store

* Investigated and removed setting the redirectUrl on the default state

* update extension and address hooks to use checkout data store

* use checkout data store in checkout-processor and use-checkout-button

* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity

* Remove useCheckoutContext from shipping provider

* Remove isCalculating from state

* Removed useCheckoutContext from lots of places

* Remove useCheckoutContext from checkout-payment-block

* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block

* add isCart selector and action and update the checkoutstate context

* Fixed redirectUrl bug by using thunks

* Remove dispatchActions from checkout-state

* Change SET_HAS_ERROR action to be neater

* Thomas' feedback

* Tidy up

* Oops, deleted things I shouldn't have

* Typescript

* Fix types

* Fix tests

* Remove isCart

* Update docs and remove unecessary getRedirectUrl() selector

* set correct type for preloadedCheckoutData

* Remove duplicate Address type

* Fix missing addresses from type-defs index

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Revert feedback changes

* REvert feedback formatting

* Update docs formatting

* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type

* Add default state for PaymentMethod data store

* Add preliminary action types

* Add preliminary action dispatchers

* Create payment method data store

* Add preliminary reducers for payment method data store

* Add preliminary selectors for payment method data store

* Add reducers/actions for registering payment methods

* Export payment method data store key

* Add test for payment method data reducers

* Add shouldSavePaymentMethod selector

* Add store key as constant

* Add more action types for registering and initializing payment methods

* Get active payment method from data store instead of from context

* Add registered methods to default state of payment method data store

* Dispatch name of registered payment method to payment method data store

* Remove setShouldSavePayment from payment method dispatcher and types

* Get payment methods from registry instead of payment context

* Add available payment methods to store

* Add function to check whether payment methods are allowed to be used

* Add selector to check if payments are initialised

* Remove resolvers and add controls to payment method data store

* Change type of payment requirements to string[]

* Turn addRegistered and addRegisteredExpress into generators

This is so we can check each payment method's validity before adding it to the list of available payment methods

* Add action type for setting express payments as initialized

* Only select from available methods in payment method options

* Remove argument from addRegisteredPaymentMethod in payment method registry

* Rename folder and store name to not contain the word data

* Add selectors for express payment methods and their initialisation

* Delete controls again in favour of thunks

* Rename payment-method-data to payment-methdods

* Create new setDefaultPaymentMethod function

This will set the payment method when the cart loads.

* Add CustomerPaymentMethodConfiguration type

* Make getAvailableExpressPaymentMethods return correct data

* Check express methods and normal methods when cart changes

* Add action for setting active express payment methods

* Handle express methods in checkPaymentMethodCanPay

* Hide express payments area if none are available

* Add selector for paymentMethodData

* Add customer data to default state and add selector for it

* Add setPaymentStatus action and reducer case

* Set the default payment method when one isn't selected

* Correct types on getCustomerPaymentMethods

* Set status in data store alongside context status

* Comment out active gateway selection - remove later

* Set status in express payment methods in data store

* Directly check payment methods from the list in blocks-registry

* Add semicolon to import statement

* Fix payment method data state call

* Get paymentMethodData from store not context

* Add addPaymentMethodData action/reducer case

* Update payment method on payment success

* Add 'getCurrentStatus' selector

* Remove the temporary solution

For getting payment method data into the data store

* Prevent the 'success' context action from being dispatched

* Update the "setPaymentStatus" data store action

Accept status as an object instead of string

* Fix the "currentStatus" reducer state update value

* Get payment data into data store

* Set the correct payment status to data store

* Get the success status of payment from data store

* Use store data in the payment dispatchers

Replace the React useReducers action in the payment dispatchers file with
the payment method data store

* Get payment status from data store

* Use data store for the payment error status

* Use payment data store failed status

* Use payment data store for the isFinished status

* Update the setPaymentStatus argument

* Set up setRegisteredPaymentMethods in data store

* Use the data store version of the registeredPaymentMethods

* Fix the default state type of the registeredPaymentMethods

* Set up setRegisteredExpressPaymentMethod in data store

* Use the data version of the registred express payment methods

* Set the correct action type for removing payment methods

* Fix default state express payment methods type

* Use the store data version of activePaymentMethod

* Use setActivePaymentMethod in the dispatchers file

And refactor code

* Update payment status arguments for express payment methods

* Use paymentMethodData from the data store

* Use payment method's errorMessage from data store

* Update paymentMethods list in data store reducer

* Replace remaining payment context data with data store

* Clean up payment method context file

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>

* Get payment method data directly from the data store instead of the usePaymentMethodDataContext hook (https://github.com/woocommerce/woocommerce-blocks/pull/6589)

* Add checkout data store

* wip on checkout data store

* CheckoutContext now uses the checkout store

* Investigated and removed setting the redirectUrl on the default state

* update extension and address hooks to use checkout data store

* use checkout data store in checkout-processor and use-checkout-button

* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity

* Remove useCheckoutContext from shipping provider

* Remove isCalculating from state

* Removed useCheckoutContext from lots of places

* Remove useCheckoutContext from checkout-payment-block

* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block

* add isCart selector and action and update the checkoutstate context

* Fixed redirectUrl bug by using thunks

* Remove dispatchActions from checkout-state

* Change SET_HAS_ERROR action to be neater

* Thomas' feedback

* Tidy up

* Oops, deleted things I shouldn't have

* Typescript

* Fix types

* Fix tests

* Remove isCart

* Update docs and remove unecessary getRedirectUrl() selector

* set correct type for preloadedCheckoutData

* Remove duplicate Address type

* Fix missing addresses from type-defs index

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Revert feedback changes

* REvert feedback formatting

* Update docs formatting

* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type

* Add default state for PaymentMethod data store

* Add preliminary action types

* Add preliminary action dispatchers

* Create payment method data store

* Add preliminary reducers for payment method data store

* Add preliminary selectors for payment method data store

* Add reducers/actions for registering payment methods

* Export payment method data store key

* Add test for payment method data reducers

* Add shouldSavePaymentMethod selector

* Add store key as constant

* Add more action types for registering and initializing payment methods

* Get active payment method from data store instead of from context

* Add registered methods to default state of payment method data store

* Dispatch name of registered payment method to payment method data store

* Remove setShouldSavePayment from payment method dispatcher and types

* Get payment methods from registry instead of payment context

* Add available payment methods to store

* Add function to check whether payment methods are allowed to be used

* Add selector to check if payments are initialised

* Remove resolvers and add controls to payment method data store

* Change type of payment requirements to string[]

* Turn addRegistered and addRegisteredExpress into generators

This is so we can check each payment method's validity before adding it to the list of available payment methods

* Add action type for setting express payments as initialized

* Only select from available methods in payment method options

* Remove argument from addRegisteredPaymentMethod in payment method registry

* Rename folder and store name to not contain the word data

* Add selectors for express payment methods and their initialisation

* Delete controls again in favour of thunks

* Rename payment-method-data to payment-methdods

* Create new setDefaultPaymentMethod function

This will set the payment method when the cart loads.

* Add CustomerPaymentMethodConfiguration type

* Make getAvailableExpressPaymentMethods return correct data

* Check express methods and normal methods when cart changes

* Add action for setting active express payment methods

* Handle express methods in checkPaymentMethodCanPay

* Hide express payments area if none are available

* Add selector for paymentMethodData

* Add customer data to default state and add selector for it

* Add setPaymentStatus action and reducer case

* Set the default payment method when one isn't selected

* Correct types on getCustomerPaymentMethods

* Set status in data store alongside context status

* Comment out active gateway selection - remove later

* Set status in express payment methods in data store

* Directly check payment methods from the list in blocks-registry

* Add semicolon to import statement

* Fix payment method data state call

* Get paymentMethodData from store not context

* Add addPaymentMethodData action/reducer case

* Update payment method on payment success

* Add 'getCurrentStatus' selector

* Remove the temporary solution

For getting payment method data into the data store

* Prevent the 'success' context action from being dispatched

* Update the "setPaymentStatus" data store action

Accept status as an object instead of string

* Fix the "currentStatus" reducer state update value

* Get payment data into data store

* Set the correct payment status to data store

* Get the success status of payment from data store

* Use store data in the payment dispatchers

Replace the React useReducers action in the payment dispatchers file with
the payment method data store

* Get payment status from data store

* Use data store for the payment error status

* Use payment data store failed status

* Use payment data store for the isFinished status

* Update the setPaymentStatus argument

* Set up setRegisteredPaymentMethods in data store

* Use the data store version of the registeredPaymentMethods

* Fix the default state type of the registeredPaymentMethods

* Set up setRegisteredExpressPaymentMethod in data store

* Use the data version of the registred express payment methods

* Set the correct action type for removing payment methods

* Fix default state express payment methods type

* Use the store data version of activePaymentMethod

* Use setActivePaymentMethod in the dispatchers file

And refactor code

* Update payment status arguments for express payment methods

* Use paymentMethodData from the data store

* Use payment method's errorMessage from data store

* Update paymentMethods list in data store reducer

* Replace remaining payment context data with data store

* Clean up payment method context file

* Get payment method state from data store in the checkout submit hook

* Copy types.ts file into the payment data store folder

* Fix isExpressPaymentMethodActive selector

* Move the entire currentStatus into the data store

* Replace the payment context state with the data store

* Fix getActiveSavedToken & clean up the context file

* Use the accutrate name of the "createErrorNotice"

* Update the payment method data store key import

* Diable unused state from the context

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>

* Refactor the payment method data store & context (https://github.com/woocommerce/woocommerce-blocks/pull/6607)

* Add checkout data store

* wip on checkout data store

* CheckoutContext now uses the checkout store

* Investigated and removed setting the redirectUrl on the default state

* update extension and address hooks to use checkout data store

* use checkout data store in checkout-processor and use-checkout-button

* trim useCheckoutContext from use-payment-method-interface && use-store-cart-item-quantity

* Remove useCheckoutContext from shipping provider

* Remove isCalculating from state

* Removed useCheckoutContext from lots of places

* Remove useCheckoutContext from checkout-payment-block

* Remove useCheckoutContext in checkout-shipping-methods-block and checkout-shipping-address-block

* add isCart selector and action and update the checkoutstate context

* Fixed redirectUrl bug by using thunks

* Remove dispatchActions from checkout-state

* Change SET_HAS_ERROR action to be neater

* Thomas' feedback

* Tidy up

* Oops, deleted things I shouldn't have

* Typescript

* Fix types

* Fix tests

* Remove isCart

* Update docs and remove unecessary getRedirectUrl() selector

* set correct type for preloadedCheckoutData

* Remove duplicate Address type

* Fix missing addresses from type-defs index

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>

* Revert feedback changes

* REvert feedback formatting

* Update docs formatting

* Fix typographical error on LegacyRegisterExpressPaymentMethodFunction type

* Add default state for PaymentMethod data store

* Add preliminary action types

* Add preliminary action dispatchers

* Create payment method data store

* Add preliminary reducers for payment method data store

* Add preliminary selectors for payment method data store

* Add reducers/actions for registering payment methods

* Export payment method data store key

* Add test for payment method data reducers

* Add shouldSavePaymentMethod selector

* Add store key as constant

* Add more action types for registering and initializing payment methods

* Get active payment method from data store instead of from context

* Add registered methods to default state of payment method data store

* Dispatch name of registered payment method to payment method data store

* Remove setShouldSavePayment from payment method dispatcher and types

* Get payment methods from registry instead of payment context

* Add available payment methods to store

* Add function to check whether payment methods are allowed to be used

* Add selector to check if payments are initialised

* Remove resolvers and add controls to payment method data store

* Change type of payment requirements to string[]

* Turn addRegistered and addRegisteredExpress into generators

This is so we can check each payment method's validity before adding it to the list of available payment methods

* Add action type for setting express payments as initialized

* Only select from available methods in payment method options

* Remove argument from addRegisteredPaymentMethod in payment method registry

* Rename folder and store name to not contain the word data

* Add selectors for express payment methods and their initialisation

* Delete controls again in favour of thunks

* Rename payment-method-data to payment-methdods

* Create new setDefaultPaymentMethod function

This will set the payment method when the cart loads.

* Add CustomerPaymentMethodConfiguration type

* Make getAvailableExpressPaymentMethods return correct data

* Check express methods and normal methods when cart changes

* Add action for setting active express payment methods

* Handle express methods in checkPaymentMethodCanPay

* Hide express payments area if none are available

* Add selector for paymentMethodData

* Add customer data to default state and add selector for it

* Add setPaymentStatus action and reducer case

* Set the default payment method when one isn't selected

* Correct types on getCustomerPaymentMethods

* Set status in data store alongside context status

* Comment out active gateway selection - remove later

* Set status in express payment methods in data store

* Directly check payment methods from the list in blocks-registry

* Add semicolon to import statement

* Fix payment method data state call

* Get paymentMethodData from store not context

* Add addPaymentMethodData action/reducer case

* Update payment method on payment success

* Add 'getCurrentStatus' selector

* Remove the temporary solution

For getting payment method data into the data store

* Prevent the 'success' context action from being dispatched

* Update the "setPaymentStatus" data store action

Accept status as an object instead of string

* Fix the "currentStatus" reducer state update value

* Get payment data into data store

* Set the correct payment status to data store

* Get the success status of payment from data store

* Use store data in the payment dispatchers

Replace the React useReducers action in the payment dispatchers file with
the payment method data store

* Get payment status from data store

* Use data store for the payment error status

* Use payment data store failed status

* Use payment data store for the isFinished status

* Update the setPaymentStatus argument

* Set up setRegisteredPaymentMethods in data store

* Use the data store version of the registeredPaymentMethods

* Fix the default state type of the registeredPaymentMethods

* Set up setRegisteredExpressPaymentMethod in data store

* Use the data version of the registred express payment methods

* Set the correct action type for removing payment methods

* Fix default state express payment methods type

* Use the store data version of activePaymentMethod

* Use setActivePaymentMethod in the dispatchers file

And refactor code

* Update payment status arguments for express payment methods

* Use paymentMethodData from the data store

* Use payment method's errorMessage from data store

* Update paymentMethods list in data store reducer

* Replace remaining payment context data with data store

* Clean up payment method context file

* Get payment method state from data store in the checkout submit hook

* Copy types.ts file into the payment data store folder

* Fix isExpressPaymentMethodActive selector

* Move the entire currentStatus into the data store

* Replace the payment context state with the data store

* Fix getActiveSavedToken & clean up the context file

* Use the accutrate name of the "createErrorNotice"

* Update the payment method data store key import

* Diable unused state from the context

* Get enabled customer payment methods using data store selector

* Remove remaining useReducer action from the dispatchers file

* Update types and remove unused vars

* Remove the payment method dispatchers hook

* Refactor & clean up (remove unused files)

* Remove commented line from payment methods types

* Move event emitter into thunks

Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>

* Remove checkout-state after merge conflicts

* Fix linting errors

* Move types to types.ts

* Move default states into respective store folders

* Fix types and add comment

* Move setExpressPaymentError to payment-methods store

* fix express payment methods not showing up

* Check if payment method is active from the state

* Add comments

* Remove commented out code in payment method data context

* Display an error in the check-payment-methods directly from data store

* Remove use-emit-response hook and move utils in event-emit/utils.ts

* Use correct action property to remove payment methods

* Fix formatting

* Only try to initialize payment methods when cart is done loading

* Add function to order payment methods from server

* Add payment methods in the correct order

* Prevent adding registered payment methods before cart is ready

* Ensure payment methods get removed from state when deregistered

* Reorder setting default payment methods to add customer methods first

* Get customer methods from store not context

* Remove error from payment-method state and associated selectors

* Remove use-payment-method-registration and update the payment method state to remove the duplicated registeredPaymentMethods

* Remove errorMessage from payment-methods store

* Rename customerPaymentMethods -> savedPaymentMethods

* Order payment methods when validating

* Refactor payment-methods.js

* Fix "Payment methods not set in editor" woocommerce/woocommerce-blocks#6655 bug

We never get to load the payment methods object in the editor mode
because there are no cart totals to load.

* Initialize payment methods when available payments are loaded

* Remove duplicate code

* Fix data store state mutation anti-pattern

A Redux rule is to never mutate the state in a reducer to avoid any unexpected results

* Set availablePaymentMethods to the paymentMethods object

Instead of its keys. We can get the keys using "Object.keys".

* Use the available ordered payment methods

The `getPaymentMethods` & `getExpressPaymentMethods` may include unordored
& unavailable payment methods.

* Get the correct value from the emit event response

Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
2022-09-28 13:45:42 +01:00
Luigi Teschio 3732363ba6 Add to the Product Button block the support for the Product Query block (https://github.com/woocommerce/woocommerce-blocks/pull/6948)
* Adds to the Product Image Block the support for the Product Query Block

Adds to the Product Image Block the support for the Product Query Block woocommerce/woocommerce-blocks#6911

* use shared config

* use shared config

* use shared config

* Add to the Product Button Block the support for the Product Query Block

* Add to the Product Image Block the support for the Product Query Block

* fix lint errors

* address feedback

* set grid view and font-size L as default
2022-09-28 10:54:38 +02:00
Lucio Giannotta 7125b08655 Bump version strings 2022-09-27 18:04:07 +02:00
github-actions[bot] 78b02ce741 Release: 8.6.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7228)
Co-authored-by: Daniel W. Robert <danielwrobert@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2022-09-27 17:56:29 +02:00
Seghir Nadir 0f57123095 Local pickup rates are always returned regardless of the shipping zone. (https://github.com/woocommerce/woocommerce-blocks/pull/7177)
* local pickup is always returned no matter the zone

* wrap filters in feature flags

* switch to experimental
2022-09-26 15:51:32 +01:00
Saad Tarhi 085242bbe9 Clean the top-level of the /build folder (https://github.com/woocommerce/woocommerce-blocks/pull/7047)
* Generate Inner Blocks' JSON files in a common folder

* Get the correct metadata path for the Inner Blocks

The Inner Blocks' metadata lives now in the `/build/inner-blocks`. But,
the function `get_block_metadata_path` was only looking for metadata
inside the top-level of the `build/` folder
2022-09-26 15:02:36 +01:00
Hsing-yu Flowers 04743add72 Check tax display type before returning the tax lines (https://github.com/woocommerce/woocommerce-blocks/pull/7084)
* Check tax display type before returning the tax lines

* Return early if not itemized
2022-09-23 16:33:12 -04:00
Lucio Giannotta d174051787 Refactor Product Query to use the latest Gutenberg APIs (https://github.com/woocommerce/woocommerce-blocks/pull/7169)
* Refactor Product Query to use the latest Gutenberg APIs

As we worked with Gutenberg folks in WordPress/gutenbergwoocommerce/woocommerce-blocks#43590,
WordPress/gutenbergwoocommerce/woocommerce-blocks#43632 and WordPress/gutenbergwoocommerce/woocommerce-blocks#44093 we have
created a standard API that could be used for our use-case. This
PR refactors our WIP experimental work to use that standardized API.
2022-09-23 15:07:44 +02:00
Seghir Nadir e0d968b310 use full link for WordPress resources (https://github.com/woocommerce/woocommerce-blocks/pull/7211)
Co-authored-by: Niels Lange <info@nielslange.de>
2022-09-23 18:02:05 +07:00
Seghir Nadir c52825ca7b switch to a permament link in errors (https://github.com/woocommerce/woocommerce-blocks/pull/7205) 2022-09-22 13:17:26 +01:00
Luigi Teschio 84432552a8 Product Query: Fix pagination issue (https://github.com/woocommerce/woocommerce-blocks/pull/7109) 2022-09-15 13:53:56 +02:00
Luigi 1f71891e2d Update version to 8.6.0-dev 2022-09-13 14:32:33 +02:00
github-actions[bot] 4ab8f9c768 Release: 8.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7110)
* Empty commit for release pull request

* add changelog - 8.5.0 version

* Add testing instructions

* add missing screenshot

* Fix pills in the Filter by Attribute block dropdown overlapping with the chevron (second attempt) (https://github.com/woocommerce/woocommerce-blocks/pull/7112)

* Fix invisible Reset filter button in some themes (https://github.com/woocommerce/woocommerce-blocks/pull/7111)

* update link zip file

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-09-13 14:29:51 +02:00
Lucio Giannotta 5dd05d7ab2 Improve public-facing texts and labels (https://github.com/woocommerce/woocommerce-blocks/pull/7045)
We noticed that oftentimes our labels and text tend to be overly
technical or unclear. We decided to do a bulk pass to improve
the readability to non-technical users.
2022-09-12 10:39:26 +02:00
Paulo Arromba 0631b04dbe Suppress unnecessary warnings for old namespace aliasing (https://github.com/woocommerce/woocommerce-blocks/pull/7046)
* Aliasing classes in deprecated.php now checks for prior alias declaration to suppress unnecessary warnings.
2022-09-07 13:55:15 +01:00
Luigi Teschio 2dcd9a954a Replace 'gutenberg_build_query_vars_from_query_block' filter with 'query_loop_block_query_vars' filter (https://github.com/woocommerce/woocommerce-blocks/pull/7078) 2022-09-07 14:05:01 +02:00
Tarun Vijwani 6294b0c227 Add steps to retrieve products variations in Store API docs (https://github.com/woocommerce/woocommerce-blocks/pull/7076) 2022-09-07 15:49:10 +05:30
Luigi Teschio 26327264c0 Add default value to parameter woocommerce/woocommerce-blocks#7060 (https://github.com/woocommerce/woocommerce-blocks/pull/7074)
add default value to  parameter
2022-09-06 16:23:15 +02:00
Alba Rincón 5e96759159 Fix php format (https://github.com/woocommerce/woocommerce-blocks/pull/7050) 2022-09-05 11:35:10 +02:00
github-actions[bot] db69fd92fc Release: 8.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/7001)
* Empty commit for release pull request

* Add the changelog to `readme.txt`

* Add testing instructions & release zip

* Fix video tags

* Update feedback document path

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-09-02 18:20:01 +01:00
Luigi Teschio 3ea46e426a Add to the Product Image block the support for the Product Query block (https://github.com/woocommerce/woocommerce-blocks/pull/6911)
* Adds to the Product Image Block the support for the Product Query Block

Adds to the Product Image Block the support for the Product Query Block woocommerce/woocommerce-blocks#6911

* Add to the Product Image Block the support for the Product Query Block

* address feedback

* set grid view and font-size L as default
2022-09-01 15:13:19 +02:00
Saad Tarhi ff48e7d45a Update version to 8.5.0-dev 2022-08-30 12:37:33 +01:00
Seghir Nadir 241350c0c9 only load shipping countries when shipping is needed (https://github.com/woocommerce/woocommerce-blocks/pull/6901) 2022-08-29 09:05:19 +01:00
Tarun Vijwani c0f6aec882 Change Type for shipping_address and billing_address to object (https://github.com/woocommerce/woocommerce-blocks/pull/6974)
* Change Type for shipping_address and billing_address to object

* Fix description
2022-08-29 07:29:50 +01:00
Lucio Giannotta 95963a7bab Fix Product Query block hijacking all Query blocks queries (https://github.com/woocommerce/woocommerce-blocks/pull/6952)
* Fix Product Query block hijacking all Query blocks queries

The Product Query block was adding a filter to Gutenberg's core
Query Loop block. When this filter was added once, it would from
then on apply to all other Query Loop blocks (or variations thereof)
on a page.

This change makes sure that:

1. No filters are added in the first place if our custom `__woocommerceVariationProps`
are not set.
2. The filter only gets run once.
2022-08-25 02:48:36 +02:00
Tomasz Tunik b295689571 Product search block as core/search variation (https://github.com/woocommerce/woocommerce-blocks/pull/6191)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2022-08-23 23:06:17 +07:00
Luigi Teschio ffbf5823d3 Product Query Block POC (Phase 1) (https://github.com/woocommerce/woocommerce-blocks/pull/6812)
* Move `EditorBlock` to general `type-defs`

`EditorBlock` was scoped under the `featured-items` directory at the time of its creation. It is, however, a useful type that should be shared repo-wide. For this reason, I am moving it into the `blocks` type-defs and updating all the references.

* Define types for the Product Query block

Also defines a more generic `WooCommerceBlockVariation` type which should be also useful in the future to implement a similar pattern.

* Add Product Query utils

Add two utility functions:

 1. `isWooQueryBlockVariation`: is used to check whether a given block is a variation of the core Query Loop block, and also one of the allowed variations within our repo. See: `QueryVariation` enum type.
2. `setCustomQueryAttribute`: is a shorthand to set an attribute within the variation query attribute.

* Refactor and cleanup the JS demo code

Specifically:

1. Creates a `constant.ts` file to store all shared constants. Currently, the default variation attributes.
2. Move the variations to their own directory. One file per variation.
3. Move the inspector controls into own file and create a conditional logic to allow showing only certain settings.

* Update webpack config

* Add ProductQuery class

* Fix `QueryVariation` enum

We had changed the Products on Sale variation slug to something else,
but we had forgotten to update the proper enum.

* Remove unused params from `update_query`

The filter we added to Gutenberg will pass the block and the page,
as we might need them in the future and we want to minimize the
amount of changes we'll have to do upstream.

However, we currently do not use those, so I removed
them from our own inner function.

Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
2022-08-18 10:02:21 +02:00
Tarun Vijwani 40ad67d9a1 Update version to 8.4.0-dev 2022-08-17 18:13:00 +05:30
github-actions[bot] d827e8176e Release: 8.3.1 (https://github.com/woocommerce/woocommerce-blocks/pull/6910)
* Add global styles to Product Categories List block in WC core (https://github.com/woocommerce/woocommerce-blocks/pull/6906)

* add side effect to package (https://github.com/woocommerce/woocommerce-blocks/pull/6904)

* Add _blank to terms link (https://github.com/woocommerce/woocommerce-blocks/pull/6908)

* Only show items if there are multiple packages in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/6899)

* Price Filter Block Design update (https://github.com/woocommerce/woocommerce-blocks/pull/6877)

* make toggle control full width

* add inlineInput attribute

* add inlineInput sidebar setting

* add inlineInput help text

* style the filter button

* style price input

* wip: reset button

* clicking on reset button will reset the price query

* support inline input fields

* price text styling update

* fix reset button font size

* add loading placeholder to all elements

* fix filter button style

* update range slider thumb and track style

* fix loading placeholder for non empty query

* move reset button into FilterSubmitButton component

* try: render placeholder serverside

* update filter button label

* Revert "try: render placeholder serverside"

This reverts commit 98f08efdb8048b8f78c7476b774d1128c1d31295.

* remove LoadingPlaceholder component

* remove Price: prefix from the current displayed price range

* update labels

* extract reset button as a dedicated component

* update price text section

* update reset button behavior

* avoid breaking filter submit button style for other filter blocks

* rename block to Filter by Price

* fix e2e test

* remove border support

* adjust padding for elments

* rename panel title

* Make the inline option enabled by default and fix frontend rendering

* Make the `Price Range Selector` uppercase

* Show `Reset` button only when a selection has been made

* Revert the `save` change to avoid the 'Block Recovery Prompt'

Co-authored-by: Alba Rincón <alba.rincon@automattic.com>

* Release: 8.3.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6897)

* Empty commit for release pull request

* Bump version numbers and add changelog

* Add testing notes

* Add global styles to Product Categories List block in WC core

* add side effect to package

* Update testing instructions

* Empty commit

* Fix linting

* Update zip file with latest changes

* Fix linting

* Update changelog entries

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>

* Update version to 8.4.0-dev

* Empty commit for release pull request

* Add change log

* Add testing instructions

* Fix the version number in testing instructions

* Bumping version strings to new version.

Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Tarun Vijwani <tarun.vijwani@automattic.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-17 17:32:49 +05:30
Tarun Vijwani fcde655ae5 Bumping version strings to new version. 2022-08-16 21:48:54 +05:30
Thomas Roberts 2285d1d4e2 Include Cart and Checkout Blocks when included in WC Core (https://github.com/woocommerce/woocommerce-blocks/pull/6805)
* Remove all inbox notifications about cart and checkout blocks

* Remove feature flag check from CreateAccount class

* Remove feature plugin check to register PaymentsApi class

* Comment out is_feature_plugin_build function

We might need this later, so keeping it around seems useful.

* Remove feature plugin check when adding resource hints

* Import registerBlockType and use it over registerFeaturePLuginBlockType

* Ensure Cart and Checkout inner blocks register even if not feature plugin

* Comment out registerFeaturePluginBlockType

* Remove duplicate import

* Revert "Comment out registerFeaturePluginBlockType"

This reverts commit bec6ed899b68e26e836bde1c573d6066fb2bcc47.

* Align PHPDoc correctly

* Update feature flag doc to remove Cart and Checkout blocks + PaymentApi
2022-08-15 11:15:15 +05:30
Alba Rincón 5bcabd0361 Register patterns under `patterns` folder and add filters pattern (https://github.com/woocommerce/woocommerce-blocks/pull/6861)
* POC about registering patterns

* POC load patterns from `/patterns` folder

* Change class name and remove unnecessary comment

* Add all four blocks to the filters pattern

* Add all 4 blocks to the block type to allow for transformations

* Add internal

* Improve filters name

* Extract regex to constants

* Add class description

* Rename and move class

* Fix wrong imports

* Address feedback

* Early return from condition

* Fix wrong block type
2022-08-12 13:09:37 +02:00
Tung Du 9253ba0eec Fix: Override the description to prevent infinite loop (https://github.com/woocommerce/woocommerce-blocks/pull/6849) 2022-08-09 16:28:35 +07:00
Daniel W. Robert 02ce62109e Add font-weight option to Mini Cart block text (https://github.com/woocommerce/woocommerce-blocks/pull/6760)
* Add font-weight option to Mini Cart button text.

Need to repeat steps for icon SVG and cart item count.

* Add font-weight controls to mini-cart item count.

* Add better error handling to PHP style output.

Ensure style value is set for style item in the
get_font_weight_class_and_style attributes array before rendering it to
the output.

* Revert font-weight option for quantity badge.

Per conversation with @vivialice, it looks better for now to keep the
font weight adjustment capabilities to just the price and leave the cart
icon and count as-is.

* Move $typography_styles variable into markup fn.

To resolve merge conflicts and get everything in it's proper place, this
commit will move the $typography_styles variable into the
get_cart_price_markup() function from woocommerce/woocommerce-blocks#6796.
2022-08-05 14:15:10 -04:00
Albert Juhé Lluveras d93bb44537 Update version to 8.3.0-dev 2022-08-02 17:24:34 +02:00
github-actions[bot] c8728fb2b5 Release: 8.2.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6806)
* Empty commit for release pull request

* Update 8.2.0 changelog

* Add 8.2.0 testing steps

* Fix typo in 8.2.0 testing steps

* Ensure package names display correctly if only one item is in package (https://github.com/woocommerce/woocommerce-blocks/pull/6815)

* Check package length >= 1 to show package name

* Check shipping rates length in order shipping packages slot

* Fix TS error where boolean value could be undefined

* Show items if there is more than one shipping rate

* Update 8.2.0 testing zip

* Bumping version strings to new version.

* Remove empty element from changelog

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-08-02 17:22:37 +02:00
Daniel W. Robert fef4d5e597 Add option to hide/show price in Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/6796)
* Add toggle control to sidebar in editor.

Adds a visibility toggle in the Mini Cart block's sidebar editor
settings for the block price.

* Update name of hasVisiblePrice attrubite.

Adjusts the name of the hasVisiblePrice attribute to hasHiddenPrice.
This seems a bit easier to reason about, where we can set the default
state of the visibility toggle to 'off'.

* Add conditional price rendering to server side.

Since this is a dynamic block, need to add the condidional attribute
state to the server-side render callback.

* Add price visibility setting to block frontend.

We need to prevent pricec from rendering when hidden setting is active
after the JS kicks in on the frontend (i.e., when the Mini Cart is
interacted with by the user).

* Fix logic error in frontend rendering conditional.

* Add unit tests for both show/hide price states.
2022-08-02 10:28:52 -04:00
Seghir Nadir 8e2a2636c2 fix proceed to checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/6804) 2022-08-01 16:29:28 +01:00
Saad Tarhi dc97e5af1e Fix missing translations in inspector (https://github.com/woocommerce/woocommerce-blocks/pull/6737)
* Try registering the "cart taxes" inner block

Registering server side. This example isn't working, but I'm pushing to
share it and see what's wrong with this implementation.

* Fix registering the cart taxes inner block issue

* Update translation script loading

* Remove unnecessary JS translation

The translation should work fine by getting the title & description from
the `block.json` file

* Put back the initial code in the 'Cart Taxes' inner block

We didn't provide the correct `block.json` file path server side,
that's why the `metadata` wasn't correctly registered

* Generate `block.json`files for inner blocks

This is the first step on fixing the missing translations of `metadata`
in `block.json` files

* Set the folder name exactly the same as the inner block name

We are doing this first test for the `Cart taxes` inner block.

The `Block` & its containing folder need to have the same name for:
- Consistency
- We use the `Block` name to get the file Path

* Update imports after folder renaming

* Get block name directly from the JSON metadata

Getting the block name from the JSON metadata is less error prone than
extracting it from the file path.

And no need to rename all our `inner-blocks` to get the correct
`block.json` path

* Revert folder naming change of `Cart taxes` inner block

Since we are getting the `block` name directly from the `block.json`
metadata instead of extracting it from the file path, there is no need
to keep their names in sync anymore

* Fix missing translations for the `Cart Subtotal` Block

* Register only the client-side settings on the client

When the block is registered on the server, you only need to register
the client-side settings on the client using the same block’s name.
See [docs](https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#javascript-client-side).

* Add schema validation to `block.json`

Development is improved by using a defined schema definition file.
Supported editors can provide help like tooltips, autocomplete, and
schema validation.

* Use the same `editor_script` as the parent block

This prevents WordPress from generating script tags to inexistant
inner blocks JS files

* Add C&C inner blocks in Cart.php & Checkout.php

This is a refactoring to keep the block types controller file less
overloaded

* Fix all Cart inner blocks missing translations

* Create the "AbstractInnerBlock" class

The "Inner Blocks" will use their parent's script, so no need to create
new scripts for each one of them

And, our "Inner Blocks" should always be registered using the metadata file

* Update the "Inner Blocks" PHP classes

* Fix PHP lint erros & update function description

* Fix missing translations bug for all Checkout Inner Blocks

* Update src/BlockTypes/Checkout.php

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>

* skip lazy loaded scripts

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-08-01 15:57:33 +01:00
Seghir Nadir 2ebb166b41 add new action for customer updates (https://github.com/woocommerce/woocommerce-blocks/pull/6792) 2022-08-01 09:56:28 +01:00
Thomas Roberts 82dd8c22db Add comment to prevent linting error on commented out code (https://github.com/woocommerce/woocommerce-blocks/pull/6789) 2022-07-29 04:54:52 -07:00
Alba Rincón ef13f65dc0 Use the archive-product template to render product attributes pages (https://github.com/woocommerce/woocommerce-blocks/pull/6776) 2022-07-28 12:49:13 +02:00
Tung Du c10e91e7e1 Fix: navigate through Mini Cart contents with keyboard (https://github.com/woocommerce/woocommerce-blocks/pull/6731)
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-07-25 12:39:47 +07:00
Tung Du 02a3d27de6 Fix: WooCommerce messages don't appear in block themes with Mini Cart block (https://github.com/woocommerce/woocommerce-blocks/pull/6728) 2022-07-22 00:05:52 +07:00
Luigi Teschio c1c2860232 Mini Cart Block: additional class are visible on the frontend page woocommerce/woocommerce-blocks#5581 (https://github.com/woocommerce/woocommerce-blocks/pull/6716)
Mini Cart Block: additional class are visible on the frontend page
2022-07-20 09:57:41 +02:00
Alba Rincón a4077d865c Bump version from 8.1.0 to 8.2.0-dev 2022-07-19 10:59:47 +02:00
github-actions[bot] 8ae71628a1 Release: 8.1.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6693)
* Empty commit for release pull request

* Update readme.txt

* Update versions

* Update WC versions

* Add testing notes and release zip file

* Update testing instructions

* Fix typo in testing instructions

* Remove fix from the testing instructions

* Update readme

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
2022-07-19 10:51:50 +02:00
Michael P. Pfeiffer 1784b525df Update block template descriptions (https://github.com/woocommerce/woocommerce-blocks/pull/6667) 2022-07-15 15:54:04 +02:00
Alba Rincón 5b50d37028 Prevent showing the blockified templates util they are implemented (https://github.com/woocommerce/woocommerce-blocks/pull/6682) 2022-07-14 14:54:25 +02:00
Paulo Arromba 678fa6bff0 Add: Cross-sells for the Store API Cart response. (https://github.com/woocommerce/woocommerce-blocks/pull/6635)
* Added Cross-sells object and schema for the API Cart response.

* Cross-sells are now WC_Product objects that pass through the visibility filter.

* Removed redundant check.

* Updated function doc comment.

* Cleaned up imports.

* Cross-sells item schema (extension of ProductSchema) was removed, and replaced by ProductSchema itself. Cross-sells are direct product representation, and extending this goes out of scope for the task at hand.

* Unit testing for cart response containing cross-sell products.
2022-07-13 15:02:49 +01:00
Luigi Teschio abf7b80576 Mini Cart: Fix loading deps when WordPress is installed in a subdir (https://github.com/woocommerce/woocommerce-blocks/pull/6673)
* Fix loading deps when WordPress is installed in a subdir woocommerce/woocommerce-blocks#6500

Fix loading deps when WordPress is installed in a subdir

* update logic
2022-07-13 12:42:28 +02:00
Tung Du 42453b7582 Fix: Add support to apply filters via URL for All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/6642)
* price-filter: update URL when filtering products of All Products block.

* active-filters: update the URL when removing price filter

* price-filter: prevent update query on PHP templates when changing prices

* active-filters: on PHP templates, remove filter only triggers the page reload

* price-filter: update comments and naming to reflect new URL behavior

* stock-filter: update url when filtering for All Products block

* attribute-filter: update the URL when filtering for All Products block

* attribute-filter: fix: uncheck all filter doesn't clear the URL

* attribute-filter: fix: endless page reload when filtering for PHP template

* attribute-filter: correctly set the defaults and update the filter query from URL

* fix: filter URL containing stock status doesn't work on homepage

* price-filter: fix issue with URL on All Products

The price slider doesn't reset after removing price filter from the Active Filters block if the initial price filter is set from URL

* ref: passing document.title to pushState is unnecessary

* use replaceState to avoid changing browser history

* extract change URL logic
2022-07-11 14:04:19 +07:00
Luigi Teschio 4aaaebe0c0 Disable render blockified Product Grid Block (https://github.com/woocommerce/woocommerce-blocks/pull/6660)
* Disable render blockified Product Grid Block

* try now
2022-07-06 14:16:32 +02:00
Alba Rincón 75184ae22d Add migration strategy and load blockified templates (https://github.com/woocommerce/woocommerce-blocks/pull/6538)
* Increase `schema_version` to add the new `wc_blocks_use_blockified_templates` flag

If the schema version stored on the db is <= 260 means the plugin is being updated
to the new version and we should keep using the old templates, not the blockified ones.

* After the theme is switched we check if we need to update the flag to
start loading the blockified templates or not.

* Get the templates from the blockified folder if the flag is set to true on the db

* Add temporary blockified template for testing purposes

* Inline variable

* Improve comment

* Use blockified templates on new installs with block themes only

* Don't use blockified templates when switching to a non FSE theme

* Fix condition

* Add tests for the option value

* Move the check to use blockified templates

* WIP

* WIP

* Add migration strategy

* Move the blockified templates to the templates folder and filter them depending on the option

* Fix tests and start using the Options constants

* Fix migration, the `should_use_blockified_product_grid_templates` and tests

* Rename tests and move to Utils folder

* add Migration class test

* try

* remove PHP

* add composer

* Replace the blockified templates with a temporary version

* Fix tests

* add comment

* Add feature gating for experimental builds

* Inject the package to the controller

* test

* Change blocks.ini

* debug

* Remove debug info

* fix test

* fix tests

* try now

* using composer cache

* install deps

* test

* Remove unnecessary extra key

* Add cache actions

* Undo tests change

* Fix readme format

Co-authored-by: Luigi <gigitux@gmail.com>
2022-07-06 09:51:39 +02:00
Niels Lange 073392c96a Bump version from 8.0.0 to 8.1.0-dev 2022-07-05 18:48:38 +02:00
github-actions[bot] 4e6da0b80d Release: 8.0.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6652)
* Empty commit for release pull request

* Empty commit for release pull request

* Update readme.txt

* Update phpcs.xml

* Add testing notes and ZIP for release 8.0.0

* Update testing notes

* Update testing notes

* Revert woocommerce/woocommerce-blocks#6591

* Update testing notes

* Update readme.txt

* Update ZIP for release 8.0.0

* Change version from 8.0.0-dev to 8.0.0

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2022-07-05 18:41:05 +02:00
Alba Rincón b5b454ad42 Fix condition to allow rendering classic templates (https://github.com/woocommerce/woocommerce-blocks/pull/6643) 2022-06-29 17:35:40 +02:00
Luigi Teschio e7eb8a6dd5 Show classic template in the inserter only for specific templates (https://github.com/woocommerce/woocommerce-blocks/pull/6539)
* Show classic template in the inserter only for specific templates

* add feature gate

* add todo comment

* rename variable

* address feedback

* not register block on post and page editor

* avoid casting
2022-06-29 09:42:02 +02:00
Seghir Nadir 6e9c348cc4 add custom local pick handling (https://github.com/woocommerce/woocommerce-blocks/pull/6631)
This PR fixes an issue in which taxes are calculated against the user address for local pickups orders. A niche issue, but an important one.
2022-06-27 15:52:24 +01:00
Ovidiu Liuta 9796af2fb4 changing tax_query field to term_id (https://github.com/woocommerce/woocommerce-blocks/pull/6585)
Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
2022-06-22 12:51:14 +02:00
Nadir Seghir e50b654d69 update version 2022-06-22 10:42:03 +01:00
github-actions[bot] da202ab1e0 Release: 7.9.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6604)
* Empty commit for release pull request

* update readme

* add testing notes

* update link

* Bumping version strings to new version.

* move testing docs

* remove old folder

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2022-06-22 10:40:03 +01:00
Luigi Teschio 15ee965e48 Fix crash when the user saves Mini Cart Template (https://github.com/woocommerce/woocommerce-blocks/pull/6613) 2022-06-21 18:30:26 +02:00
Tung Du aadb94c012 Fix: Display the correct title for templates from theme (https://github.com/woocommerce/woocommerce-blocks/pull/6452) 2022-06-21 22:26:09 +07:00
Daniel Dudzic 8f00447f2d Add descriptions for all WC templates and refactor Search template hierarchy loading logic (https://github.com/woocommerce/woocommerce-blocks/pull/6345)
* Refactor template title and description loading and search template hierarchy updating

* Remove an unnecessary return

* Fix template descriptions for custom templates

* Fix template description typos

* Move the template description loading logic to mirror the title's

* Remove the descriptions filter and move the search hierarchy code back to a separate file

* Restore the original order of the container registrations

* Restore the product search template slug

* Restore the Product Search Results slug as a constant

Co-authored-by: Luigi <gigitux@gmail.com>
2022-06-20 14:49:18 +01:00
Albert Juhé Lluveras fc956b7f48 Fix images hidden by default in Product grid blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6599) 2022-06-20 14:13:56 +02:00
Albert Juhé Lluveras b543fa2684 Replace instances of wp_is_block_theme() with wc_current_theme_is_fse_theme() (https://github.com/woocommerce/woocommerce-blocks/pull/6590) 2022-06-17 14:51:04 +02:00
Tomasz Tunik 0dfc1ad58b provide span wrapper for category list item name (https://github.com/woocommerce/woocommerce-blocks/pull/6574)
will enable adding text overflow of other effects that user might not want to interfere with the image element
2022-06-15 11:37:21 +02:00
Albert Juhé Lluveras 680ebba7cb Fix an endless loop when using product grid blocks inside product descriptions (https://github.com/woocommerce/woocommerce-blocks/pull/6471)
* Fix an endless loop when using product grid blocks inside product descriptions

* Add array_key_exists protection

* Typo in comment

* 👌IMPROVE: Improve comments - woocommerce/woocommerce-blocks#6416

Co-authored-by: Panos (Panagiotis) Synetos <panos.synetos@automattic.com>
2022-06-14 11:24:48 +03:00
Niels Lange 15a22db4f4 Update README.md 2022-06-13 14:37:05 +02:00
Niels Lange 3208da551b Improve the structure of the WooCommerce Blocks Handbook (https://github.com/woocommerce/woocommerce-blocks/pull/6429)
* Improve the structure of the WooCommerce Blocks Handbook

Co-authored-by: Rania Lang <rania.langouretou@automattic.com>
2022-06-09 17:52:19 +02:00
Niels Lange a748f533a8 Format Markdown files using wp-scripts (https://github.com/woocommerce/woocommerce-blocks/pull/6462)
* Format Markdown files using Prettier

* Format Markdown files using wp-scripts

* Adjust MD linting
2022-06-09 14:43:17 +02:00
Alex Florisca 295184a734 Change Checkout.md to correct mistake (https://github.com/woocommerce/woocommerce-blocks/pull/6541) 2022-06-09 13:18:25 +03:00
Thomas Roberts 0aa3bcd9cb Access correct property of package destination in Store API (https://github.com/woocommerce/woocommerce-blocks/pull/6470)
* Access correct property of package destination

* Check for address_1 first then address
2022-06-09 12:45:00 +03:00
Albert Juhé Lluveras d994f06803 Fix PHP notice in Mini Cart when prices included taxes (https://github.com/woocommerce/woocommerce-blocks/pull/6537) 2022-06-09 09:57:37 +02:00
Luigi Teschio 9a80ad3f6a bump version and update tested up value for WordPress and WooCommerce (https://github.com/woocommerce/woocommerce-blocks/pull/6534) 2022-06-07 15:58:18 +02:00
github-actions[bot] 7a05f8559d Release: 7.8.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6517)
* Empty commit for release pull request

* Add changelog for the 7.8.0 release

* Add testing notes for 7.8.0 release

* move legacy payment processing to its own class (https://github.com/woocommerce/woocommerce-blocks/pull/6519)

* update changelog and testing instructions after the cherry-pick

* add link

* Featured Item: Fix colors from default palette not being applied (https://github.com/woocommerce/woocommerce-blocks/pull/6525)

Gutenberg uses two different attributes for text colors:

* `style.color.text`, and
* `textColor`

However, the second one is used only when a color from the default
palette is selected AND the post is saved and reloaded.

With this fix we use the human readable string from the default palette
as a CSS variable.

Please note that while Gutenberg correctly assigns the appropriate CSS
class to render the right color, the problem is that if the color is
handled by a class, it can be overridden for example by themes.

See woocommerce/woocommerce-blocks#6492

* upload new zip

* update changelog

* Revert "Remove Combobox patch (https://github.com/woocommerce/woocommerce-blocks/pull/6465)" (https://github.com/woocommerce/woocommerce-blocks/pull/6531)

This reverts commit 4976afad58.

* upload new zip

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Luigi <gigitux@gmail.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2022-06-07 15:40:54 +02:00
Seghir Nadir 87a5e41e05 move legacy payment processing to its own class (https://github.com/woocommerce/woocommerce-blocks/pull/6519) 2022-06-06 13:44:52 +01:00
Tung Du fb84599f42 Fix: Use `register_block_type_from_metadata` function (https://github.com/woocommerce/woocommerce-blocks/pull/6511) 2022-06-03 10:10:08 +07:00
Tung Du 775e149ad7 Fix: All translations related to JS blocks are loaded even if the block is not used (https://github.com/woocommerce/woocommerce-blocks/pull/6478) 2022-05-30 23:00:40 +07:00
Daniel Dudzic b15050909e Mini Cart: Add font size and font family controls (https://github.com/woocommerce/woocommerce-blocks/pull/6396)
* Mini Cart: Add font size and family controls

* Remove redundant property from the path

* Add conditional check for isFeaturePluginBuild
2022-05-30 10:45:15 +02:00
Alba Rincón 7ab9cb214b Refactor: `Featured product` and `Featured category` classes (https://github.com/woocommerce/woocommerce-blocks/pull/6443)
* Add `Fixed/Repeated background` to the `Featured Category` block

* Reorganize `Featured Product` and `Feature Category` before unification

* Add new `FeaturedItem` class with the shared code for `Featured Product/Category`

* Remove space

* Small tweaks after review feedback
2022-05-30 09:08:53 +02:00
Seghir Nadir 3ff8440643 Respect low stock setting (https://github.com/woocommerce/woocommerce-blocks/pull/6444) 2022-05-27 20:55:46 +01:00
Daniel Dudzic 9488b9186d Post-release version bump to 7.8.0-dev 2022-05-26 11:08:20 +02:00
github-actions[bot] 7f32bc4c14 Release: 7.7.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6448)
* Empty commit for release pull request

* Add changelog for the 7.7.0 release

* Add testing notes for the 7.7.0 release

* Fix being able to remove Cart Totals block (https://github.com/woocommerce/woocommerce-blocks/pull/6449)

* Update .zip link for the 7.7.0 release

* Revert changes to webpack build output (https://github.com/woocommerce/woocommerce-blocks/pull/6456)

* revert changes to webpack file

* fix loading of chunks

* revert changes to assets api as well

* include chunks from other blocks

* bail early if there is no build folder

* check if current folder exist (https://github.com/woocommerce/woocommerce-blocks/pull/6460)

* Update the 7.7.0 release .zip file

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
Co-authored-by: Alex Florisca <alex.florisca@automattic.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2022-05-26 11:03:56 +02:00
Seghir Nadir f031f8f83a check if current folder exist (https://github.com/woocommerce/woocommerce-blocks/pull/6460) 2022-05-26 10:34:29 +02:00
Seghir Nadir d3c2f638fa Revert changes to webpack build output (https://github.com/woocommerce/woocommerce-blocks/pull/6456)
* revert changes to webpack file

* fix loading of chunks

* revert changes to assets api as well

* include chunks from other blocks

* bail early if there is no build folder
2022-05-25 16:59:51 +01:00
Alba Rincón 983a13c8bf Add `Fixed/Repeated background` to the `Featured Category` block (https://github.com/woocommerce/woocommerce-blocks/pull/6440)
* Add `Fixed/Repeated background` to the `Featured Category` block

* Reorganize `Featured Product` and `Feature Category` before unification

* Fix gradient overlay
2022-05-24 16:10:16 +02:00
Seghir Nadir 238ab01ab2 Refactor webpack splitting to fix missing translation (https://github.com/woocommerce/woocommerce-blocks/pull/6420)
* don't splitChunk frontend scripts

* simplfy output folders

* reduce minimum chunk size to 10kb

* add all inner blocks for loading

* better splitChunks

* update translation code

* wait for scripts

* try sleeping

* fix loading translation

* fix tests for mini cart

* simplfy po logic

* automate loading chunks

* rename webpack group file

* rename block.json path
2022-05-23 15:58:13 +01:00
Alba Rincón a18e44e1a7 Convert `Products by Attribute` to TS (https://github.com/woocommerce/woocommerce-blocks/pull/6418)
* Convert `Products by Attribute` block to TS

* Small tweaks after review

* Extract InspectorControls and EditMode into components

* Refactor: move the edit related code to the edit.jsx file

* Remove the `editMode` attribute and control the edit mode inside the edit component

* Remove edit mode

* Change `isEditing` depending on attributes are selected or not

* Improved interfaces/props after review

* Add enum allowed values to `attrOperator` and `orderby` on the `block.json`

* Move `withSpokenMessages` to wrap the whole Edit block
2022-05-23 10:45:54 +02:00
Alba Rincón eec68ed371 Convert `Handpicked Products` block to TS (https://github.com/woocommerce/woocommerce-blocks/pull/6417)
* Convert `Handpicked Products` block to TS

* Extract InspectorControls and EditMode into components

* Refactor edit and remove the `editMode` attribute

* Change `isEditing` default depending on products selected or not

* Improve interfaces/props after review

* Move withSpokenMessages to wrap the whole Edit block
2022-05-23 10:14:51 +02:00
Alba Rincón 3b86ff6b39 Fix padding for the Featured Product block (https://github.com/woocommerce/woocommerce-blocks/pull/6435) 2022-05-20 14:20:57 +02:00
Lucio Giannotta 7fcc561db1 Refactor Featured Category and Featured Product blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6406)
This PR creates a new directory called `featured-items` which includes both blocks.
All the shared code lives at the top level of that directory.

Individual blocks still have their own directories, with their `block.json` and all other relevant configuration.

All the functionalities have been refactored out into their own files, accepting configuration when relevant, but mostly de-duplicating all the code.

Styles have also been refactored using mixins and extends and they mostly live in one place.
2022-05-19 18:16:46 +02:00
Alba Rincón 22e6394d47 Implement `Fixed image` and `Repeated image` media controls for the `Featured Product` (https://github.com/woocommerce/woocommerce-blocks/pull/6344)
* Add `Fixed` and `Repeated` background controls to `Featured Product`

* Add `Repeated background` feature when the toggle is activated

* Extract `get_image_url` function

* Add the styles for rendering the repeated image on the frontend

* Add `hasParallax` and `isRepeated` to the `block.json` file

* Adjust styles

* Remove unused function, improve phpdoc

* Use alt and product name

Fix error rebasing master

* Hide alt if isRepeat is true

When isRepeated is true, the image is a background so it does not
make sense to have an alt attribute.

* Add `Fixed image` behaviour

* Remove unnecessary single quotes

* Remove duplicated const due to rebasing

* Fix focal point getting lost after enabling Fixed bg

* Fix duotone for fixed and repeated images

* Fix duotone for fixed and repeated images on the front end

* Don't allow alt if the image is a bg not an img element
2022-05-18 16:08:32 +02:00
Thomas Roberts 2bfc687093 Bump version numbers following release PR merge 2022-05-10 12:55:02 +01:00
github-actions[bot] 07b201664a Release: 7.6.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6388)
* Empty commit for release pull request

* Bump version numbers and add changelog

* Add testing notes

* Add correct list of blocks to 6302 notes

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
2022-05-10 12:50:11 +01:00
Thomas Roberts f3dc80c6f7 Bump version numbers to 7.7.0-dev 2022-05-10 09:54:22 +01:00
Tom Cafferkey fffe7903d7 Check asset_data_registry keys do not exist before adding them for PHP templates (https://github.com/woocommerce/woocommerce-blocks/pull/6384)
* Check key does not exists before adding it

* Use third param to check if duplicate key exists instead of condition
2022-05-09 11:50:22 +01:00
Daniel Dudzic 0b3acfad27 Add the product image control for all blocks utilizing GridContentControl (https://github.com/woocommerce/woocommerce-blocks/pull/6302) 2022-05-09 12:04:33 +02:00
Tung Du 26fbb3f569 Shop page: Remove the Template panel from the Setting Sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/6366) 2022-05-05 08:08:10 +07:00
Tung Du 217c822b76 Fix: Mini Cart block is not available from the Edit template screen (https://github.com/woocommerce/woocommerce-blocks/pull/6351)
* revert woocommerce/woocommerce-blocks#5653

* remove unused global variable

* fix class name
2022-05-05 07:41:35 +07:00
Daniel Dudzic cd8196fa5f Product Tag Cloud: Hide from Widgets screen in classic themes (https://github.com/woocommerce/woocommerce-blocks/pull/6327)
* Product Tag Cloud: Hide from Widgets screen in classic themes
* Fix code indentation
2022-05-04 16:57:25 +02:00
Tung Du 206672f27e Classic Template: set the default alignment to wide (https://github.com/woocommerce/woocommerce-blocks/pull/6356) 2022-05-04 18:02:42 +07:00
Alba Rincón bdfd1da4c5 Start using the `block.json` metadata file for the `Featured Category` block (https://github.com/woocommerce/woocommerce-blocks/pull/6300)
* Start using the `block.json` metadata file for the `Featured Category` block

* Get default attributes from the `block.json` file

* Remove unnecessary `get_block_metadata_defaults` function

* Add alt attribute to the block.json file

* Remove unused imports
2022-04-28 17:31:59 +02:00
Alba Rincón 0aac2c59ef Start using the `block.json` metadata file for the `Featured Product` block (https://github.com/woocommerce/woocommerce-blocks/pull/6296)
* Start using the `block.json` metadata file for the `Feature Product` block

* Get default attributes from the block.json file

* Add removed comment

* Remove unnecessary `get_block_metadata_defaults` function

* Add alt default to block.json
2022-04-28 17:04:56 +02:00
Alba Rincón 964f6e5965 Add new `alt` attribute to the `Featured Product` media settings (https://github.com/woocommerce/woocommerce-blocks/pull/6308)
* Add new `alt` attribute to Media Settings

Allow to define an alt text for the Feature Product block

* Simplify on change

* Improve alt description and use name instead of short description

Short description can contain html and images, so it's not adequate to use on the alt attribute
2022-04-28 16:28:22 +02:00
Alba Rincón ec73743d0f Add new `alt` attribute to the `Featured Category` media settings (https://github.com/woocommerce/woocommerce-blocks/pull/6341) 2022-04-28 16:28:09 +02:00
Tarun Vijwani 1d0acebfa9 Update to dev version: 7.6.0-dev (https://github.com/woocommerce/woocommerce-blocks/pull/6336)
* update to dev version: 7.6.0-dev
2022-04-27 17:54:51 +04:00
github-actions[bot] a0d7400432 Release: 7.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/6312)
* Release: 7.5.0
2022-04-27 17:19:21 +04:00