Commit Graph

62193 Commits

Author SHA1 Message Date
Tom Cafferkey 99fc85ae15
Block Hooks API: Add Tazza theme to the list of allowed themes for Mini Cart auto-insertion (#42900)
Co-authored-by: github-actions <github-actions@github.com>
2023-12-21 08:08:54 +00:00
Manish Menaria ba4f3d4d29
Add price range filter to Product Collection block (#42858)
* Add price range filter to Product Collection block

This update introduces a price range filter feature to Product Collection. Changes include:

1. Constants Update:
   - Added `priceRange` as undefined in `DEFAULT_QUERY` and `DEFAULT_FILTERS` in `constants.ts`.

2. Style Adjustments:
   - Added CSS for `.wc-block-product-price-range-control` in `editor.scss` to align the input text to the end.

3. Component Integration:
   - In `inspector-controls/index.tsx`, the `PriceRangeControl` component is now imported and integrated.

4. New Components:
   - `PriceTextField.tsx` and `PriceRangeControl/index.tsx` have been created to handle price range inputs in the Product Collection block.

5. Backend Integration:
   - `PriceRange` interface added in `types.ts` for type support.
   - In `ProductCollection.php`, a filter (`add_price_range_filter`) is added to modify the main query based on the price range, including adjustments for tax considerations.

Overall, this enhancement allows users to filter products within a specific price range. The backend adjustments ensure that the filtering respects tax settings and displays accurate prices.

* Fix formatting

* Fix: Price range filter not working on Editor

* Improve: Share logic between Frontend & Editor

* Add changelog

* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce

* Remove duplicate changelog file

* Enhanced Input Control for Price Fields

Key changes include:

1. **Switch to Input Control**: Replaced the NumberControl component with the more versatile InputControl. This offers better handling of currency formatting and user input.

2. **Currency Formatting Logic**: Added robust logic for formatting numbers according to the currency settings. This includes handling thousand separators, decimal places, and currency symbols.

3. **String-to-Number Conversion**: Implemented a function to convert user-entered strings back to numbers, accounting for currency symbols and separators. This ensures accurate parsing of user input for processing.

4. **Input Handling Improvements**: Modified the onChange handlers for minimum and maximum price inputs. Now, they correctly handle edge cases like undefined or zero values, maintaining consistency in the user interface and data processing.

* Refactor price range query handling

1. Introduction of a new method `get_price_range_query_args()` to encapsulate the logic for handling price range queries, especially for the two edge cases:
   - Prices excluding tax displayed including tax.
   - Prices including tax displayed excluding tax.

2. Removal of direct conditionals in the `get_query_results()` method, replacing them with a call to the new `get_price_range_query_args()` method. This makes the code more modular and easier to understand.

This refactor enhances readability and maintainability of the code, ensuring that special cases in price range filtering are handled more effectively.

* Remove unnecessary suffix prop

* Refactor PriceTextField formatting logic for currency

1. Conditional application of thousand separators: The code now checks for the existence of `currency.thousandSeparator` before applying it. This prevents potential errors when the separator is undefined.

2. Simplified decimal separator handling: Introduced a fallback for the decimal separator, defaulting to a period ('.') if not specified by the currency settings.

3. Enhanced readability and documentation: Added comments to clarify the purpose of code blocks, especially where currency symbols are added or removed, and where value normalization occurs.

4. Function renaming for clarity: Renamed `formatValueWithCurrencySymbol` to `formatCurrency`, which better reflects its purpose.

* Fix onBlur issue with PriceTextField component

Refactored the PriceTextField component to utilize useState for better state management. This change introduces a local state variable, 'newValue', to store the current value. The state updates occur in the handleOnChange function, ensuring that the component's state is managed efficiently. Additionally, a new function, handleOnBlur, is implemented to handle the onBlur event, updating the component's state when focus is lost. The handleEnterKeyPress function captures the 'Enter' key press, providing a more user-friendly experience by allowing users to confirm their input with the Enter key.

* Fix linting error

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-21 12:45:20 +05:30
Niels Lange 49d6b2058a
Link cross-sells product image to product page (#42904)
* Link cross-sells product image to product page

* Add changelog entry

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-12-21 11:13:47 +07:00
Justin Palmer cb0c42180a
Revise excluded order statuses for order attribution customer history (#42999)
* Better align excluded order statuses with WC Reports

* Update Tracks data to match updated customer order history count

* Add changelog

* Clarify code comment

* Exclude `checkout-draft` for block checkout/API orders.

* Remove unecessary array_map

Co-authored-by: Bartosz Budzanowski <bartosz.budzanowski@automattic.com>

* Use existing method to get un-prefixed order statuses

---------

Co-authored-by: Bartosz Budzanowski <bartosz.budzanowski@automattic.com>
2023-12-21 00:06:30 +01:00
Simran Vijwani 8e351f2f15
Add UTM group to product URL on the Discover page (#41967)
* Add utm_category to discover page

* Fix product category URL params

* Add changefile(s) from automation for the following project(s): woocommerce

* Update productCategory to productGroup in Discover and NoResults components

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: Simran <simran.kaur@automattic.com>
Co-authored-by: github-actions <github-actions@github.com>
2023-12-21 02:13:52 +04:00
Dekadinious d8e01b23cd
Update documentation in class-wc-order-item-product.php (#41160)
* Update class-wc-order-item-product.php

* Changelog.

* Fix alignment.

---------

Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com>
2023-12-20 13:52:00 -08:00
Leif Singer 06dc19ebd4
Ensure the gateway activation email does not depend on the gateway title being stored in the settings option (#42992)
* use `method_title` for the email to the admin as that is better suited for an admin context

* do not require the title to be set in the updated option

* add the changelog file

* adjust the test, too

* appease the linter
2023-12-20 13:44:30 -08:00
Ilyas Foo 4a5373409b
Fix shipping cost formatting to respect shipping formula (#42916) 2023-12-21 10:25:43 +13:00
Kathy 4d7bf10c96
Use product-sale-price ID for hooks. Closes #42907. (#42908)
* Use product-sale-price ID for hooks. Closes #42907.

* attempt to add a changelog
2023-12-20 17:44:32 -03:00
Damián Suárez e1e1d3c593
[Product Block Editor]: add `product-linked` feature flag (#43006)
* Add product-linked feature flag

* cchangelog

* enable product-linked flag in dev for now

* set product-linked unavailable in prod
2023-12-20 16:41:00 -03:00
Daniel Dudzic 7122669d44
Product Gallery: Simplify the Product Gallery Pop-up (#42797)
* Product Gallery Pop-up: Simplify the pop-up for v1

* Product Gallery Pop-up: Update the Product Gallery template part contents

* Product Gallery Pop-up: Add changelog entry

* Product Gallery: Fix CSS linting errors

* Product Gallery Pop-up: Add an additional changelog entry

* Product Gallery Pop-up: Update changelog message

* Product Gallery Pop-up: Fix logic error
2023-12-20 19:03:01 +01:00
Tom Cafferkey 0ba8f7848d
Block Hooks API: Add Amulet theme to the list of allowed themes for Mini Cart auto-insertion (#42899)
Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 15:26:21 +00:00
Nathan Silveira 0dac985d8e
Prepare @woocommerce/product-editor for 1.2.0 release (#42991)
* Prepare @woocommerce/product-editor for 1.2.0 release

* Fix typo
2023-12-20 11:46:12 -03:00
Luigi Teschio e45089eab3
CYS - select the right font with AI offline (#42973)
* CYS - select the right font with AI offline

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 15:41:19 +01:00
Luigi Teschio 24d0fed8e5
CYS - reset products and pattern when the site doesn't have AI generated content (#42970)
* CYS - reset products and pattern when the site doesn't have AI generated content

* Add changefile(s) from automation for the following project(s): woocommerce

* fix lint

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 15:41:04 +01:00
Niels Lange 2f2e573f48
Fix notice styles (#42692)
* Fix notice styles

* Adjust failing e2e test
2023-12-20 08:29:43 -06:00
Brian Borman df1f5d9e45
Check store api draft order on short code for reserved stock (#42796) 2023-12-20 06:18:47 -08:00
Tom Cafferkey 95c34a430d
Block Hooks API: Add Thriving Artist theme to the list of allowed themes for Mini Cart auto-insertion (#42910)
Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 13:42:38 +00:00
Nathan Silveira 8a07e61db5
Expose Taxonomy and TaxonomyMetadata types (#42962)
* Expose Taxonomy and TaxonomyMetadata types

* Apply suggestions from code review

Co-authored-by: Damián Suárez <rdsuarez@gmail.com>

---------

Co-authored-by: Damián Suárez <rdsuarez@gmail.com>
2023-12-20 10:06:34 -03:00
Karol Manijak 4fec136da1
Trigger event `experimental__woocommerce_blocks-cart-add-item` in the SSR Product Button vis Interactivity API (#42946)
* Trigger event experimental__woocommerce_blocks-cart-add-item in the SSR Product Button vis Interactivity API

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Update code comment and add reference to the followup issue

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 13:50:43 +01:00
berislav grgičak 8d6621ece1
Remove install support for Woo.com hosted products (#42952)
* Installer url API

* Redirect if installer not available

* Remove paid product autoinstall support

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 12:52:51 +01:00
Néstor Soriano df17713dea
Add logging and an admin notice for Legacy REST API usages (#41804)
* Add logging and admin noticing for rest api usages

Two new settings are added (UI in the Legacy API settings page):

- woocommerce_legacy_api_log_enabled
- woocommerce_legacy_api_usage_notice_enabled

When any of the two are enabled, legacy API usages are stored
in two options, 'wc_legacy_rest_usages' and 'wc_legacy_rest_last_usage'.

'wc_legacy_rest_usages' is a dictionary keyed by user agent,
each entry is in turn a dictionary keyed by request route,
items are arrays containing first and last usage dates as well
as total usages count (API version is logged too but for simplicity
it's not used to key the data).

'wc_legacy_rest_last_usage' contains the entry for the last usage,
regardless of user agent and route. It's used to display the notice.

When 'woocommerce_legacy_api_usage_notice_enabled' is enabled,
and the 'wc_legacy_rest_last_usage' option exists, an admin notice
displaying its contents is shown.

* Add changelog file

* Linting fixes

* Fix unit test

* Simplify the approach to logging/noticing:

- Remove settings
- Use a transient instead of an option for temporary data
- Store temporary data by user agent but not by route
- Make the admin notice dismissable
- Don't log now show the notice if the legacy REST API extension
  is installed and active
- Add a filter to explicitly disable the logging

* Small fixes, including a missing "exit" after request processing

* Apply suggestions from code review

Co-authored-by: Jorge A. Torres <jorge.torres@automattic.com>

* Fix linting issues

* Update the warning text under the "Enable legacy REST API" setting

* Change the rules to display the notice.

Now it won't appear if the transient isn't available
or if the Legacy REST API is disabled (or if the Legacy REST API
extension is active, as before); but if the user hasn't
explicitly dismissed the notice it will appear again if the transient
is recreated or the Legacy REST API is enabled again.

---------

Co-authored-by: Jorge A. Torres <jorge.torres@automattic.com>
2023-12-20 11:34:31 +00:00
Justin Palmer 8853c93aca
Tweak Order Attribution meta data and Tracks data (#42937)
* Add the source type / origin of "Web admin" for orders created in admin

* Include "Web admin" in values for Order information metabox

* Include "Web admin" value for the Order information metabox

* Use the Order Origin meta value in the Origin column of the Orders table

* Add web admin and direct as origin values, and a flag for un/translated

* Use the untranslated origin_label value in Tracks

* Don't store the origin label in the database to allow better l10n

* Lowercase origin label in Tracks

* Empty label and Direct or Web admin as source for orders table column

* Better Tracks customer order count and include customer status

* Add changelog

* Update test to expect Unknown

* Remove short ternary

* Change OA meta box title to Order Attribution

* Use native order method `get_total_refunded`

* Simplify origin labels - use the same value for Orders Edit and table

* Correct imprecise doc comment.

* Improve customer order count and total spend calculation

* Make default label "Unknown" (for pre-OA orders, for example)

* Update tests to match new labels
2023-12-20 12:28:19 +01:00
Kyle Nel 58138e0036
Hide In-app marketplace feature flag UI (#42951)
* Hide Marketplace feature toggle UI
* Ensure marketplace feature is active in DB on all sites

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 12:44:22 +02:00
Alba Rincón 8484520231
CYS > Update copy to remove the duplicate "try to include" (#42960)
* Remove duplicated text

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 10:39:09 +01:00
Thomas Roberts 7768ef5b5c
Prevent "Use same address for billing" being checked by default if addresses differ (#42967)
* Don't access the keys of what is now just an array

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-20 14:47:59 +07:00
Matt Sherman 0b315380ed
Skip BlockRegistry tests for now until we can figure out why they are flaky (#42977) 2023-12-19 22:51:50 -05:00
Kathy 7cbf7a3442
Cart: Force calculate totals when ordering again (#42921)
Ensure cart totals are correctly calculated when using "Order again".

Fixes #42889
2023-12-19 16:58:41 -08:00
Barry Hughes d033a40b26
Tweak create-product-attribute spec (#42854)
* Adds missing aria-label and tabindex HTML attributes to the Help tip element for "Product data" on "Add new product" page.

* Escape HTML tags

* Added changelog

* Update comment

* Amend method for selecting "New attribute" placeholder.

* Restore use of `getByRole()` and select first instance (two are being matched, in some cases).

* Use last match (in some test runs, `getByRole()` is unexpectedly matching more than 1 heading.

---------

Co-authored-by: Sagar Tamang <mi5t4n@gmail.com>
2023-12-19 16:35:20 -08:00
Luigi Teschio 310de4cc9f
Docs: Compatibility Layer - update documentation about `woocommerce_single_product_summary` (#42862)
* docs: Compatibility Layer - update documentation about woocommerce_single_product_summary

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-19 23:18:24 +01:00
Nathan Silveira ddd877441c
Add useProductMetadata hook (#42961)
* Add useProductMetadata hook to perform update in multiple meta entries at same time

* Update type to string

* Add test

* Remove unused parameters
2023-12-19 17:17:08 -03:00
Paul Sealock b04c45ee5e
Shipping Settings: Highlight text on focus of cost input values (#42689) 2023-12-20 08:22:17 +13:00
Nathan Silveira f83a2a8ae8
Add step prop to NumberControl (#42928)
* Add step prop to NumberControl

* Add step to block attributes as well

* Add documentation
2023-12-19 15:43:36 -03:00
louwie17 a72f3ee7a2
Add grouped and external products to new experiment (#42934) 2023-12-19 14:21:05 -04:00
Damián Suárez 5d20ab5ffa
[Product Block Editor]: expose Label component (#42959)
* expose Label component

* changelog
2023-12-19 15:16:50 -03:00
Nathan Silveira 1cf4b20fdd
Support HTML in checkbox-control tooltip (#42926)
* Support HTML in checkbox-control tooltip

* Add HTML support for tooltip in label
2023-12-19 14:44:42 -03:00
Damián Suárez 3faedf24d9
[Product Block Editor]: add story for Label component (#42953)
* [Product Block Editor]: add story for Label component

* changelog

* add simple Label story

* add Product Editor pkg to Storybook app:
2023-12-19 13:09:30 -03:00
Albert Juhé Lluveras 06e5b43d52
Reviews by Product block: fix encoded in input aria-label (#42944)
* Reviews by Product block: fix encoded in input aria-label

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-19 13:05:18 +01:00
Mike Jolley fe37bf8ddb
Remove duplicate cookie headers from the response (#42828)
Co-authored-by: github-actions <github-actions@github.com>
2023-12-19 03:10:52 -08:00
Tom Cafferkey 73e696f467
Block Hooks API: Add Zaino theme to the list of allowed themes for Mini Cart auto-insertion (#42912)
Co-authored-by: github-actions <github-actions@github.com>
2023-12-19 11:06:35 +00:00
Seghir Nadir d63dd1ed49
Allow passing partial data to Store API extensions field. (#42790)
* Make extended fields optional in Store API

* add tests

* add changelog

* update logic in validate function

---------

Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
2023-12-19 12:04:11 +01:00
Paul Sealock 23f44c0484
Shipping Settings: revert refresh styles (#42738) 2023-12-19 23:42:21 +13:00
Tung Du c651b10b3d
Add: Active Filters block powered by Interactivity API (#42008)
* add: active filters block

* update text domain

* chore: linting

* use template string instead of concat

* add experimental flag to register block type calls

* chore: update comments

* feat: register active rating filter data

* fix: unique navigation id when collection filters are added outside product collection

* fix: active filter rating id

* fix: return the href

* chore: phpcs
2023-12-19 17:29:33 +07:00
Jorge A. Torres 1965dfb63e
Add CLI tool to remove order data from legacy tables (#42848)
* Introduce `LegacyDataHandler` for handling legacy orders in the HPOS datastore

* Add methods to count and obtain orders subject to cleanup

* First pass at metadata cleanup for orders

* Add unit tests

* Implement `wc hpos cleanup` CLI tool

* Make PHPCS happy

* Add changelog

* Change error to warning

* Improve tests

* Fix unit tests

* Allow cleaning up of placeholders with meta

* Add support for `--force` flag

* Update plugins/woocommerce/changelog/enhancement-41914

Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>

* Update plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php

Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>

* Update plugins/woocommerce/src/Database/Migrations/CustomOrderTable/CLIRunner.php

Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>

* Exclude auto-draft

---------

Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
2023-12-19 09:32:55 +00:00
Tom Cafferkey bd6a8d365a
Block Hooks API: Add Tsubaki theme to the list of allowed themes for Mini Cart auto-insertion (#42911)
Co-authored-by: github-actions <github-actions@github.com>
2023-12-19 08:59:13 +00:00
Bartosz Budzanowski 1c4d373c84
Fix Order Attribution device type in tracks. (#42814)
* Fix Order Attribution device type in tracks.

* Add changelog.

* Fix indentation.

* Remove wrong comment.

* Update plugins/woocommerce/changelog/fix-order-attribution-device-type-in-tracks

Co-authored-by: Justin Palmer <228780+layoutd@users.noreply.github.com>

* Update plugins/woocommerce/src/Internal/Admin/Orders/MetaBoxes/OrderAttribution.php

Co-authored-by: Justin Palmer <228780+layoutd@users.noreply.github.com>

* Remove trailing whitespace.

---------

Co-authored-by: Justin Palmer <228780+layoutd@users.noreply.github.com>
2023-12-19 09:18:19 +01:00
Tarun Vijwani 82a6611144
Move the switch to classic shortcode block button to separate component (#42724)
* Move the switch to classic shortcode block button to separate component

- Move modal component file from incompatible-extension-notice component folder to switch-to-classic-shortcode-button folder.
- Rename modal component file to model-content component file.
- Move the switch to classic shortcode block button to separate component folder

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Update class names in switch-to-classic-shortcode-button component

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Update plugins/woocommerce-blocks/assets/js/editor-components/switch-to-classic-shortcode-button/editor.scss

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

* Refactor SwitchToClassicShortcodeButton component

* Fix css lint erros

---------

Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
2023-12-19 11:44:09 +04:00
Paul Sealock 055b1429fe
Admin.scss: Provide image-mask for Chrome (#42853)
* add mask-image

* Add changefile(s) from automation for the following project(s): woocommerce

---------

Co-authored-by: github-actions <github-actions@github.com>
2023-12-19 16:44:57 +13:00
Corey McKrill 7ff0e47690
Navigation: Change error_log call to doing_it_wrong (#42890)
Avoids printing an error log message in the middle of phpunit output.

Co-authored-by: Leif Singer <leif@automattic.com>
2023-12-18 14:26:38 -08:00
Alejandro López Ariza 057df162dc
Bump pnpm version in the release-code-freeze.yml workflow to fix issue that impeded the creation of new WooCommerce zip packages. (#42919)
* Bump pnpm version in the release-code-freeze.yml workflow to fix issue that impeded the creation of new WooCommerce zip packages.

* Update code freeze workflow to automatically get the pnpm version from the root package.json file.

* Improve reusability of the method to retrieve the pnpm version in the Code Freeze workflow.
2023-12-18 15:39:45 -06:00