Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save balakrishnandsr/909322b9e2d44795ac2200051c9c436e to your computer and use it in GitHub Desktop.
Save balakrishnandsr/909322b9e2d44795ac2200051c9c436e to your computer and use it in GitHub Desktop.
woocommerce_order_status_changed
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