* Fix infinite loop (range error) on subscribe callback.
* Replace getEditedPostContext with getEditedPostId to retrieve the templateId from the Site Editor for 6.1.1 compatibility
---------
Co-authored-by: tjcafferkey <tjcafferkey@gmail.com>
* Don't use withProductDataContext in Sale Badge block
There was no information about product passed to the block, so it fetched information about all products which then wasn't even used
* Pass necessary props to the Sale Badge so it doesn't overfetch unnecessary data
* Move the import to the previous place
* Single Product Template - Compatibility Layer: don't skip custom HTML (https://github.com/woocommerce/woocommerce-blocks/pull/9075)
* Fix: tax_query should be calculated only if __woocommerceAttributes is valid (https://github.com/woocommerce/woocommerce-blocks/pull/9049)
This commit refactors the update_rest_query method in the ProductQuery.php file to improve code readability. It simplifies conditional expressions by introducing variables for clarity, and uses ternary operators to streamline the logic.
* Blockfied Single Product Template: Add support for template for specific product (https://github.com/woocommerce/woocommerce-blocks/pull/9069)
* Product Price Block: remove ProductSelector (https://github.com/woocommerce/woocommerce-blocks/pull/8980)
* Empty commit for release pull request
* Make Woo_Directive_Store PHP 7.3 compatible (https://github.com/woocommerce/woocommerce-blocks/pull/9033)
* update version
* add changelog
* add testing instructions
* update zip link file testing
* Update docs/internal-developers/testing/releases/1001.md
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
---------
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
Co-authored-by: Manish Menaria <the.manish.menaria@gmail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Viktor Szépe <viktor@szepe.net>
Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
* Add color, typography, and spacing support to Product SKU block
This commit introduces a new file `supports.ts` for the Product SKU block in the WooCommerce Blocks plugin, which adds color, typography, and spacing support. The following configuration has been added:
1. In `assets/js/atomic/blocks/product-elements/sku/supports.ts`, a new `supports` object is created, which extends the shared configuration and adds support for the following properties:
- `text` and `background` color
- `fontSize`, `lineHeight`, `__experimentalFontWeight`, `__experimentalFontFamily`, `__experimentalFontStyle`, `__experimentalTextTransform`, `__experimentalTextDecoration`, and `__experimentalLetterSpacing` for typography
- `margin` and `padding` for spacing
* Add color, typography, and spacing support for Product SKU block in All Products block
This commit extends the support for color, typography, and spacing to the Product SKU block when used within the All Products block. The following changes have been made:
1. In `assets/js/atomic/blocks/product-elements/sku/block.tsx`, the `useColorProps`, `useSpacingProps`, and `useTypographyProps` hooks are imported and used to add the appropriate className and style properties to the rendered SKU element.
2. In `assets/js/atomic/blocks/product-elements/sku/edit.tsx`, the `style` property is separated from `useBlockProps()` and used directly on the `div` element for the SKU block.
* Add server-side rendering class for Product SKU Gutenberg block
This commit adds the ".wp-block-woocommerce-product-sku" class to the Product SKU Gutenberg block for server-side rendering purposes. The inclusion of this class ensures consistent styling between the editor and the front-end view of the block, providing a seamless experience for users.
The class name is generated based on the Gutenberg block prefix "wp-block", the namespace "woocommerce", and the block name "product-sku", creating a unique and identifiable class for the block. This class enables developers to target the block specifically in both the editor and front-end styles, maintaining the integrity of the block's appearance and functionality across different environments.
By adding this class to the server-side rendered version of the block, we ensure a unified and coherent styling experience throughout the block's usage.
* Fix minor issues
* Gate only experimental features behind isFeaturePluginBuild flag
This commit refactors the Product SKU block supports to enable color, typography, and spacing features for all builds, while keeping experimental features specific to the feature plugin build. It also adds necessary lint and TypeScript error handling for the experimental spacing API.
* Add overflow-wrap to Product SKU block and update comment
This commit adds the overflow-wrap property to the Product SKU block styles to handle long SKU values gracefully.
It also updates the comment for the experimental spacing API to better reflect the usage check.
* Refactor Product SKU block classname and style handling
This commit refactors the Product SKU block classname and style handling. It combines classnames for better readability and removes the hardcoded textTransform style in favor of default styles.
This also fix the issue where textTransform style was not working as expected.
* Add support for color, typography and spacing to stock indicator block
This commit updates the stock-indicator block support in the woocommerce-blocks repository. It includes the following changes:
- Added support for background color, line height, and various experimental typography features.
- Conditionally included support for margin and padding based on the availability of the __experimentalGetSpacingClassesAndStyles function from the @wordpress/block-editor package.
These updates provide more customization options for the stock-indicator block, allowing users to better match the appearance of this element to their site's design.
* Refactor stock text generation and apply minor style adjustments
This commit introduces a new function, `getTextBasedOnStock`, which handles the generation of stock text based on the stock information provided. It replaces the previous `lowStockText` and `stockText` functions, making the code more readable and maintainable.
In addition, minor adjustments to the class name handling have been made to simplify the code and ensure consistent styling when used inside the All Products block.
In the `edit.tsx` file, the `useBlockProps` function call has been updated to include the default `wc-block-components-product-stock-indicator` class name, ensuring it is always applied.
* Remove redundant block type supports in ProductStockIndicator
This commit removes the redundant get_block_type_supports() method from the ProductStockIndicator.php file, as it is no longer needed. The block type supports are now handled in the frontend.
This commit refactors the update_rest_query method in the ProductQuery.php file to improve code readability. It simplifies conditional expressions by introducing variables for clarity, and uses ternary operators to streamline the logic.
* Set up Playwright
* Use caching in GitHub Actions
* Update tests/e2e-pw/README.md
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Rename “{blockName}” to “{blockName} block”
* Disable “no-console” for setup and teardown files
* Remove obsolete log and adjusted disabled ESLint definition
* Remove conditional logic from actions/upload-artifact
---------
Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
* Mini Cart template part: give user customized template priority over theme template
* Use get_block_templates_from_db() from BlockTemplateUtils
* Add deprecation notice
* Update the docs regarding Product Collection Data endpoint in Store API
* Add the dots at the end of sentences
* Remove the and from Product Collection Data endpoint docs as it's covered in Products endpoint
* Create the counter block and the header pattern
* Change the pattern to an inner block
* Allow customizing item counter block
* Rename block
* Allow removing the items counter block
* Add padding controls
* Preload new blocks
* Add title block back from the inserter
* Move h2 tag to the parent title
* Align items at the bottom
* Unify styles
* Add title class in the editor
* Prevent removing title blocks
* Disallow unlocking and inserter
* Disallowing moving blocks
* Enable the attribute lookup direct updates settings
We are importing products using the batch api and we need the lookup tables
to be updated immediately for our tests to work. Enabling this setting will
do that, instead of doing it asynchronously.
* Fix customer account test classes
* Increase timeout limit for failing tests
---------
Co-authored-by: roykho <roykho77@gmail.com>
* Introduce the new get_attribute_and_meta_counts method.
* Ensure that if no term_slug or term_id is found for counting, the default list with all terms (with count equal zero) is returned instead.
* update conditional for the slug, the empty state for requests without filter attributes and the condition query for 'and'
* Introduce the get_terms_list method.
* Remove the legacy get_attribute_counts method and update its calls to rely on the new get_attribute_and_meta_counts method instead.
* Update the query to ensure that if a parent product has multiple identical attributes, they are counted once.
* Update to start relying on the get_product_by_metas method for counting product metas
* Add a new where_clause to only include product metas and attributes in the macro query if they are not empty.
* Add wpdb->prepare to the macro query and the get_terms_list method.
* Replace the raw atomic query for fetching the filtered terms with the new get_product_by_filtered_terms method.
* Update the request params for the get_attribute_and_meta_counts method.
* Update the request params for the product metas (min and max price).
* Update the query and returned value on get_terms_list.
* Update the validation for returning the default counts when no values are filtered.
* Update the query on get_terms_list to use ->prefix
* Update the variable for the query to rely on the filtered one. Update the min_price and max_price format on get_product_by_metas.
* Ensure the get_product_by_filtered_terms method is triggered for each one of the filtered terms and update the macro query to include those term ids on the WHERE clause.
* Make adjustments for the 'and' condition to work as expected.
* Ensure the queryState.attributes is properly added as a param to the API request to correctly fetch the attribute count data.
* Ensure the get_product_by_metas method is only triggered when at least one of the metas in the request is not empty.
* Join type update: for the 'and' (all) filter condition, items with the count zero are not displayed.
* wpdb prepare the where clauses
* Update the get_product_by_filtered_terms query wpdb prepare params
* update the get_product_by_metas method's where clause preparation.
* Update the where clause preparation for get_attribute_and_meta_counts so we don't rely on interpolated variables anymore.
* Adjust the get_attribute_and_meta_counts method for usage alongside the rating filter.
* Adjust the query for fetching the attribute counts for filtered ratings.
* Add support for the filter by stock.
* Ensure the product attribute counts are correct if the parent product receives a rating.
* Ensure product_or_parent_id is used only when the filter by rating is used, not affecting price or stock filters.
* Add the missing else condition.
* Enable caching.
* Address CR
* Update query for average rating.
* remove file accidentally commited.
* When multiple ratings are selected, make sure the where clause is updated accordingly for each one of them.
* Start updating the stock_status logic to account for when multiple options are selected by the user.
* Ensure the counts are properly updated when more than one stock status is selected.
* Ditch the is_array condition for the average_rating counts as is always an array.
* Deprecate the second param attributes for the get_attribute_counts method.
* Add the filtered_attribute to the transient_key
* Bypass cache if WP_DEBUG is enabled.
* Update formatting for macro query.
* Fix mixed tabs spaces on query
* Fix PHP unit tests for the new attribute counts.
* Update spacing/formatting for SQL queries.
* Minor: update indentation for the main SQL query
---------
Co-authored-by: roykho <roykho77@gmail.com>
* Introduce the new get_attribute_and_meta_counts method.
* Ensure that if no term_slug or term_id is found for counting, the default list with all terms (with count equal zero) is returned instead.
* update conditional for the slug, the empty state for requests without filter attributes and the condition query for 'and'
* Introduce the get_terms_list method.
* Remove the legacy get_attribute_counts method and update its calls to rely on the new get_attribute_and_meta_counts method instead.
* Update the query to ensure that if a parent product has multiple identical attributes, they are counted once.
* Update to start relying on the get_product_by_metas method for counting product metas
* Add a new where_clause to only include product metas and attributes in the macro query if they are not empty.
* Add wpdb->prepare to the macro query and the get_terms_list method.
* Replace the raw atomic query for fetching the filtered terms with the new get_product_by_filtered_terms method.
* Update the request params for the get_attribute_and_meta_counts method.
* Update the request params for the product metas (min and max price).
* Update the query and returned value on get_terms_list.
* Update the validation for returning the default counts when no values are filtered.
* Update the query on get_terms_list to use ->prefix
* Update the variable for the query to rely on the filtered one. Update the min_price and max_price format on get_product_by_metas.
* Ensure the get_product_by_filtered_terms method is triggered for each one of the filtered terms and update the macro query to include those term ids on the WHERE clause.
* Make adjustments for the 'and' condition to work as expected.
* Ensure the queryState.attributes is properly added as a param to the API request to correctly fetch the attribute count data.
* Ensure the get_product_by_metas method is only triggered when at least one of the metas in the request is not empty.
* Join type update: for the 'and' (all) filter condition, items with the count zero are not displayed.
* wpdb prepare the where clauses
* Update the get_product_by_filtered_terms query wpdb prepare params
* update the get_product_by_metas method's where clause preparation.
* Update the where clause preparation for get_attribute_and_meta_counts so we don't rely on interpolated variables anymore.
* Adjust the get_attribute_and_meta_counts method for usage alongside the rating filter.
* Adjust the query for fetching the attribute counts for filtered ratings.
* Add support for the filter by stock.
* Ensure the product attribute counts are correct if the parent product receives a rating.
* Ensure product_or_parent_id is used only when the filter by rating is used, not affecting price or stock filters.
* Add the missing else condition.
* Enable caching.
* Address CR
* Update query for average rating.
* remove file accidentally commited.
* When multiple ratings are selected, make sure the where clause is updated accordingly for each one of them.
* Start updating the stock_status logic to account for when multiple options are selected by the user.
* Ensure the counts are properly updated when more than one stock status is selected.
* Ditch the is_array condition for the average_rating counts as is always an array.
* Deprecate the second param attributes for the get_attribute_counts method.
* Add the filtered_attribute to the transient_key
* Bypass cache if WP_DEBUG is enabled.
* Update formatting for macro query.
* Fix mixed tabs spaces on query
* Update spacing/formatting for SQL queries.
* Minor: update indentation for the main SQL query
---------
Co-authored-by: roykho <roykho77@gmail.com>
* Add block minimal structure
* Add Single Product block icon
* Add usesContext to block.json
* Add Save function to Single Product Block registration settings
* Add InnerBlocks template to Editor for Single Product Block
* Add Product selector to Single Product block
* Add withProduct HOC to the block editor
* Add save function to the Single Product block
* Add renderOnServerSide attribute to Product image
This attribute is used to determine if the product image should be rendered on the server side or not. This is needed because the product image is not rendered on the server side by default, but we want to render it on the server side when it is inside the Single Product block.
* Add renderOnServerSide attribute to Product Category List block
* Add renderOnServerSide attribute to Product Price block
* Add renderOnServerSide attribute to Product Rating block
* Add renderOnServerSide attribute to Product Stock Indicator block
* Add renderOnServerSide attribute to Product Summary block
* Add renderOnServerSide attribute to Product Tag List block
* Add renderOnServerSide attribute to Product Title block
* Add renderOnServerSide attribute to Product Add to Cart, Sales Badge and Sku block
* Reuse editor code for Single Product block
* Add Props interface to Single Product Server Side Editor
* Add render_block_context hook to SingleProductServerSide block
* Fix Single Product Server Side block that was not appearing in the block inserter
* Fix bug where the correct product was not being displayed on the frontend
* Remove Single Product Block
* Add Product title and product summary variations
* Add Add To Cart Form and Product Meta blocks to the Single Product Block
* remove more files that belong the Single Product block
* fix php linter error
* wrap up Single Product Block
* Fix issue preventing the block from working on the Single Product Template
* Fix update context function for Single Product block
* Replace Single Product block title
* Replace global $post only for Single Product inner blocks
* Remove unnecessary var_dump statement
* Improve documentation for the Single Product block
* fix registration: add-to-cart-form and product-meta blocks
* Improve documentation for Single Product block
* Fix lint error related to imports
* Remove query monitor debug code
* Remove unnecessary `renderOnServerSide` attribute from product elements
* Fix return type for the Save function of the Product Elements blocks
* Fix return type for the Save function of the Product Title block
* Add scss file for Single Product block
* Fix PHP coding standards
* Fix php coding standards
* Remove internal dependencies section duplication
* Replace .wc-block with .wc-block-editor- styles
According to the naming convention for this project (https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/contributors/contributing/coding-guidelines.md#naming) we should be using the `.wc-block-editor-` prefix for styles that are only used in the editor.
* Solve style for the Edit card component in the Single Product block
* Fix error preventing Block Control from being displayed
* Make the Product title to be a link by default
* Fix PHP Coding Standards
* Fix PHP Code Standards
* Fix php cs issues
* Fix issue with php cs
* Remove unnecessary comment
* Remove unused Icon import
* Remove unnecessary dot from the className attributes in the Single Product Block
* Replace metadata.name with metadata.title in the Editor file
* Ignore phpcs rule
* Add new attributes to the Attributes interface of the Price block
* Fix typescript errors on the Product Meta block
* Fix ts errors on Single Product editor
* Fix ts errors on layout-editor.tsx
* Fix ts errors in Single Product index file
* Fix ts errors on add to cart form index file
* Fix unsupported block error when using inner blocks outside the Single Product template
* Fix unsupported block error for the Single Product block when editing Posts/Pages
* Remove unnecessary JSDoc types
* Remove unnecessary APIError component
* Replace global $post only when rendering a `core/post-excerpt` block
* Fix php cs errors
* Put the Single Product block behind an experimental flag
* Enable Single Product block preview
---------
Co-authored-by: Luigi <gigitux@gmail.com>
* Add block minimal structure
* Add Single Product block icon
* Add usesContext to block.json
* Add Save function to Single Product Block registration settings
* Add InnerBlocks template to Editor for Single Product Block
* Add Product selector to Single Product block
* Add withProduct HOC to the block editor
* Add save function to the Single Product block
* Add renderOnServerSide attribute to Product image
This attribute is used to determine if the product image should be rendered on the server side or not. This is needed because the product image is not rendered on the server side by default, but we want to render it on the server side when it is inside the Single Product block.
* Add renderOnServerSide attribute to Product Category List block
* Add renderOnServerSide attribute to Product Price block
* Add renderOnServerSide attribute to Product Rating block
* Add renderOnServerSide attribute to Product Stock Indicator block
* Add renderOnServerSide attribute to Product Summary block
* Add renderOnServerSide attribute to Product Tag List block
* Add renderOnServerSide attribute to Product Title block
* Add renderOnServerSide attribute to Product Add to Cart, Sales Badge and Sku block
* Reuse editor code for Single Product block
* Add Props interface to Single Product Server Side Editor
* Add render_block_context hook to SingleProductServerSide block
* Fix Single Product Server Side block that was not appearing in the block inserter
* Fix bug where the correct product was not being displayed on the frontend
* Remove Single Product Block
* Add Product title and product summary variations
* Add Add To Cart Form and Product Meta blocks to the Single Product Block
* remove more files that belong the Single Product block
* fix php linter error
* wrap up Single Product Block
* Fix issue preventing the block from working on the Single Product Template
* Fix update context function for Single Product block
* Replace Single Product block title
* Replace global $post only for Single Product inner blocks
* Remove unnecessary var_dump statement
* Improve documentation for the Single Product block
* fix registration: add-to-cart-form and product-meta blocks
* Improve documentation for Single Product block
* Fix lint error related to imports
* Remove query monitor debug code
* Remove unnecessary `renderOnServerSide` attribute from product elements
* Fix return type for the Save function of the Product Elements blocks
* Fix return type for the Save function of the Product Title block
* Add scss file for Single Product block
* Fix PHP coding standards
* Fix php coding standards
* Remove internal dependencies section duplication
* Replace .wc-block with .wc-block-editor- styles
According to the naming convention for this project (https://github.com/woocommerce/woocommerce-blocks/blob/trunk/docs/contributors/contributing/coding-guidelines.md#naming) we should be using the `.wc-block-editor-` prefix for styles that are only used in the editor.
* Solve style for the Edit card component in the Single Product block
* Fix error preventing Block Control from being displayed
* Make the Product title to be a link by default
* Fix PHP Coding Standards
* Fix PHP Code Standards
* Fix php cs issues
* Fix issue with php cs
* Remove unnecessary comment
* Remove unused Icon import
* Remove unnecessary dot from the className attributes in the Single Product Block
* Replace metadata.name with metadata.title in the Editor file
* Ignore phpcs rule
* Add new attributes to the Attributes interface of the Price block
* Fix typescript errors on the Product Meta block
* Fix ts errors on Single Product editor
* Fix ts errors on layout-editor.tsx
* Fix ts errors in Single Product index file
* Fix ts errors on add to cart form index file
* Fix unsupported block error when using inner blocks outside the Single Product template
* Fix unsupported block error for the Single Product block when editing Posts/Pages
* Remove unnecessary JSDoc types
* Remove unnecessary APIError component
* Replace global $post only when rendering a `core/post-excerpt` block
* Fix php cs errors
* Put the Single Product block behind an experimental flag
* Fix error occurring when trying to access ancestor of an undefined block settings
* Fix Product Image appearing with different size on the Frontend
* Fix PHP Code Standards errors
* Remove JS Doc from shared-product-control.tsx
* Fix single-product-frontend.js 404 error
* Fix error 'Block names must be string' when adding Single Product block
* Add todo comment to state the temporary solution used in the Single Product block
* Set imageSizing attribute on Product Query and Single Product blocks
* Rename values for image size options in the product image block
The previous allowed values were 'cropped' and 'full-size'. The new values are 'thumbnail' and 'single' which are similar to the values used in WooCoomerce.
WooCommerce uses 'woocommerce_thumbnail', 'woocommerce_gallery_thumbnail' and 'woocommerce_single' for images sizes. The 'woocommerce_single' size is used for the Single Product page and the 'woocommerce_thumbnail' size is used for the product grid.
* Fix Related Products image to show as a thumbnail instead of the full size
* Fix PHP CS error
---------
Co-authored-by: Luigi <gigitux@gmail.com>