Skip to content

Commit

Permalink
PRESS4-401 Added a event when an item is added to the cart
Browse files Browse the repository at this point in the history
  • Loading branch information
mamatharao05 committed Nov 16, 2023
1 parent c244dd5 commit 4be81f0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions includes/Listeners/Commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function register_hooks() {
add_filter( 'newfold_wp_data_module_cron_data_filter', array( $this, 'orders_count' ) );
add_filter('woocommerce_before_cart', array( $this, 'site_cart_views'));
add_filter('woocommerce_before_checkout_form', array( $this, 'checkout_views'));
add_action('woocommerce_cart_updated',array( $this, 'site_product_add_to_cart_data'));
add_filter('woocommerce_thankyou', array( $this, 'thank_you_page'));
add_filter( 'pre_update_option_nfd_ecommerce_captive_flow_razorpay', array( $this, 'razorpay_connection' ), 10, 2 );
add_filter( 'pre_update_option_nfd_ecommerce_captive_flow_shippo', array( $this, 'shippo_connection' ), 10, 2 );
Expand Down Expand Up @@ -121,6 +122,24 @@ public function checkout_views() {
);
}

/**
* Added to cart, send data to Hiive
*
* @return void
*/
public function site_product_add_to_cart_data() {
$data = array(
"product_count" => WC()->cart->get_cart_contents_count(),
"cart_total" => floatval(WC()->cart->get_cart_contents_total()),
"currency" => get_woocommerce_currency(),
);

$this->push(
"site_product_add_to_cart",
$data
);
}

/**
* Thank you page, send data to Hiive
*
Expand Down

0 comments on commit 4be81f0

Please sign in to comment.