This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust cart item price of the order summary items. | |
| registerCheckoutFilters( 'example-extension', { | |
| cartItemPrice: ( value, extensions, args ) => { | |
| // Return early since this filter is not being applied in the Summary context. | |
| // We must return the original value we received here. | |
| if ( args?.context !== 'summary' ) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust item name of the order summary items. | |
| registerCheckoutFilters( 'example-extension', { | |
| itemName: ( value, extensions, args ) => { | |
| // Return early since this filter is not being applied in the Summary context. | |
| // We must return the original value we received here. | |
| if ( args?.context !== 'summary' ) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust allowed cart and checkout inner block types. | |
| registerCheckoutFilters( 'example-extension', { | |
| additionalCartCheckoutInnerBlockTypes: ( value, extensions, { block } ) => { | |
| // Remove the ability to add `core/separator` | |
| value = value.filter( ( blockName ) => blockName !== 'core/separator' ); | |
| // Add core/quote to any inner block area. | |
| value.push( 'core/quote' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust the place order button label. | |
| registerCheckoutFilters( 'example-extension', { | |
| placeOrderButtonLabel: () => '💰 Pay now 💰' | |
| } ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust the proceed to checkout button link. | |
| registerCheckoutFilters( 'example-extension', { | |
| proceedToCheckoutButtonLink: ( value, extensions, { cart } ) => { | |
| if ( ! cart.items ) { | |
| return value; | |
| } | |
| const isSunglassesInCart = cart.items.some( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust the proceed to checkout button label. | |
| registerCheckoutFilters( 'example-extension', { | |
| proceedToCheckoutButtonLabel: ( value, extensions, { cart } ) => { | |
| if ( ! cart.items ) { | |
| return value; | |
| } | |
| const isSunglassesInCart = cart.items.some( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust sale badge price format of the cart line items. | |
| registerCheckoutFilters( 'example-extension', { | |
| saleBadgePriceFormat: ( value, extensions, args ) => { | |
| // Return early since this filter is not being applied in the Cart context. | |
| // We must return the original value we received here. | |
| if ( args?.context !== 'cart' ) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Show remove item link of the cart line items. | |
| registerCheckoutFilters( 'example-extension', { | |
| showRemoveItemLink: ( value, extensions, args ) => { | |
| // Return early since this filter is not being applied in the Cart context. | |
| // We must return the original value we received here. | |
| if ( args?.context !== 'cart' ) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust cart item class of the cart line items. | |
| registerCheckoutFilters( 'example-extension', { | |
| cartItemClass: ( value, extensions, args ) => { | |
| // Return early since this filter is not being applied in the Cart context. | |
| // We must return the original value we received here. | |
| if ( args?.context !== 'cart' ) { | |
| return value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { registerCheckoutFilters } = window.wc.blocksCheckout; | |
| // Adjust cart item price of the cart line items. | |
| registerCheckoutFilters( 'example-extension', { | |
| cartItemPrice: ( value, extensions, args ) => { | |
| // Return early since this filter is not being applied in the Cart context. | |
| // We must return the original value we received here. | |
| if ( args?.context !== 'cart' ) { | |
| return value; | |
| } |