![]() |
Hi Members,
I am looking for a solution here.
I have a woo-commerce website. I am looking to integrate webengage with it. I need to pass an event to webengage called "Added to cart" along with the product details that have been added to cart ( like product name, quantity, sku, sale price, reg price etc..)
My site is using Ajax and I am not sure how to fire script after product is added to cart via ajax along with the product data as mentioned above.
My site products are more of variation products, So I need to pass variation name aloing with the product title, price, sku, reg price, sale price, sku.
Any help is much appreciated. Thanks!
Solution - 1WooCommerce offers a hook that fires when an item is added to the cart. It is: This hook provides the following variables: $cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data So you can use them in your custom function. To send data to any API from this function, you can use wp_remote_post or wp_remote_get methods. Here is a sample code that sends data after product is added to the cart: Hope you will find this useful to send your data to WebEngage API. Solution - 2Are y ou still looking for help? |
Wordpress |
Type: | Code Example |
Category: | Coding |
Sub Category: | Code Example |
Uploaded by: | Admin |
Views: | 34 |