Skip to content

Commit

Permalink
update to new listner
Browse files Browse the repository at this point in the history
  • Loading branch information
manikantakailasa committed Sep 6, 2024
1 parent 45ed860 commit b22b0df
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions includes/Ecommerce_Checkout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace NewfoldLabs\WP\Module\Data\Listeners;

/**
* Monitors EcommerceCheckout events
*/
class Ecommerce_Checkout extends Listener {

/**
* Register the hooks for the listener
*
* @return void
*/
public function register_hooks() {
add_action( 'woocommerce_payment_complete', array( $this, 'Ecommerce_checkout_used' ), 10, 1 );
}


/**
* Track Ecommerce_Checkout used in checkout page
* Send data to hiive
* @param string $order_id complete order details.
* @return void
*/
public function Ecommerce_checkout_used( $order_id ) {

$order = wc_get_order( $order_id );
$order_id = $order->get_id();
$order_status = $order->get_status();

$data = array(
'label_key' => 'order_id',
'order_id' => $order_id,
'status' => $order_status,
);

error_log('data to send',print_r($data));

// $this->push(
// 'order_status_update',
// $data
// );
}
}
1 change: 1 addition & 0 deletions includes/EventManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class EventManager {
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\Commerce',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\Yoast',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\WonderCart',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\Ecommerce_Checkout',
'\\NewfoldLabs\\WP\\Module\\Data\\Listeners\\WPMail',
);

Expand Down

0 comments on commit b22b0df

Please sign in to comment.