Created
August 12, 2021 13:18
-
-
Save balakrishnandsr/909322b9e2d44795ac2200051c9c436e to your computer and use it in GitHub Desktop.
woocommerce_order_status_changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function update_store_credit_on_the_order_status_complete($order_id, $previous_status, $next_status, $order){ | |
if($next_status == 'completed'){ | |
$from = strtotime($order->get_date_created()); | |
$to = strtotime($order->get_date_modified()); | |
$time_diff = human_time_diff( $from, $to ); | |
$time_diff = explode(" ",$time_diff); | |
if(isset($time_diff[0]) && isset($time_diff[1]) && ($time_diff[0] < 5) ){ | |
if($time_diff[1] == 'second' || $time_diff[1] == 'seconds'){ | |
$this->update_smart_coupon_balance( $order_id ); | |
} | |
} | |
} | |
} | |
add_action( 'woocommerce_order_status_changed', array( $this, 'update_store_credit_on_the_order_status_complete' ), 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment