Skip to content

Instantly share code, notes, and snippets.

@nielslange
Last active July 18, 2023 16:58
Show Gist options
  • Select an option

  • Save nielslange/c6227dc32a16ee846bdfd5241844d5a4 to your computer and use it in GitHub Desktop.

Select an option

Save nielslange/c6227dc32a16ee846bdfd5241844d5a4 to your computer and use it in GitHub Desktop.
Proceed to Checkout Button Label filter » proceedToCheckoutButtonLabel
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(
( item ) => item.name === 'Sunglasses'
);
// Return the default value if sunglasses is not in the cart.
if ( ! isSunglassesInCart ) {
return value;
}
return 'Proceed to 😎 checkout';
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment