run php after product added 1

run php after product added

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
        ?>
            
        

Here is what the above code is Doing:
1. We hook into the 'added_to_cart' event.
2. We use the 'console.log' function to display a message in the browser console.
3. We use the 'is_shop()' conditional tag to target only the shop page.

Now, when you add a product to cart, you should see the message 'EVENT: added_to_cart' in your browser console.

You can use the same technique to hook into other events.

Here's a list of all the available events:

added_to_cart
removed_from_cart
added_to_wishlist
removed_from_wishlist
added_to_compare
removed_from_compare
updated_item_quantity
updated_shipping_method
updated_payment_method
updated_checkout
updated_order_review
updated_customer_details
updated_addresses
updated_cart_totals
updated_shipping_methods
updated_variation
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated_item_quantity
updated

Similar Posts