Skip to content

Instantly share code, notes, and snippets.

@NickGreen
Created July 19, 2018 15:30
Show Gist options
  • Save NickGreen/c424091f2ba7fe3a4164c2ecb1e5975c to your computer and use it in GitHub Desktop.
Save NickGreen/c424091f2ba7fe3a4164c2ecb1e5975c to your computer and use it in GitHub Desktop.
Added to cart
add_action('wp_footer','custom_jquery_add_to_cart_script');
function custom_jquery_add_to_cart_script(){
if ( is_shop() || is_product_category() || is_product_tag() ): // Only for archives pages
?>
<script type="text/javascript">
// Ready state
(function($){
$( document.body ).on( 'added_to_cart', function(){
console.log('EVENT: added_to_cart');
});
})(jQuery);
</script>
<?php
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment