run php after product added

Solutions on MaxInterview for run php after product added by the best coders in the world

showing results for - "run php after product added"
Beatrice
28 Jan 2020
1add_action('wp_footer','custom_jquery_add_to_cart_script');
2function custom_jquery_add_to_cart_script(){
3    if ( is_shop() || is_product_category() || is_product_tag() ): // Only for archives pages
4        ?>
5            <script type="text/javascript">
6                // Ready state
7                (function($){ 
8
9                    $( document.body ).on( 'added_to_cart', function(){
10                        console.log('EVENT: added_to_cart');
11                    });
12
13                })(jQuery); // "jQuery" Working with WP (added the $ alias as argument)
14            </script>
15        <?php
16    endif;
17}
similar questions
queries leading to this page
run php after product added