Commit Graph

1062 Commits

Author SHA1 Message Date
Albert Juhé Lluveras 831cf20a4d Remove unnecessary __experimentalDuotone instances (https://github.com/woocommerce/woocommerce-blocks/pull/8328) 2023-02-01 10:28:23 +01:00
Niels Lange dc283a0e0a Document how to add multiple items via batch request (https://github.com/woocommerce/woocommerce-blocks/pull/8266)
* Document how to add multiple items via batch request

* Remove “Add Items” section title

* Remove “data” part from JSON example payload
2023-01-30 11:26:07 +01:00
Patricia Hillebrandt 9563468dc1 Create Store Breadcrumbs Block (https://github.com/woocommerce/woocommerce-blocks/pull/8222)
* Initial structure for the breadcrumbs block

* ditch inline comment

* Fine-tune the store breadcrumbs

* Disable the breadcrumbs block for regular posts & pages

* Update the breadcrumbs block details.

* Add tests

* rely on sprintf to render the breadcrumb

* Ditch usesContext.

* Add a link to the breadcrumb editor preview

* Disable all pointer-events for the breadcrumb link in the editor preview

* Add the align attribute

* Use the Disabled component to prevent interactions and update the copy for the block description.
2023-01-27 18:31:13 +01:00
Paulo Arromba 729bec698c Fix for wrong shipping schema in checkout (https://github.com/woocommerce/woocommerce-blocks/pull/8291)
Co-authored-by: Niels Lange <info@nielslange.de>
2023-01-26 16:31:02 +07:00
Paulo Arromba d4806016c9 Fix/ Ensure variation data is populated with unspecified default attribute values (https://github.com/woocommerce/woocommerce-blocks/pull/8226)
* Fixes a bug where cart response only reflects variation data submitted and not full variation data with default values.

* Sort variation data by attribute alphabetically

* PHP unit test for checking variation data.
2023-01-25 13:03:44 +00:00
Mike Jolley 1f0253795a Checkout/Store API: Push valid changes selectively (https://github.com/woocommerce/woocommerce-blocks/pull/8030)
* support partial updates

* revised error ids to reference in validation class

* Validate before push

* Fix logic + TS

* Avoid need for PUT by delaying validation/sanitization

* $cart change was not needed

* Revert changes in schema - fix is handled at route level

* Put back wc_do_deprecated_action

* Extra validation is not needed

* No need to export isValidAddressKey - its not used anywhere

* No longer using RouteException in customer update route

* Fix setting shipping to billing with changes

* Update error ids

* Only validate posted props

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-01-24 14:52:59 +00:00
Alba Rincón b0f2198e35 Set inherit default to true only when is inserted in the archive product template (https://github.com/woocommerce/woocommerce-blocks/pull/8251) 2023-01-24 11:04:00 +01:00
Mike Jolley aedcd5ff2a Document filter usage (https://github.com/woocommerce/woocommerce-blocks/pull/8232)
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2023-01-23 17:05:39 +00:00
Seghir Nadir 637c1a735f Use cart item key instead of index in shipping items (https://github.com/woocommerce/woocommerce-blocks/pull/8199)
* use cart item key instead of index

* Update src/StoreApi/Schemas/V1/CartShippingRateSchema.php

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-01-23 15:45:10 +01:00
Daniel Dudzic da637b8b64 Product Price: Transition from using CSS margin to Global Styles (https://github.com/woocommerce/woocommerce-blocks/pull/8195)
* Product Price: Transition from using CSS margin to Global Styles

* Product Price: Re-add css margins for Product Price inside of the All Products block.

* Product Price: Change bottom margin to 1rem

* Product Price: Fix the margin typescript declaration.
2023-01-20 15:56:29 +01:00
Albert Juhé Lluveras eaad45eb8a Avoid changing the markup of all ratings when the Product Rating block is present in the page (https://github.com/woocommerce/woocommerce-blocks/pull/8247) 2023-01-20 14:44:01 +01:00
Tung Du 2eafec1044 Add a compatibility layer to keep extensions continue working with Blockified Archive Templates (https://github.com/woocommerce/woocommerce-blocks/pull/8172)
* wip: initial BlockTemplatesCompatibility class

* full support for archive template

* early return

* fix early return using wc conditional functions

* address code review

* remove_default_hooks is only called with inherited block

* refactor the data structure

* shorter hook name

* Move additional hooks to remove_default_hooks

* Update src/Templates/BlockTemplatesCompatibility.php

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>

* Add check that  is an array

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2023-01-20 12:44:02 +01:00
Alba Rincón fbd86f8762 Add Store Notices block (https://github.com/woocommerce/woocommerce-blocks/pull/8157)
* Block scaffolding

* Rename to store notices

* Register only in the site editor

* Update description

* Add woocommerce class

* Add tests

* Delete old test file

* Update notices message in the editor

* Remove customization

* Disable the block server side

* Fix TS error

* Add custom classes

* Reprashed test description

* Escape notices

* Remove unnecessary disabled component

* Only allow to insert the block once

* Improve class name

* Merge edit and block files

* Fix copy

* Simplify test case

* Remove align support

* Remove attributes

* Change editor markup

* Use the Notice component to display the notice placeholder on the editor

* Use sprintf to improve readability

* Inline component

* Remove styles and unregister scripts

* Use ordered placeholders

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

* Use info as the notices status

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

* Fix php lint error

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-18 13:40:30 +01:00
Alba Rincón 34c7fa95e1 Add Catalog Sorting filter block (https://github.com/woocommerce/woocommerce-blocks/pull/8122)
* WIP

* Render in editor and add styles

* Simplify select

* Undo change

* Update titles and description

* Wrapped text for translation

* Remove from products inner blocks

* Allow the block in the inserter

* Rename test file and add new tests for catalog-sorting block

* Register on the site editor only

* Fix tests

* Disable block server side

* Override the `enqueue_assets`

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

* Fix TS error

* Simplify edit

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

* Disable background color

* Add custom classes

* Remove alignment

* Inherit color and font properties

* Merge edit and block files

* Use sprintf to improve code readability

* Make fontsize small by default

* Add order placeholders and woocommerce class

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

* Fix floating issue

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

* Add woocommerce class

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

Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 16:20:10 +01:00
kmanijak d00a21fbaf [Blockifying Product Archive Templates] Add Results Count block (https://github.com/woocommerce/woocommerce-blocks/pull/8078)
* Init setup to add a new block Results Count

* Render  template part as a content of ResultsCount block

* Switch to template part rendering

* Rename the block to ProductResultsCount

* Fix typo in BlockTypesController

* Change the ProductResultsCount class name

* Remove Product Results Count block from Product Query template

* Improve the way Product Results Count is rendered in the editor

* Add  prefix to places that missed renaming from ResultsCount to ProductResultsCount

* Remove unnecessary frontend.tsx file for ProductResultsCount

* Make sure global styles are applied and respected by Product Results Count block

* Make sure the Product Results Count is available inly in Product Catalog template

* Add basic tests to Product Results Count

* Remove empty line in style file

* Fix TS issue in Product Results Count

* Fix typo

* Override the enqueue_assets method to prevent unnecessary enqueue and 404 error on the frontend

* Add necessary property to block's metadata

* Address code review feedback

* Update description

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

* Remove disabled component

* Improve test description

* Merge edit and block files

* Remove align support

* Remove background support

* Simplify edit component

* Improve readability with sprintf and add custom class

* Simplify test case

* Add styles and order placeholders

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

* Fix markup to match with the frontend

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

Co-authored-by: Alba Rincón <albarin@users.noreply.github.com>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Alba Rincón <alba.rincon@automattic.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
2023-01-17 16:19:42 +01:00
Luigi f1e79d6ca8 bump version to 9.5.0-dev 2023-01-17 15:10:39 +01:00
github-actions[bot] 67c4a4741f Release: 9.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/8198)
* Empty commit for release pull request

* update WooCommerce compatibility

* adding testing instructions

* add zip file testing for the release 9.4.0

* add gif to testing instructions

* remove add to cart testing instructions

* Correctly detect compatible express payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/8201)

* Remove unused action and type action

* Derive the incompatible payment methods with selector

Instead of adding the incompatiblePaymentMethods to the payment state.
Let's simply derive it using a selector to keep a minimal state.

* Check compatibility with express payments

* update testing instructions

* add new zip file for testing

* Refresh shipping cache when saving Local Pickup (https://github.com/woocommerce/woocommerce-blocks/pull/8203)

* invalidate cache on page load

* always flesh settings after save

* use correct prefix

* Account for local pickup rates before disabling shipping in editor (https://github.com/woocommerce/woocommerce-blocks/pull/8207)

* Account for local pickup rates before disabling

* check for local pickup before disabling shipping in editor

* 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: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2023-01-17 15:09:02 +01:00
Lucio Giannotta 26ae17ffa0 Products: Fix variable products add to cart (https://github.com/woocommerce/woocommerce-blocks/pull/8173)
Variable products would get added to cart via the button, even
when the button said “Select options” and contained a link.

This was because the button was automatically hydrated
through a CSS class.
2023-01-16 18:54:25 +01:00
Seghir Nadir f438ea8ba2 Refresh shipping cache when saving Local Pickup (https://github.com/woocommerce/woocommerce-blocks/pull/8203)
* invalidate cache on page load

* always flesh settings after save

* use correct prefix
2023-01-16 17:56:56 +01:00
Mike Jolley fcc9bacdc9 Prevent undefined variable notice on checkout (https://github.com/woocommerce/woocommerce-blocks/pull/8197) 2023-01-16 11:53:12 +01:00
Nadir Seghir 549358c65c Local Pickup: Change location modal to have store country as default country 2023-01-12 15:42:43 +01:00
Nadir Seghir 4338944681 ungate the ShippingController class 2023-01-12 15:42:43 +01:00
Mike Jolley d9fbaa5ec3 Force method/pickup in the checkout layout (https://github.com/woocommerce/woocommerce-blocks/pull/7910) 2023-01-12 15:42:43 +01:00
Seghir Nadir 7d9602253c Restrict Local Pickup Checkout block users only (https://github.com/woocommerce/woocommerce-blocks/pull/7893)
* limit page visiblity to Checkout block

* only enable pickup_locations if checkout block

* always register local pickup
2023-01-12 15:42:43 +01:00
Mike Jolley abaea4fff8 Fix up the missing details section for local pickup
Fixes woocommerce/woocommerce-blocks#7898
2023-01-12 15:42:04 +01:00
Seghir Nadir 3c824053d7 Show notice if merchant has legacy local pickup enabled alongside the new pickup (https://github.com/woocommerce/woocommerce-blocks/pull/7842)
* add notice when there are existing enabled legacy local pickups

* Fix PHP warning

* Link though to the settings page

* Fix setting save

* Enabling this will produce duplicate options at checkout.

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2023-01-12 15:42:04 +01:00
Mike Jolley f2318060e1 Local Pickup: handle some UI issues
Duplicate selector

Convert to sentence case

Swap location and name in rate
2023-01-12 15:42:04 +01:00
Mike Jolley 65bc740518 Block Checkout: Apply selected Local Pickup rate to entire order (all packages) (https://github.com/woocommerce/woocommerce-blocks/pull/7484)
* Avoid duplicates in selected shipping method display

* Correct types

* Render pickup locations - not rates

* Always show "from" when there are multiple packages

* Pickup must be available for all packages

* Derive locations from rates

* Improve code style/docs

* Packagecount

* Introduce woocommerce_store_api_cart_select_shipping_rate

* Update docblock
2023-01-12 15:40:15 +01:00
Mike Jolley c49426570d React Based Local Pickup Settings Screen (https://github.com/woocommerce/woocommerce-blocks/pull/7581)
* Move payment methods

* Setup entrypoints

* Sortable implementation

* Sortable

* Basic UI in place for settings

* Hydrate real settings

* Form updates values

* Styling and save button placement

* useSettings hook

* Prepare for save

* delete

* Add location button

* Remove className

* Conditional display of taxes

* Save via API

* Update general settings to designs

* Modal styles

* Style table

* Border colors and radius

* Added e2e tests

* use node 16

* Enqueue states in admin

* Use render from wordpress/element

* Missing handle style

* Enable translations

* Remove curried function

* Todo for inline settings

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-01-12 15:40:15 +01:00
Mike Jolley 3d0109f1dc Enhancement/pickup location editor improvements (https://github.com/woocommerce/woocommerce-blocks/pull/7446)
* Hide form step descriptions when empty unless block has focus

* Make editor style match frontend

* Add links to settings in sidebar

* update sample costs

* phpcs
2023-01-12 15:40:15 +01:00
Mike Jolley bc2a52b85d Local Pickup: merge packages into a single package 2023-01-12 15:40:15 +01:00
Mike Jolley 16fa7f7b85 Enhance and fix add button in Local Pickup admin UI 2023-01-12 15:39:41 +01:00
Mike Jolley 82e9155167 Rename collection to shipping to reflect the block purpose 2023-01-12 15:38:06 +01:00
Mike Jolley 87c51d822f Local Pickup: add support for addresses and base taxes on them
Break address into multiple pieces for pickup Break address into multiple pieces for pickup Break address into multiple pieces for pickup locations

Apply taxes based on location

Require locations

Customer location tax logic

Improved editing
2023-01-12 15:38:06 +01:00
Mike Jolley 586bc90f1b Shipping and collection method block package support (https://github.com/woocommerce/woocommerce-blocks/pull/7383)
* Shipment wordage

* Hide panel if collection is not available for an item

* Update selection when displayed

* Register a global local pickup method for the block based checkout (https://github.com/woocommerce/woocommerce-blocks/pull/7414)

* Register a blocks local pickup method globally

* Remove local pickup plucking from store api

* Multiple pickup locations

* Unused code

* Translate meta data

* Update UI to match zones table

* Description

* Handle new shipping method in client

* Improve location rendering

* Only split out pickup location methods

* Fix enabled toggle

* Show and hide shipping text in sidebar based on pickup

* No need for "from" when min and max are the same price

* Update sample data for the editor
2023-01-12 15:35:57 +01:00
Mike Jolley 23b175d246 Create Pickup Locations Block (https://github.com/woocommerce/woocommerce-blocks/pull/7316)
* prefersCollection controls shipping visibility

* Remove log

* Create skeleton pickup options block based on shipping methods

* Filter locations to local pickup methods

* Correct case of block name

* Location styling

* Pull pickup details from new core fields

* Fix linting warnings on new types

* Remove blocks_local_pickup check (this does not exist yet)

* Move enable_local_pickup_without_address so it works under all contexts

* Fix display of FREE when there are a mix of prices

* Remove undefined return value

* Update block descriptions

* fix message

* Correct case

Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com>
2023-01-12 15:35:57 +01:00
Nadir Seghir 9ee5b40186 Introduce shipping method toggle block 2023-01-12 15:34:44 +01:00
kmanijak c0f33efb1c Order blocks alphabetically in webpack-entries and BlockTypesController (https://github.com/woocommerce/woocommerce-blocks/pull/8109)
* Order blocks in webpack-entries alphabetically

* Order blocks in BlockTypesController.php alphabetically
2023-01-12 08:34:45 +01:00
Albert Juhé Lluveras 886786eee1 Use DAY_IN_SECONDS constant instead of calculating the value (https://github.com/woocommerce/woocommerce-blocks/pull/8156) 2023-01-11 17:11:41 +01:00
Thomas Roberts c3873f4950 Add example request and example payment data to Checkout docs (https://github.com/woocommerce/woocommerce-blocks/pull/8083) 2023-01-05 06:43:51 -08:00
Manish Menaria 3da812ea0b Bump version strings to 9.4.0-dev 2023-01-04 16:34:26 +05:30
github-actions[bot] 6c379258e6 Release: 9.3.0 (https://github.com/woocommerce/woocommerce-blocks/pull/8072)
* Empty commit for release pull request

* Add changelog

* Add testing notes

* Fix a typo

* load all JSON translation files correctly (https://github.com/woocommerce/woocommerce-blocks/pull/8034)

Co-authored-by: Saad Tarhi <saad.trh@gmail.com>

* Disable Rate Limiting when editing Blocks in admin (https://github.com/woocommerce/woocommerce-blocks/pull/7934)

* Disable Rate Limiting for users who can edit posts

To avoid limiting the number of edits in WP admin to our Woo Blocks, we
need to disable rate limiting altogether.

We simply disabled rate limiting for users who can edit posts!

* Refactor rate limiting code

* Fix disabled rate limiting bug for non admin users

* Refactored applying rate limiting code.

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>

* Update woocommerce-gutenberg-products-block.zip

* Update ZIP file

* Add screenshots to testing notes

* Fix markdown linting issues

* Bumping version strings to new version.

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-01-04 15:24:54 +05:30
Seghir Nadir 156737d9b7 load all JSON translation files correctly (https://github.com/woocommerce/woocommerce-blocks/pull/8034)
Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2023-01-02 16:21:47 +01:00
Saad Tarhi a22465796b Disable Rate Limiting when editing Blocks in admin (https://github.com/woocommerce/woocommerce-blocks/pull/7934)
* Disable Rate Limiting for users who can edit posts

To avoid limiting the number of edits in WP admin to our Woo Blocks, we
need to disable rate limiting altogether.

We simply disabled rate limiting for users who can edit posts!

* Refactor rate limiting code

* Fix disabled rate limiting bug for non admin users

* Refactored applying rate limiting code.

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-01-02 14:49:12 +01:00
Stian 056e9bf73f Replace instances of wp_is_block_theme() with wc_current_theme_is_fse_theme() (https://github.com/woocommerce/woocommerce-blocks/pull/7496) 2022-12-29 13:14:00 +01:00
Rodrigo Primo 077c8fa3ff PHP 8.2: fix "Using ${var} in strings is deprecated, use {$var} instead" (https://github.com/woocommerce/woocommerce-blocks/pull/7782)
PHP 8.2 deprecated using ${var} in strings
(https://kinsta.com/blog/php-8-2/#deprecate--string-interpolation). {$var}
should be used instead. This commit fixes the occurrences of ${var} in
woocommerce-blocks to prepare for the next version of PHP which is
scheduled to be released early in December.

I found this in the context of testing MailPoet with PHP 8.2. I'm not
familiar with the woocommerce-blocks so I might be missing something. I did
not test the changes in this commit.
2022-12-29 13:13:15 +01:00
kmanijak 1bb1ad5f40 Display "Add review" link if there's no product rating (https://github.com/woocommerce/woocommerce-blocks/pull/7929)
* Display Add Review link in the All Products if there's no product rating in All Products and Products

* Apply the font-size mixin to the Add Review link

* Make Add review link NOT clickable in editor

* Improve styles of Rating component so they support alignment in product grids
2022-12-28 14:24:43 +01:00
Paulo Arromba 586e8ea884 Fix dev version strings (https://github.com/woocommerce/woocommerce-blocks/pull/8038) 2022-12-27 15:51:00 +00:00
Niels Lange 46f0330a0a Use Woo Blocks instead Woo core translation within the Checkout order Summary block (https://github.com/woocommerce/woocommerce-blocks/pull/7995)
* Use Woo Blocks instead Woo core translation

* Activale previously skipped e2e tests

* Adjust loading order of $shared_chunks, $vendor_chunks and $chunks

* Revert chunk order of MiniCart.php
2022-12-23 19:54:04 +07:00
Alba Rincón f9dd42a36a Add `Customer account` to patterns (https://github.com/woocommerce/woocommerce-blocks/pull/7944)
* Render the block in the frontend

* 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

* Add link to account settings

* Split css file

* Switch to SSR

* Add customer account block to header patterns

* Add customer account block to footer patterns

* Adapt minimal header to designs

* Adapt large header to designs

* Adapt header patterns to new designs and format code

* Adapt footer patterns to the designs

* Change display style for the essential header

* Increase alt icon size

* Make the icon resize with the label

* Adjust icon size on headers

* Add padding and move second row to the right

* Remove unused enum

Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
2022-12-23 10:08:44 +01:00
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