* Add animation for client-side pagination
This includes:
- Addition of animation state management in the frontend file to control the visual transition between pagination states.
- Introduction of new SCSS rules for the start and finish animations, ensuring a seamless and visually appealing pagination experience.
- Modification of the PHP logic to inject necessary HTML for the animation to be applied.
These updates aim to provide a more engaging and responsive interface for users navigating through product collection.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Allow user clicks under product collection's loading animation
This commit enhances the user experience of the loading animation for the product collection block. Changes include:
- Specifying `transform-origin: 0% 0%;` directly within the block's initial style to indicate the animation should start from the left
- Adding `pointer-events: none;` to allow user interactions with elements underneath the loading animation, thus improving usability by not blocking clicks.
Additionally, redundant `transform-origin` properties were removed from the `@keyframes` declaration to clean up the code and avoid unnecessary repetition. This simplification contributes to both the maintainability and readability of the stylesheet.
* Fix linting errors in SCSS file
---------
Co-authored-by: github-actions <github-actions@github.com>
* Early implementation of getting the Product Collection location/context
* Solve the problem of async fetch in the hook
* Improve typing
* Import core data store instead of hardcoding store name
* Recognise Product Category and Product Tag
* Remove attr property from archive location data
* Unify states naming
* Add TODO entry
* Display the info about the location of Product Collection
* Improve the typing
* Recognise if Product Collection is nested in Single Product block
* Improve cases descriptions and add some defaults to potentially undefined values
* Change the taxonomies sourceData
* Recognise Mini Cart as Cart context
* Recognise attribute as archive contect but no taxonomy
* Refactor the function into single useEffect and clean it up
* Fix typo
* Remove unnecessary import
* Stop rendering the output in Editor (it was for demo purposes)
* Pass location data to Product Template query in Editor
* Replace templateSlugs literal strings with object reference
* Rename parseResponse function to more specific name getIdFromResponse
* Add dpeendency array to useEffect
* Refactor templates detection
* Use full taxonomy names instead of shortcuts
* Write down scenarios to test
* Working scenario
* Change the verification way for more robust
* Add more robust methods to include Single Product block
* Add test Product Collection in Single Product block in a Single Product Template
* Imprvoe the order of veryfing the requests
* Fix linter issues. Although that makes code less readable
* Improve the useGetLocation typing so it's more generic
* Rework the E2E tests regarding location of Product Collection and limit their number
* Bring back necessary eslint-disable
* Remove unused imports
* Uncomment line required for other tests
* Add changelog
* Rename constant from BLOCK_NAME to BLOCK_SLUG as it's a slug
* Add a BLOCK_NAME constant and replace the literal block name usages in E2E tests
* Fix post merge issues
* Fix test after merge
* Adjust the tests to kick off waiting for request before action that triggers them
* Make attributes available in rest_product_query hook
This commit introduces the 'includeInQueryContext' attribute to the 'woocommerce/product-collection' block and updates the 'woocommerce/product-template' block to consume this new attribute.
Key Changes:
1. `woocommerce/product-collection` Block:
- A new attribute 'includeInQueryContext' is added in `block.json`. This attribute is designed to hold a list of attribute names relevant for the query context.
- The 'includeInQueryContext' attribute is included in the `providesContext` field to ensure its availability to child blocks.
- In `constants.ts`, default values for 'includeInQueryContext' are defined, specifying 'collection' and 'id' as initial attributes.
- The `types.ts` file is updated with a comment explaining the purpose of 'includeInQueryContext'.
2. `woocommerce/product-template` Block:
- Modified `block.json` to utilize the 'includeInQueryContext' context provided by the parent `woocommerce/product-collection` block.
- The `edit.tsx` file is updated to handle the new context. It uses a newly added utility function `useProductCollectionBlockAttributes` from `utils.tsx` to access parent block attributes.
- The `utils.tsx` file is introduced, containing the `useProductCollectionBlockAttributes` hook. This hook is responsible for finding the parent 'woocommerce/product-collection' block and returning its attributes.
- Within `edit.tsx`, logic is added to create a query context object based on the attributes specified in 'includeInQueryContext', enhancing the block's ability to dynamically adapt to changes.
* Remove commented code
* Rename query context attribute and optimize parent block detection
This commit introduces two significant changes aimed at improving code readability and efficiency.
1. **Renaming of Query Context Attribute:**
- The attribute `includeInQueryContext` has been renamed to `queryContextIncludes` across various files, including block JSON configurations and TypeScript definitions. This change makes the attribute's purpose more intuitive, indicating it specifies which attributes to include in the query context.
2. **Optimized Parent Block Detection:**
- Replaced the use of `getBlockParents` with `getBlockParentsByBlockName` in utility functions to find the closest Product Collection block. This optimization allows for a more direct and efficient way to identify the relevant parent block by specifying the block name, reducing unnecessary iterations and improving code performance.
* Streamline query context construction in product template
Key Changes:
- **Introduction of `useProductCollectionQueryContext` Hook:** This new hook takes the `clientId` and `queryContextIncludes` as inputs and returns a query context object. It encapsulates the logic for fetching parent product collection block attributes and constructing the query context accordingly. This abstraction simplifies the edit component's logic, focusing on the essentials and improving code readability.
- **Optimization of Parent Block Detection:** The hook uses `getBlockParentsByBlockName` to accurately and efficiently find the closest parent `Product Collection` block, minimizing the overhead previously associated with traversing the block hierarchy.
* Always include `collection` and `id` in query context
* Minor refactor
* Enhance query context handling for more maintainable code
- Introduced `DEFAULT_QUERY_CONTEXT_ATTRIBUTES` in `edit.tsx` to maintain a clear list of default query context attributes.
- Modified `ProductTemplateEdit` to automatically include these default attributes in `queryContextIncludes`, ensuring they are always part of the query context without manual initialization.
- Simplified `useProductCollectionQueryContext` in `utils.tsx` by removing static initialization of 'collection' and 'id', relying instead on the dynamic addition of necessary attributes from `queryContextIncludes`.
This refactor enhances the maintainability and clarity of the code, ensuring a solid foundation for future enhancements and features.
* Add E2E tests for Product Collection query context
- Added a new test suite 'Query Context in Editor' to validate the correctness of query context parameters when the Product Collection block is used. This suite ensures that:
- For the 'Product Catalog', only the ID is sent in the query context, confirming that collection-specific parameters are excluded when not relevant.
- For collections such as 'On Sale', the collection name is correctly passed in the query context, validating that the block dynamically adjusts query parameters based on its settings.
- Introduced a new utility method `setupAndFetchQueryContextURL` in `product-collection.page.ts`. This method automates the setup of a post with the Product Collection block and fetches the URL with query context parameters, facilitating the validation of query context handling.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Fix edge case when `queryContextIncludes` is not defined
- Initializing `queryContextIncludes` with a default empty array directly in the destructuring assignment of the component's props. This approach ensures that `queryContextIncludes` is always an array, simplifying downstream logic.
- Creating a new constant `queryContextIncludesWithDefaults` to hold the combination of `queryContextIncludes` and `DEFAULT_QUERY_CONTEXT_ATTRIBUTES`. This step avoids directly mutating the `queryContextIncludes` prop, aligning with best practices for functional purity and making the code easier to understand and debug.
- Updating the `useProductCollectionQueryContext` hook call to use `queryContextIncludesWithDefaults`. This ensures that the default query context attributes are consistently included without altering the original prop.
These adjustments not only enhance the code's maintainability but also ensure more predictable behavior by avoiding side effects related to parameter mutation.
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add logic to trap keyboard focus inside the Product Gallery Pop-Up
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Remove unnecessary condition
* Fix issue with keyboard focus trap not working within the Pop-Up
---------
Co-authored-by: github-actions <github-actions@github.com>
* Import editor.scss styles of Product Templayte and increase specificity
* Add changelog
* Add ts ignore
* Revert changing eslint-disable as it conficts with another rule creating more errors
* Include collection attribute in the block context
* add 'collection' to useContext for Product Template
* Changelog
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
* Return focus to trigger element when closing pop-up
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix php cs error
---------
Co-authored-by: github-actions <github-actions@github.com>
* Add ability to select thumbnails using keyboard
* Add ability to open the Product Gallery pop up using the keyboard
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix outline border not showing on Thumbnails on some browsers
* Prevent firefox browser from focusing on UL tag of the Large Image block
* Enable usage of 'Space' and 'NumpadEnter' keys to navigate between the thumbnails
---------
Co-authored-by: github-actions <github-actions@github.com>
* fix error on decimal input for the Number of Thumbnails setting
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Initial working version
* Update scrolling behavior in product collection block frontend
This commit updates the scrolling behavior in the product collection block's frontend script.
Previously, the code focused on the first anchor or button within a product collection block. This approach was taken to maintain accessibility and ensure that the focused element was scrolled into view. However, this behavior has been changed to improve the user experience.
The updated code now directly scrolls to the first product in the collection. This is achieved by selecting the product using a new selector that targets the `.wc-block-product` class within the `.wc-block-product-template` of the specified `data-wc-navigation-id`. Once the product is selected, the `scrollIntoView` method is used with smooth behavior and start block alignment, offering a more visually appealing scroll effect.
This change enhances the user experience by smoothly directing attention to the beginning of the product collection, making it easier for users to browse products.
* Remove code related to animation
* Fix the issue related to pagination block rendering
- I have improved the code by breaking it into smaller functions
- Added unique `data-wc-key` to each anchor tag
* Enhance Product Collection Block with Interactive Prefetching
* Refine Prefetch Logic & other improvements
This commit further refines the prefetch logic and interactivity in the Product Collection block. It focuses on enhancing code clarity and improving the prefetch behavior based on user interactions.
Key changes include:
1. Renamed 'isPrefetchNextAndPreviousLink' to 'isPrefetchNextOrPreviousLink' in ProductCollectionStoreContext for better readability and accuracy.
2. Modified the scrollToFirstProductIfNotVisible function to accept a wcNavigationId as a parameter instead of a reference
3. Introduced checks for the existence of wcNavigationId in scrollToFirstProductIfNotVisible to prevent unnecessary executions.
4. Updated comments throughout frontend.tsx for enhanced clarity, explaining the prefetch logic and its triggers in detail.
5. Adjusted the logic in the navigate and prefetch functions to align with the new context structure and prefetch strategy.
6. In ProductCollection.php, updated data attributes to align with the revised prefetch strategy.
7. Refined the attribute setting in process_pagination_links function to correctly implement the updated interactivity and prefetch logic.
These changes aim to optimize the prefetch functionality, reduce unnecessary prefetching on initial page load, and ensure a smoother and more efficient navigation experience within the Product Collection block.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Improve comments
* Use wp_json_encode for data-wc-interactive attribute
This commit updates the `ProductCollection` class to use `wp_json_encode` for setting the `data-wc-interactive` attribute value. Previously, the attribute value was hardcoded as a JSON string. Now, by utilizing `wp_json_encode`, we ensure the JSON encoding is handled correctly by WordPress standards, enhancing readability and maintainability of the code.
---------
Co-authored-by: github-actions <github-actions@github.com>
* Initial approach to fix incorrect product data displayed in Product Collection in context of Single Product block
* Remove the BlockCOntextProvider
* Add Block context for title and summary
* Add changelog
* Improve typing
* Add E2E test with Product Collection inside Single Product block
* Improve insertBLock function description
* Make productPrices selector in Product Collectionmore specific
* Extract components props into a types
* Hide the shipping rates in editor to match front-end
- If there are no shipping rates, hide the shipping rates in editor to match front-end.
* Add get_shipping_zones method to CartCheckoutUtils
* Display change address like for fallback shipping zone
- If cart has multiple and default shipping zones without shopper address, display the change address link
* Update shipping address label
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Fix linting errors
* Update plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/shipping/shipping-address.tsx
Co-authored-by: Niels Lange <info@nielslange.de>
* Display shipping calculator for locations outside all other zones
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Update typescript for activeShippingZones
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
* Add unique ID attribute to Product Collection block
In this update, we introduced a unique identifier for each instance of the Product Collection block. This change involves several key modifications:
1. **Block JSON Update**: Added a new `id` attribute in `block.json` to store the unique identifier for each block instance.
2. **Product Collection Content Update**: In `product-collection-content.tsx`, we utilized the `uuid` library to generate a unique ID. This is done in a `useEffect` hook, ensuring that each block instance receives a distinct ID upon initialization.
3. **Type Definitions**: The `ProductCollectionAttributes` interface in `types.ts` was updated to include the new `id` attribute, aligning with our enhanced data structure.
4. **Package Dependencies**: To support this feature, `@types/uuid` and `uuid` were added to `package.json`, ensuring we have the necessary tools for ID generation.
This enhancement is pivotal for uniquely identifying each Product Collection block, paving the way for more robust and individualized block handling in the future.
* Rename uniqueId to id
* Add lock file
* Add 'id' context to product collection and template
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Merge trunk with 42861-introduce-a-unique-identifier-for-each-product-collection-block
* Regenerate the lockfile
* Remove autogenerated change in plugins/woocommerce/package.json
* Regenerate lock file
* Rerun CI actions
* Delete pnpm-lock.yaml file & regenerate it using pnpm install command
---------
Co-authored-by: github-actions <github-actions@github.com>
* Remove the experimental flag from the Product Gallery block
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* Get default attributes on front end
* Remove console log
* Show notice about 0 registered fields in editor
* Do not show block in editor if no fields are registered
* Wrapper block
* Styling/spacing
* Update webpack config
* Register heading pattern
* Wrapper block type definition
* get_fields_for_location return fields in array format
* Use wrapper in default content
* Separate fields from the hook block
* Hide when no custom fields exist
* Address and contact fields
* Shared form fields in settings
* remove info block from wrapper
* Revert render_content to original
* rename block
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Update styling
* Create shared get_order_additional_fields_with_values to format values
* Update block names and descriptions
* Show address placeholders
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* Unused import
---------
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: github-actions <github-actions@github.com>
* Product Gallery: Update div elements to ul and li for better accessibility
* Product Gallery: Add changelog files
---------
Co-authored-by: roykho <roykho77@gmail.com>
* Prevent body from scrolling when pop-up is open
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Add namespace to the modal-open css class
* Fix class name for the Product Gallery block
---------
Co-authored-by: github-actions <github-actions@github.com>
* Fix Mini-Cart price disappearing on hover
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Introduce the minimal block style for productDetails block
* Change the default style in the template
* Change the default template when using the transform-to-blocks button
* Cleanup
* Organize CSS selectors
* Add opacity on hover
* Fix specificity and add explanation
* Cleanup
* Changelog
* Rename media setting to "Open pop-up when clicked"
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Product Gallery: Use @container rule to adjust overlay link count font size
* Add changelogs
* Remove em from line height
* Make view all link smaller
* 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
* Update generic incompatibility notice
- Update the notice description.
- Add switch to classic shortcode block button to the notice.
* Fix margin in editor.scss
* 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
* 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
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Add type property to notice events
* Refactor switch to classic shortcode button logic
* Use isCart for switchButtonLabel and snackbarLabel
* Remove empty div in sidebar compatibility notice component
* Refactor switch to classic shortcode button event handling
* Adjust wording
* Adjust marging and readability
* Introduce union for SwitchToClassicShortcodeButtonProps type prop
* Simplify logic
* Use proposed text
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* add: multiple select support to attribute dropdown
* fix: remove active filter from dropdown
* chore: remove unused extractBuiltinColor
---------
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* add: query filters count class
* chore: method comments
* refactor: rename class to QueryFilters
* fix: price filter count
* fix: price filter url
* chore: remove unnecessary transformation
* chore: remove unused meta query filter
* chore: put public methods on the top of the class
* fix: passing $wp_query
* Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce
* fix: stock query clause
* fix: handle and query type for attribute filter
* fix: ensure passing non null value to floor/ceil
* [Experimental] Collection Filter blocks: ensure the namespace is always rendered (#43112)
* fix: ensure the namespace is always rendered
* fix: target only wc queries
* fix: properly reset part of query to make new filter blocks work with Product Collection block
* Update woocommerce.com URLs in documentation and code files
* Add changelog
* Fix github repository link in extend-rest-api-add-custom-fields.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Add github reporter (#42974)
* Add github reporter
* Add changelog
---------
Co-authored-by: Jon Lane <jon.lane@automattic.com>
* Fix product task redirect to support grouped and external products (#43051)
* Rearrange product redirection logic to better accept grouped and external produc types
* Add changelog
* Modify feedback modal actions (#43005)
* Adapt feedback modal actions
* Add changelogs
* Modify comments
* Fix tests
* Fix test
* Update class-wc-gateway-bacs.php (#43054)
* Update class-wc-gateway-bacs.php
Fix typo in textdomain
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* [Product Block Editor]: Add `Linked product` tab (#43009)
* add linked-products to group IDs
* add Linked Products tab
* tweak hideConditions condition
* changelog
* fix typo in doc comment
* Introduce a product type selection within the new experience (#41823)
* Create a relation between the product type and the product block template
* Add 'patterns' to name the kind of products that can be created for a specific template
* Resolve template using its id as a template query param
* Rename ProductEditPattern to ProductTemplate
* Rename get_patterns hook to woocommerce_product_editor_get_product_templates
* Return the list of templates to the client
* Set layout template events as array
* Register the layout template based on the product template or the post type in case of product variations
* Registering non supported product types
* Create and register the woocommerce/product-details-section-description block
* Add the product type to the section description
* Create product type selector
* Fix menu item style
* Highlight selected menu item
* Set the selected product template
* Set product template title to lowercase in the content description
* Rename blocks by blockTemplates under the AbstractBlockTemplate class
* Rename to woocommerce_product_editor_product_templates filter
* Remove product_template_ prefix from the supported_product_types map
* Rename get_formatted to to_JSON and convert the props to client side like
* Refactor get_product_templates
* Fix icon resolution
* Add a confirmation modal for unsupported product templates
* Add changelog files
* Remove product types using for testing
* Fix redirection when changing to a non supported product template
* Set the change button state to busy when it is saving the product
* Fix php linter errors
* Fix rebase conflict
* Move ProductTemplate to Automattic\WooCommerce\Admin\Features\ProductBlockEditor namespace
* Add the to_json definition to the BlockTemplateInterface
* Create default product template by custom product type if it does not have a template associated yet
* Fix some comments and product template creation validation
* Add support to load the product template icon from an external resource
* Fix php linter
* Fix the changelog description
* [Experimental] Interactivity Dropdown multi-select mode, ratings filter and introduce each directive (#42981)
---------
Co-authored-by: David Arenas <david.arenas@automattic.com>
* Introduce the transient files engine (#42877)
Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
* Change marketplace install API request to POST instead of GET (#43033)
* Change marketplace install API to using POST instead of GET
* Fix linting error
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* Prep trunk for 8.6 cycle (#43021)
Prep trunk for 8.6 cycle with version bump to 8.6.0-dev
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
* Add Playwright tests for All Reviews, Reviews by Product and Reviews by Category blocks (#42903)
* Remove Reviews blocks Puppeteer tests
* Minor code cleanup
* Typos
* Create publishAndVisitPost() editor util
* Fix subcategories when importing products in Playwright and add reviews
* Add Reviews blocks tests in Playwright
* More typos
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
* Create a 'reviews' object in data.ts so we can store reviews data in one single place
* Update test so instead of creating a new post in each test, we go to the already-created post
* Add source comments to reviews data to match it with the script
---------
Co-authored-by: github-actions <github-actions@github.com>
* Release: Remove 8.5 change files (#43022)
Delete changelog files from 8.5 release
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
Co-authored-by: Alex López <alex.lopez@automattic.com>
* Delete changelog files based on PR 43033 (#43079)
Delete changelog files for 43033
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
* Delete changelog files based on PR 43051 (#43081)
Delete changelog files for 43051
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
* Interactive Price Filter: use `context` instead of `state` (#42980)
* feat: use context instead of state
* fix: temporary move the context to inner element for diffing to work
* fix: update context before navigation for optimistic UI
* Load google analytics gtag script asynchronously in WooCommerce Blocks (#43040)
Co-authored-by: github-actions <github-actions@github.com>
* set WOOCOMMERCE_BLOCKS_PHASE to 1 for the production build (#43074)
* set WOOCOMMERCE_BLOCKS_PHASE to 1 for the production build
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
* Revert "Fix schedule sales error" (#43094)
Revert "Fix schedule sales error (#42700)"
This reverts commit 9b800aa179.
* [Product Block Editor]: add Linked product sections. First approach. (#43013)
* add Linked products, Upsell section
* changelog
* add Cross-lens section
* add links to the Upsell sections
* changelog
* fix lint issues
* fix lint issus
* fix linting issue :-|
* check whether the linked product group is defined
* [Product Block Editor]: introduce ShoppingBags component (#43042)
* add ShoppingBags component
* Add ShoppingBag story
* changelog
* Fix: Collection data being leaked between Collection Filters blocks (#43044)
* fix: CYS - change heading color (#43076)
* fix: CYS - change heading color
* Add changefile(s) from automation for the following project(s): woocommerce
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
* Delete changelog files based on PR 43074 (#43118)
Delete changelog files for 43074
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
* [Product Block Editor]: fix feature flag to hide the Linked products (#43119)
* fix flag to hide/show product editor
* changelog
* Add changelog
---------
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
Co-authored-by: Jonathan Lane <lanej0@users.noreply.github.com>
Co-authored-by: Jon Lane <jon.lane@automattic.com>
Co-authored-by: louwie17 <lourensschep@gmail.com>
Co-authored-by: Fernando Marichal <fernando.marichal@automattic.com>
Co-authored-by: Marc Guay <marc.guay@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Damián Suárez <rdsuarez@gmail.com>
Co-authored-by: Maikel David Pérez Gómez <maikel.perez@automattic.com>
Co-authored-by: Sam Seay <samueljseay@gmail.com>
Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
Co-authored-by: Corey McKrill <916023+coreymckrill@users.noreply.github.com>
Co-authored-by: Kyle Nel <22053773+kdevnel@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: WooCommerce Bot <no-reply@woo.com>
Co-authored-by: Alex López <alex.lopez@automattic.com>
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Patricia Hillebrandt <patriciahillebrandt@gmail.com>
* Fix: Enable Pagination Block Visibility in Product Collection Block
This commit resolves an issue where the Pagination block was not visible in the block insertor within the Product Collection block.
- The core query pagination block name, initially hardcoded, is now declared as a constant `coreQueryPaginationBlockName` in `constants.ts`. This change not only improves code readability but also ensures consistency in using the block name across different files.
- In `index.tsx`, the `addProductCollectionBlockToParentOfPaginationBlock` utility function from `utils.tsx` is imported and executed. This function plays a crucial role in the fix. It dynamically adds the Product Collection block to the parent array of the Core Pagination block, ensuring the latter's visibility in the insertor when editing the Product Collection block.
- The utility function employs WordPress hooks and version checks to gracefully handle different WordPress environments. This careful approach maintains backward compatibility while addressing the current issue.
With these changes, merchants can now easily add a Pagination block from the insertor while working on the Product Collection block, enhancing the user experience and functionality.
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
* Show rating stars for the cross-sells products
* Fix typo introduced in #43116 (#43148)
* Fix typo introduced in #43116
* Add changefile(s) from automation for the following project(s): @woocommerce/product-editor
---------
Co-authored-by: github-actions <github-actions@github.com>
---------
Co-authored-by: github-actions <github-actions@github.com>
* Migrate PR to Core
* Migrate test changes
* Add Custom Collection with inherit query attribute disabled
* Update copy of Product Catalog collection
* Don't choose default active collection in polaceholder and remove highlight
* Remove inherit query option from inspector controls
* Add collection names to Product Catalog and Custom one
* Unify Collection Chooser between Modal and Placeholder
* Bring back util removed by accident
* Replace the translations domain with woocommerce
* Remove leftovers after merge
* Add pagination and no results to Product Catalog and Custom collections
* Revert textdomain change
* Fix lint error
* Add changelog entry
* Change collection label
* Bring back Inherit query from template
* Remove Custom collection and bring back single Product Collection
* Simplify applying collection
* Make sure Inherit query from template is enabled in archive templates by default and disbaled in posts/pages
* Change incorrect Playwright locator
* Add test for Product Catalog inheriting the query in product archive
* Add tests for recommendation collection hiding the predefined filters
* Add reviews to multiple products
* Update expected products in Top Rated
* Remove rating creation in test env and skip undeterministic tests
* Add skip to Best Sellers test
* Update README.md
* Add more keywords to collections, like 'product collection' to recommendation collections
* Rephrase the README note about Collections registration
* Simplify types
* Rename unchangeableFilters to hideControls
* Fix typo in file name
* Remove 'pattern' references from toolbar files
* Replace hardcoded SCSS color with wc variable
* Remove changelog file from different PR
* Move hideControls to Product Collection ayttributes
* Improve responsiveness of columns in Product Collection Placeholder
* Use admin color pallette in Product Collection Placeholder
* Move Inherit query from template to the top of Inspector Controls
* Change the Collection prefix to woocommerce rather than woocommerce-blocks
* Simplify Placeholder and Modal styles
* feat: use context instead of state
* fix: temporary move the context to inner element for diffing to work
* fix: update context before navigation for optimistic UI
* 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>
* 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>
* 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
* Introduce Additional Fields API for Checkout Block https://github.com/woocommerce/woocommerce-blocks/pull/12073
* revert test to what it was
* Default to text, if the type supplied is not supported throw an error
* Add type for options
* Return null if somehow the select made it through without options
* Make select fields type enum and add options to schema
* Lint fixes
* Update plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/address-form/address-form.tsx
Co-authored-by: Niels Lange <info@nielslange.de>
* Update plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFields.php
Co-authored-by: Niels Lange <info@nielslange.de>
* Update checks to log errors and fail gracefully
* Add field id to class names
* Fix lint error
* Fix short array use
* Introduce Additional Fields API for Checkout Block https://github.com/woocommerce/woocommerce-blocks/pull/12073
* Default to text, if the type supplied is not supported throw an error
* Lint fixes
* Introduce Additional Fields API for Checkout Block https://github.com/woocommerce/woocommerce-blocks/pull/12073
* add support for registering checkboxes
* remove extra error log
* add styling
* fix rebase conflit
* fix rebase conflit 2
* fix linter errors
* address review comments
* add warning for checkbox
* fix changes
---------
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
Co-authored-by: Niels Lange <info@nielslange.de>
* Remove padding for the products query with background
* Add changefile(s) from automation for the following project(s): woocommerce-blocks
---------
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Karol Manijak <20098064+kmanijak@users.noreply.github.com>
* Introduce Additional Fields API for Checkout Block https://github.com/woocommerce/woocommerce-blocks/pull/12073
* add changelog
* Auto load the Blocks/Domain/Services/functions.php file
* add changelog
* revert test to what it was
* Update text domain for translations
* Ensure address data is added on the cart block too
* fix lint problem
---------
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Product Image Gallery: Add transform to Product Gallery block
* Single Product Template: Transform to blocks with new Product Gallery block
* Ensure we first check for block existance
* Add changelog
* Add/delete changelog file
* Change border color to Gutenberg 100 for Cart and Checkout blocks
* Change form input color to Gutenberg 900 for Cart and Checkout blocks
* Fix additional border colors of Checkout block
* Update borders and form field colors in Cart Block
* Change border color to $universal-border-light
* Change border color for cart line items to $universal-border-light
* Change form input fields border color to $universal-border-dark
- Add $universal-border-dark color variable for woocommerce/woocommerce-blocks#1e1e1e on white.
* Fix colors of text area border and form steps
* Change form input fields border color to $universal-border-dark
- Add $universal-border-dark color variable for woocommerce/woocommerce-blocks#1e1e1e on white.
* Fix form steps
* Update universal dark border rgba value
- Update universal dark border rgba value from rgba(0, 0, 0, 0.882) to rgba(17, 17, 17, .80) to keep it consistent with universal-border colors
* Update $universal-border-light color
* Update the opacity of the borders
* Update the border color to rgba (17, 17, 17, 0.12)
* Roll back $universal-border-light value to the original value: 0.115
* Remove Opacity and pass it as argument in with-translucent-border
- We have with-translucent-border option that accepts border and opacity for pseudo elements.
* Remove additional spaces
* Replace with-translucent-border with normal border
- Since we're are not mixing the opacity to the border color so we don't need to use mixin with-translucent-border.
* Fix applied css and add low contrast Color usage details
- Fix minor CSS as per the standards.
- Add comments for universal border colors that they're low contrast colors and should be used for decorative elements only
* Fix border gap and double border for multiple shipping packages
* Fix payment method borders and Cart line items borders
- Change border bottom to border-top for cart line items.
- Fix payment method radio control borders.
* Fix local pickup border
- Local pickup was using with-translucent-borders so it has some opacity, changed it to border-bottom.
* Add border-bottom to cart items
* Remove additional border from Cart items
* Fix radio and checkbox borders as per the design
* Fix shipping method borders and background color as per the design.
* Force align left on the description for the local pickup options.
* Update border color in quantity selector component
* Fix Shipping options radio selection alignment
- Add left padding to wc-block-components-shipping-rates-control__package element.
* Update colors and variables
* Change checkbox and radio button colors
- Change checkbox and radio button colors from rgba(25, 23, 17, 0.3) to rgba(25, 23, 17, 0.48).
* Remove bottom property from express payment style
* Center align view all link
* Add thumbnail count specific styling
* Product Gallery Thumbnails: Improve the responsiveness of the View All overlay text
---------
Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com>
* Change the default for Mini Cart block
The Block Hooks API currently doesn’t allow for setting the default state of the block injected into content so this ensures the mini-cart block has a better default state for injection. The current default (displaying total value in cart) takes up more width increasing the risk of poor layout.
* Utilize Block Hooks to automatically inject mini-cart block.
* include experimental prefix on filters
* Fix filter name.
* remove experimental prefix.
On thinking about this, I don’t think these need to be experimental. They are intentionally provided as escape hatches for hosts/themes that want to opt-in/out so we’ll have to support them when this is shipped (at least until its no longer needed!)
* fix variable name!
* fix unit tests because of new default
* remove another incorrect text expectation
Defaults for the block affect this expectation.
* fix E2E tests
* Mini Cart Block: improve E2E test
* fix: improve check for the Product Collection block
---------
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* Reorganise Columns controls and fix undefined problem in Product Collection settings
* Remove type condition in hasValue of Columns control
* Adjust the E2E tests locator to new changes
* Try env:restart instead of env:start
* Change env:restart to env:start again
* Try env:restart instead of env:start
* Change env:restart to env:start again
* Adjust heading level of cart and checkout template
* Replace button selector with label selector
* Try env:restart instead of env:start
* Change env:restart to env:start again
* Ensure to close welcome guide modal
* Adjust heading level of default template content
* Try env:restart instead of env:start
* Change env:restart to env:start again
* Try env:restart instead of env:start
* Change env:restart to env:start again
* Address existing TS issues
* View template in edit mode
* Keep certain tests skipped
* Fix broken tests after addressing TS issues
* Convert to tsx and replace proptypes by ts definitions
* Fix imports
* Fix noReviewsPlaceholder type
* Fix ts errors
* Use createHigherOrderComponent in withReviews
* Revert hoc change
---------
Co-authored-by: Niels Lange <info@nielslange.de>
* Add HTML entity decoding for product names in Hand-Picked Products control
In the Hand-Picked Products control within the product-collection inspector controls, a function for decoding HTML entities in product names has been added.
- A new utility function `decodeHTMLEntities` has been implemented. This function decodes HTML entities in a string, ensuring that special characters are correctly displayed in their human-readable form.
- The `transformTokenIntoProductName` function has been updated to utilize `decodeHTMLEntities`. Now, when a product name is fetched (either directly as a token or via a product ID), the HTML entities within the name are decoded.
- This enhancement ensures that product names containing characters like ampersands or other HTML entities are accurately displayed in the UI.
This change improves the readability and accuracy of product names within the Hand-Picked Products control, enhancing the user experience for store managers using WooCommerce Blocks.
* Update label and hide description
This commit updates the `HandPickedProductsControl` component. Specifically, the user-facing label for product selection has been changed from 'Pick some products' to 'Hand-picked Products'. Additionally, the `__experimentalShowHowTo` property has been added with a `false` value, to hide description. Corresponding changes have been made in the E2E test file `product-collection.block_theme.spec.ts`, where the filter name is updated to match the new label.
* Refactor: Replace custom HTML entity decoder with `@wordpress/html-entities`
Rationale:
- The shift to `@wordpress/html-entities` aligns with standard WordPress practices, ensuring consistency across the platform.
- Enhances maintainability by relying on a well-supported library rather than custom code.
- Simplifies the codebase by removing a redundant utility function.
This change enhances the robustness of our code and aligns with best practices in WordPress development.
* Product Gallery Thumbnails: Refactor sizing in the editor and the front end
* Product Gallery Thumbnails: Change default vertical alignment to top and better control the width of the thumbnails
* Product Gallery Thumbnails: Fix thumbnails cropping based on the 'Crop images to fit' setting
* Product Gallery Thumbnails: Revert thumbnails styling from woocommerce/woocommerce-blocks#11665
* Product Gallery Thumbnails: Update the default value of the cropImages setting to false
* Product Gallery Thumbnails: Refactor sizing in the editor and the front end
* Product Gallery Thumbnails: Change default vertical alignment to top and better control the width of the thumbnails
* Product Gallery Thumbnails: Restrict the bottom position thumbnails width based on the total number of thumbnails set
* Product Gallery: Remove hardcoded width for Thumbnails and the Large Image and update the width inside of the Dialog
* Product Gallery Thumbnails: Introduce thumbnails scaling based on the number of thumbnails
* Product Gallery Thumbnails: Fix editor thumbnails scaling
* Product Gallery Thumbnails: Remove unused column gap variable
* Product Gallery Thumbnails: Fix styling for vertical images
* Product Gallery: Remove the unused editor.scss file
* Product Gallery: Fix the placement of the Thumbnails block in the block template
* Product Gallery Dialog: Reset changes to the dialog
* update @wordpress/e2e-test-utils-playwright package
* don't update node version
* remove waitForSiteEditorFinishLoading function
* use visitSiteEditor util
* Product Gallery Thumbnails: Add code comments
* Product Gallery Thumbnails E2E: Fix the test checking the default position of the thumbnails
* Product Gallery E2E: Fix the test checking if the cropping setting works correctly
* Product Gallery Thumbnails: Hide the Thumbnails block if there aren't at least 2 thumbnails to display
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* Enable shrink columns option in Product Collection by default
* Improve tests about responsiveness
* Make regex allowing for floating pixels
* Related products should not use sticky and author attribute or have hardcoded queryId
* Bring back properties for Related Products as it's based on Propducts block, not Product Collection
* Enable shrink columns to fit by default in patterns
* Sync Interactivity API code with Gutenberg
* New store() API
* Store raw actions
* Update wc-interactivity-store implementation
* Replace `wc_store` with `wc_initial_state`
* Parse and populate initial state
* Allow store parts in `store()`
* Accept namespaces in directive paths
* Add $$namespace to directives' object values
* Make namespace parsing more robust
* Use DeepPartial type for store parts
* Do not pass `rawStore` to `afterLoad` callbacks
* Simplify `store()` a bit
* Implement `privateStore()`
* Sync context directive with Gutenberg
* Refactor scope and extract getters per scope
* Add namespace to getters and actions
* Remove current privateStore implementation
* Remove `afterLoad` option from `store`
* Use same proxy handlers for ns, getters and actions
* Set scope inside `evaluate`
* Refactor proxy handlers
* Improve types a bit
* Catch errors in async actions
* Implement stacks for scopes and namespaces
* Implement `getElement`
* Change directives object structure
* Remove unnecessary import
* Implement private stores
* Return value from sync actions
* Minor optimizations and improved comments
* Don't use async inside `data-wp-watch`
* Use a single Provider in context directive
* Remove DeepPartial type
* Do not check if element exists
* Add the `current` prop of state inside the scope
* Move getters outside scope
* Fix wc-key assignment
* Fix missing `navigate` in directives
* Fix namespace not being picked in the same element
* Deep merge raw stores instead of proxied ones
* Fix namespace assignment
* Allow forward slashes in namespaces
* Migration of Product Collection and Product Button blocks to the new `store()` API (https://github.com/woocommerce/woocommerce-blocks/pull/11558)
* Refactor Product Button with new store() API
* Use `wc_initial_state` in Product Button
* Fix namespace
* Remove unnecessary state
* Test namespaces in directive paths
* Add test context with namespace
* Simplify woo-test context
* Move addToCart and animations to a file
* Do not pass `rawStore` to `afterLoad` callbacks
* Move callbacks and actions back to the main file
Because the animation was broken.
* Remove selectors in favor of state
* Use default ns in `getContext` for state and actions
* Remove `afterLoad` callback
* Remove unnecessary ns
* Fix getContext in add-to-cart
* Replace namespace and delete unnecessary store
* Pass context types only once
* Use an alternative for requestIdleCallback
* Add previous react code for notices
* Add namespace to Product Collection block
* Replace getTextButton with getButtonText
* Add block name to the ProductCollection namespace
* fix style HTML code
* Remove circular deps error on the Interactivity API
* Product Gallery block: Migrate to new Interactivity API store (https://github.com/woocommerce/woocommerce-blocks/pull/11721)
* Migrate Product Gallery block to new Interactivity API store
* Fix some references
* Add missing data-wc-interactive
* Fix an additional namespace
* Remove unnecessary click handler
* Dialog working
* Refactor action names
* Reindex PHP array
There was some missing indexes, which turned the array into an object in JS.
* Remove unused event handlers
* Move next/previous logic to external function
* Move StorePart util to the types folder
* Rename namespace to `woocommerce/product-gallery`
* Undo product collection namespace renaming
* Remove unnecessary namespace
* Don't hide the large image on page load
* Minor refactorings
* Fix eslint error
* Fix php cs errors with spacing and double arrows alignment
* Disable no-use-before-define rule for eslint
* Disable @typescript-eslint/ban-types rule for eslint
* Fix parsed context error in e2e tests
* Fix context parser for Thumbnail image
* Move store to the top of the frontend file
* Add interactivity api utils to the @woocommerce/utils alias
* Replace deprecated event attribute
---------
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Co-authored-by: David Arenas <david.arenas@automattic.com>
Co-authored-by: roykho <roykho77@gmail.com>
---------
Co-authored-by: David Arenas <david.arenas@automattic.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: roykho <roykho77@gmail.com>
* Fix error when closing product gallery dialog with keyboard escape key
* use wc_initial_state instead of wc_store
---------
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Alexandre Lara <allexandrelara@gmail.com>
Co-authored-by: roykho <roykho77@gmail.com>
* Update Interactivity API JS files
* Disable TS checks in the Interactivity API for now
* Add new SSR files
* Replace wp_ prefixes with wc_ ones
* Replace wp- prefix with wc-
* Replace guternberg_ prefix with woocommerce_
* Remove file comments from Gutenberg
* Rename files with `wp` prefix
* Fix code to load Interactivity API php files
* Remove TODO comments
* Replace @wordpress with @woocommerce
* Update Webpack configuration
* Fix directive prefix
* Remove interactivity folder from tsconfig exclude
* Add client-side navigation meta tag code
* Remove unneeded blocks.php file
* Fix store tag id
* Register Interactivity API runtime script
* Fix Interactivity API runtime registering
* Add Simple Price Filter block
* Remove all files related to directive processing in PHP
* Use values directly for SimplePriceFilter SSR
* Reset pages to 0 when changing filter
Note: we also need to do this with `/page/x`
* wip
* phpcs
* register price filter as inner block
* try: render block using save
* add types
* use min range var instead of 0
* inject dynamic data
* query price data in editor
* better injecting interactivity data
* remove rounding
* Product Collection Data endpoint doesn't care about current query so we remove the context for now
* extract data injecting as a method, possbily a trait in the future
* add sidebar setting
* duplicating the markup in php render callback for safety
* remove directive from edit component
* show prices without decimal
* use final class
* use sample collection data response
* prepare for multiple styles support
* use collection data from context
* cleanup props and props passing
* pass only necessary states
* retire heredoc in favor of late escaping
* reorganize style
* inherit style from current price filter react component, pre extract the component for multiple display style support
* keep minPrice smaller than max
* remove unnecessary active handler logic
* update folder structure
* avoid whitespace change
* clean up
* title
* move inspector to component folder, ready to be extracted to inner block
* block icon
* block name
* name
* use inner block for view
* inner block view switcher
* try: process data in Collection Filtes block only
* wip: query collection data from collection filters block only
* provide all context from collection filters block
* simplify context passing
* feat: use default attribute to define filter type of view block
* rename
* remove price block
* rename price slider to price, default price filter should be a slider
* type cleanup
* fix ancestor block name
* only passing the collection data down
* wip
* recusive
* editor preview
* refactor: data fetching, context passing, and code organization
* initial attribute filter block
* feat: attribute selector
* inspector control
* wip
* break the edit into smaller components
* wip: editor component
* extract checkbox list
* wip editor preview
* show count checkbox list
* fix param aggregation for attribute filter blocks
* post merge fix
* fix param aggregation for attribute filters
* fix: set correct selected attribute
* WIP checkbox list
* WIP checkbox list
* avoid action name conflicts
* Checkbox list front end
* phpcs
* update context on input, navigate on change
* fix: attribute selection
* dropdown
* remove isDeepEqual
* add: warning when attribute has no products or no attribute is selected
* update type
* update type
---------
Co-authored-by: David Arenas <david.arenas@automattic.com>
Co-authored-by: Luis Herranz <luisherranz@gmail.com>
* Add custom 'No Results' block for Product Collection
This commit introduces a new 'No Results' block, replacing the default core 'query-no-results' block within product collection block. The 'No Results' block provides a tailored experience for WooCommerce stores, displaying a custom message when no products are found in a query.
Key changes include:
- A new block type 'woocommerce/no-results' is registered with a complete configuration and content structure.
- Edit and save functions are implemented for the block, allowing for custom content and styles within the block editor and on the front end.
- Webpack entries are updated to include the new block in the build process.
- A PHP class NoResults is added for server-side rendering, which only displays the block when the product query returns no results, enhancing performance.
- The ProductCollectionUtils utility class is extended to support the new block's query needs.
The new block enriches the user experience by providing clearer communication when no products match the collection criteria and allows store owners to customize the message and presentation.
* Update description
* Rename 'no-results' block to 'product-collection-no-results'
Changes include:
- Updating the block name in `edit.tsx` within the `product-collection` directory.
- Modifying the block.json file in the `no-results` inner block to reflect the new name.
- Adjusting the className in `edit.tsx` for the `no-results` inner block.
- Altering the webpack entries in `webpack-entries.js` to recognize the new block name.
- Renaming the block in `NoResults.php` to align with this update.
This renaming aims to make the block's purpose more clear and to maintain a consistent naming scheme within our product collection blocks.
* Rename NoResults to ProductCollectionNoResults for clarity
This commit renames the `NoResults` class to `ProductCollectionNoResults`. The change aims to enhance clarity and specificity about the class's purpose, indicating that it specifically handles no-result scenarios within product collections.
Changes made:
- Renamed `NoResults.php` to `ProductCollectionNoResults.php`.
- Updated the class name from `NoResults` to `ProductCollectionNoResults` in the file.
- Modified the reference in `BlockTypesController.php` to use the new class name.
This renaming ensures better readability and understanding of the class's role in the context of product collections. The primary change is the renaming, with no significant alterations in the class functionality.
* Update No-Results Message Formatting in Product Collection Block
This commit simplifies the layout and message content for the 'No results found' message in the product collection block's no-results edit component. The changes include:
1. Removal of the full stop in the 'No results found' string for consistency.
2. Replacing the 'core/group' block with a 'core/paragraph' block.
3. Streamlining the message content to be more concise and integrated into fewer text blocks.
4. Direct links for 'clearing any filters' and navigating to the 'store's home' are now included in the same paragraph.
---------
Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
* WIP: experimenting with strategy pattern for block registration
* Add TemplateChangeDetector to BlocksRegistrationManager
* Handle blocks registration
* Fix issue causing blocks to be registered multiple times
* Allow register/unregister blocks when on pages or posts
* Add BlockRegistrationStrategy logic
* Fix import error
* Add doc comments for BlockRegistrationManager class
* Add doc comments to TemplateChangeDetector class
* Fix eslint errors
* Import domReady from @wordpress/dom-ready
* Prevent error when using blockName for registerBlockType function
* Add e2e tests to check for block availability in different contexts
* Add e2e tests to cover block availability on different contexts
* Hide pager in dialog
* Product Gallery: reset main image when dialog closes
* Product Gallery block: Add product title to dialog
* Align double arrow
* Use H2 to be more semantic
* Use product title block in template part
* Default pager to off
* Remove pager only in dialog
* Remove unused param
* Default pager to off instead of removing
* Move Button, StoreNotice and StoreNoticesContainer components into the components package
* Delete the button folder and leave alias in index.ts
* Update references from @woocommerce/blocks-checkout to @woocommerce/blocks-components
* Add checks to see if getCartData finished before rendering address
* Prevent block error due to excessive updates of customValidation
* Do not condense address in admin and handle phone field
* Add missing showPhoneField for billing
---------
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* Create Related Products pattern reused in the Single Product template
That's needed in order to make the Related Products string translatable
* Add margin to Related Products heading
* Add margin to Related Products transformed from classic template
* Simplify the translation
* Change string capitalization so it's the same as the other one and can be transklated
* Add support for filtering products by featured status
- Added `featured` attribute to `ProductCollectionQuery` type to enable filtering by featured status.
- Implemented `FeaturedProductsControl` to provide a toggle option in the inspector controls.
- Integrated `FeaturedProductsControl` into `ProductCollectionInspectorControls`.
- Added `get_featured_query` function in `ProductCollection` class to generate query for fetching featured products.
- Updated existing functions and queries in `ProductCollection` class to support featured products filtering.
* Revert changes to composer.lock
* Refactor handling of 'featured' parameter
This commit makes the handling of the 'featured' parameter consistent in the ProductCollection class. Previously, the 'featured' parameter was being type-casted to boolean, which was not necessary and could lead to incorrect results. Now, the 'featured' parameter is used directly without type-casting, and the check for 'featured' products in the get_featured_query method has been updated accordingly. This ensures that the 'featured' parameter is handled consistently and correctly throughout the class.
* Handle undefined 'featured' index
This commit adds null coalescing operator to handle the case when 'featured' index is not set in the $query array. This prevents potential PHP notices or errors that may arise when trying to access an undefined index.
* Add time frame filter to Product Collection block
This commit introduces the ability to filter products within the Product Collection block by a specified time frame. The changes include:
- A new 'timeFrame' property added to the DEFAULT_QUERY constant in constants.ts, initialized as null, allowing for the storage of time frame data.
- Creation of a new component `CreatedControl` in created-control.tsx that provides UI elements for selecting a time frame filter.
- Inclusion of `CreatedControl` in the Product Collection Inspector Controls.
- Expansion of the ProductCollectionQuery interface in types.ts to include a 'timeFrame' attribute.
- Addition of the 'timeFrame' parameter handling within the ProductCollection PHP class to construct and execute the date query based on the provided time frame.
The addition of the time frame filter offers enhanced flexibility in presenting products and allows users to dynamically segment their product lists based on product creation dates.
* Refactor: Standardize 'timeFrame' to be 'undefined' instead of 'null'
This commit includes a refactoring that changes the initialization and reset values for the `timeFrame` property from `null` to `undefined`. This standardization affects the constants, type definitions, and the handling of the `timeFrame` property in both the inspector controls and the PHP backend.
* Switch date query to use post_date_gmt for DST consistency
This commit changes the column reference in the date query from 'post_date' to 'post_date_gmt'. This update ensures that the product collection filtering is based on Coordinated Universal Time (UTC) rather than local time, which can be affected by Daylight Saving Time (DST) shifts. The modification will lead to more consistent and reliable behavior across different time zones and during DST changes.
* Capitalize toggle group labels
The following adjustments have been made:
- Introduced a constant `uppercaseStyle` to store the `{ textTransform: 'uppercase' }` style.
- Applied `uppercaseStyle` to both the 'IN' and 'NOT IN' toggle options to ensure label text is consistently uppercase.
- Updated the 'Not in' label text to uppercase ('NOT IN') to match the newly applied style.
These changes ensure that the toggle labels align with the design guidelines that call for uppercase styling in control elements.
* Make first letter of first work capital
* Rename to Within & Before
* Update i18n for Product Collection query operators
This commit updates the internationalization (i18n) for the Product Collection query operators in the 'Created' control component of the WooCommerce Blocks plugin. It replaces the '__' function with '_x' for translation and provides context comments for better translation handling. This improvement enhances the localization of the query operators for better multilingual support.
* Product Gallery Thumbnails: Add View All link to the last thumbnail (non-interactive)
* Product Gallery Thumbnails: Add interactivity to the View All overlay
* Product Gallery Thumbnails: Refactor View all html to make it more readable
* Product Gallery Thumbnails: Fixwoocommerce/woocommerce-blocks#11100 - Load all thumbnails and hide the View all overlay when in Dialog
* Product Gallery Thumbnails: Fixwoocommerce/woocommerce-blocks#11099 - Enable the dialog for the View all thumbnails overlay even when the 'Full-screen when clicked' setting is disabled
* Product Gallery Thumbnails: Remove unnecessary concatenation from the View all html
* Product Gallery Thumbnails: Abstract the View All conditions into separate functions for readability
* Product Gallery Thumbnails: Add escaping to the View all plain text string
* E2E: Fix the Sale Badge and Single Product Template tests by selecting the first Sale Badge
* Product Gallery: Add cropped image support
* Product Gallery: Add cropped image support
* Clean up
* Create the crop dimensions based on smallest original image dimension
* Bail if image is not available
* Add `data-wc-init` directive to Interactivity API
* Add support for variation image updates on the Product Gallery block
* Watch correct form based on the product id
* Fix php cs error
* Fix php cs error
* Prevent adding wc-init to non-variable products
* Remove authors filter from Product Collection block
* Remove author filed in query
* Add back the author query argument in the final query builder
---------
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>