Created
September 4, 2021 22:54
-
-
Save warnakey/e6148487398e4c40b45363e6549bbb13 to your computer and use it in GitHub Desktop.
WooCommerce Function Only Applied To A Specific Page
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
/* This goes in your functions.php file */ | |
/* When the woocommerce cart is updated on the page with ID 353034, print "test" at the top of the page */ | |
/* This is an example of using 2 functions together with an action hook */ | |
function action_woocommerce_cart_updated() { | |
add_action('get_header', function() { | |
if (is_page('353034')) { | |
echo 'test'; | |
} | |
}); | |
}; | |
add_action( 'woocommerce_cart_updated', 'action_woocommerce_cart_updated', 10, 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment