Last active
July 18, 2023 16:58
-
-
Save nielslange/c6227dc32a16ee846bdfd5241844d5a4 to your computer and use it in GitHub Desktop.
Proceed to Checkout Button Label filter » proceedToCheckoutButtonLabel
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( | |
| ( 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