Skip to content

Instantly share code, notes, and snippets.

@warnakey
Created September 4, 2021 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warnakey/e6148487398e4c40b45363e6549bbb13 to your computer and use it in GitHub Desktop.
Save warnakey/e6148487398e4c40b45363e6549bbb13 to your computer and use it in GitHub Desktop.
WooCommerce Function Only Applied To A Specific Page
/* 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