This PR adds a block-enabled theme with templates for WooCommerce
which is intended to be used when testing the more complex scenarios
such as template fallbacks.
Additionally, since theme-dependent logic seems to be becoming more
and more useful (see woocommerce/woocommerce-blocks#5913), this PR also adds a utility function used to
explicitly declare theme dependencies of a test (`useTheme`).
Said function will activate the theme before running a given suite and then
reactivate the previous theme, as to make sure to not have any side-effects
(such as the ones described in woocommerce/woocommerce-blocks#5913 above).
Closeswoocommerce/woocommerce-blocks#5660
* Avoid calling plugin_dir_url a lot
* Fix crash if woocommerce admin is disabled
With Woocommerce's PR
https://github.com/woocommerce/woocommerce/pull/31991 applied, if
woocommerce admin is disabled via the woocommerce_admin_disabled
filter, the InboxNotifications block could crash.
* Fix coding style
* Simplify code path
* Remove unused initialization
* Introduce 'wooocommerce_store_api_validate_cart' action
This action can be used by third party developers to add extra 'errors' in cart route responses. This is meant to function as a replacement of the legacy 'woocommerce_check_cart_items' hook.
* Introduce a new 'wooocommerce_blocks_draft_order_updated' action
The new action can be used to modify the finalized draft order object.
Additionally, developers can use it to throw a RouteException in order to prevent access to the checkout block.
The PR also shuffles some existing code that checks the order instance and sets the draft order ID before the 'woocommerce_blocks_checkout_update_order_meta' gets fired.
* Fix PHPCS
* Revert changes to Checkout route
* Add some extra content to the 'woocommerce_blocks_checkout_update_order_meta' docblock on the effect of exceptions thrown from callbacks
* Add __experimental prefix to 'wooocommerce_store_api_validate_cart' action
* Remove long ooo
* Add example
* Refactor cart error getters as wrappers to the validate functions
* Refactor stock_exceptions_to_wp_errors to return a single wp error.
* Add type hint in custom exception
* Fix namespace versioning and some minor improvements
* Move InvalidCartException catcher from AbstractCartRoute to AbstractRoute
* Introduce the __experimental_woocommerce_store_api_cart_errors filter
* Handle all notices and group them into a single WP_Error instance
* Cleanup doc and update example
* Cleanup NoticeHandler
* Fix doc
* Fix WP_Error namespace
* Update NoticeHandler unit tests
* Fix Unit tests typo
* Add docs to tests to bypass precommit scripts
* Refactor wp error grouping with merge_from
* Remove previous cart getters and refactor the get_cart_errors
* Fix CartSchema error getter and minor fixes
* Revert NoticeHandler exception namespace
* Unit test fix for get_cart_errors
* Switch back to do_action
* Update the example doc
* Duplicate use statement
* Update docblock in validate_cart() method for validation hooks
* Update action docs
* Remove __experimental prefix
Co-authored-by: Manos Psychogyiopoulos <psyx@somewherewarm.com>
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* templates README and block-template-controller README
* Add execution scenario to block template controller readme
* Amend return value to block template controller readme
* Add source file link to block template controller docs
* LegacyTemplate.php overview
* Legacy Template JavaScript block README
* Update requirements of templates feature
* Doc updates based on feedback, and change Legacy Template references to Classic Template in anticipation of naming convention updates
* Update classic-template.md README
* Reword part of the add_block_templates section
* Update assets/js/blocks/legacy-template/README.md
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* Update docs/readme.md
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* Update docs/templates/README.md
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* Update docs/templates/README.md
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* Update README for blocktemplatecontroller
* Review feedback for Woo FSE technical documentation
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
* Empty commit for release pull request
* Add Changelog to readme.txt
* Update allow-plugins list as release build doesnt work otherwise
* Add testing instructions
* Update testing instructions
* Update version number in README.md
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
* Add phpcodesniffer to Composer allow-plugins
* Bumping version strings to new version.
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Michael P. Pfeiffer <michael@cssconf.eu>
Co-authored-by: Michael P. Pfeiffer <frontdevde@users.noreply.github.com>
Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com>
* Add margin support on the Product Image block woocommerce/woocommerce-blocks#5671
Add margin support on the Product Image block
* fix tests
* more specific selector
* update mixin
* Add Global Styles support to product price block
- This comes sat a cost of losing control over regular vs sale price
- This includes refactor of attribute from align to textAlign
which is a reserved supports feature attribute and textAlign is
used across the Gutenberg project
* Add experimentalSelector and register as PHP block
This is required to make the GlobalStyles work inside of
the InnerContent block. Ie. All Products block.
* move sharedConfig supports outside of isFeaturePluginBuild check
* restore regularPriceClassName
* remove douplicated block registration on php side
* Add constants for C & C pages in our E2E tests
Inspired by WC E2E this will avoid going to admin to find out the links for these pages.
* Select C & C pages by using the main navigation links
* Fix function calls
* Revert back to using constants for C & C block pages' URLs
reverts 9587a0bd5efa5d97b484cd8d1bf927ff50f8e014 and bd7e2f996792d887756c0a0f4a10e6886574e77b
* Revise Storybook entries for Checkout Blocks/totals components
Revise Storybook entries for Checkout Blocks/totals components
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* Fix a typo in the Item label value
* set disable value for description and disable control for 'showRateAfterTaxName' prop
Co-authored-by: Luigi Teschio <gigitux@gmail.com>
* Add Global Styles support for the Add To Cart Button block woocommerce/woocommerce-blocks#5666
Add Global Styles support for the Add To Cart Button block
* remove support to font size
* try: fix the style override issue for add to cart button (https://github.com/woocommerce/woocommerce-blocks/pull/5843)
* restore typography support
* fix font weight
* add support for font weight
Co-authored-by: Tung Du <dinhtungdu@gmail.com>
* Ensure screenshots can be attached in jest html report
* Force tests to fail in ci
* Console log for testing
* Console log for testing
* Check on hook failure as well as test failure
* Revert "Force tests to fail in ci"
This reverts commit 6efebd63bba4792214f5b24824fb405cf38b1367.
* Take full page screenshot only when error type is not hook_failure
* Remove console log
* adds toolbar option to remove custom image
removing custom image will reset it back to the default
product image if available
* update copy as per discussion
went with just Reset as it is commonly used in WordPress
and will have translation available
* Add address-related items to wc/store/cart data store
* include shippingAsBilling in return value of useCustomerData
* Add useUpdateCustomerData hook
This allows us to have a single hook responsible for updating the customer information on the server.
* Add useUpdateCustomerData hook in Checkout block
* Remove the updating customer data work from the useCustomerData hook
* Remove shippingAsBilling from previousCustomerData ref type
* Add useShippingAsBillingCheckbox hook
* Control shippingAsBilling from single hook
* Remove checkbox handling from useCheckoutAddress
* Remove CustomerDataContext typedef
* Merge with woocommerce/woocommerce-blocks#5810 changes
* Move shipping as billing to checkout state context provider
* Unused import
* Subscribe to changes
* Only receiveCartContents when updating customer data via checkout
* Cache customerDataToUpdate
* rename debounced function
* Combine customerDataType and customerDataContextType
* Change case of CustomerDataType
* debouncedUpdateCustomerData typo
* Fix notice context
* Clean up inline docs for push changes
* Comment on dirty state
* Phone is always set
* shippingAddress is never undefined
* setBillingPhone
* receiveCartContents explanation
* Tweak customerData to avoid null
* useShippingAsBilling
Co-authored-by: Thomas Roberts <thomas.roberts@automattic.com>
* fix Global Styles for Product Image, Product Category List and Product Tag List blocks
fix Global Styles for Product Image, Product Category List and Product Tag List blocks
* Block style font-size was applying wrong value for fontSize
* Add missing __experimentalSkipSerialization to Category List
Co-authored-by: Tomasz Tunik <tomasztunik@gmail.com>
* Pass context information about containing block to the existing Slots
* Fix images added to the Slots docs
* Use the parent's block name for the context prop passed to Slot fills