The documentation for WooCommerce Blocks has moved to the WooCommerce monorepo.
Please refer to the documentation in the new location as the files in this repository will no longer be updated and the repository will be archived.
Miscellaneous utility functions for dealing with checkout functionality.
When executed, this will call the cart/extensions REST API endpoint. The new cart is then received into the client-side store.
// Aliased import
import { extensionCartUpdate } from '@woocommerce/blocks-checkout';
// Global import
// const { extensionCartUpdate } = wc.blocksCheckout;
extensionCartUpdate( {
namespace: 'extension-unique-namespace',
data: {
key: 'value',
},
} );
The following options are available:
Args to pass to the Rest API endpoint. This can contain data and a namespace to trigger extension specific functionality on the server-side. You can read more about this, and the server-side implementation, in this doc.
Ensures that a given value contains a string, or throws an error.
// Aliased import
import { mustContain } from '@woocommerce/blocks-checkout';
// Global import
// const { mustContain } = wc.blocksCheckout;
mustContain( 'This is a string containing a <price />', '<price />' ); // This will not throw an error
mustContain( 'This is a string', '<price />' ); // This will throw an error
The following options are available:
Value being checked. Must be a string.
What value must contain. If this is not found within value
, and error will be thrown.
We're hiring! Come work with us!
🐞 Found a mistake, or have a suggestion? Leave feedback about this document here.