Last active
July 18, 2023 16:58
-
-
Save nielslange/9e95ac8245ee358f6defea0c1606be7c to your computer and use it in GitHub Desktop.
Proceed to Checkout Button Link filter » proceedToCheckoutButtonLink
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( | |
| ( item ) => item.name === 'Sunglasses' | |
| ); | |
| // Return the default value if sunglasses is not in the cart. | |
| if ( ! isSunglassesInCart ) { | |
| return value; | |
| } | |
| return '/sunglasses-checkout'; | |
| } | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment