@@ -765,6 +765,41 @@ public static function handle_restore_order($order_id, $oldStatus, $newStatus, $
765765 Flow::execute ('WC ' , static ::RESTORE_ORDER , $ orderData , $ flows );
766766 }
767767
768+ public static function handle_order_status_pending ($ orderId )
769+ {
770+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_PENDING );
771+ }
772+
773+ public static function handle_order_status_failed ($ orderId )
774+ {
775+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_FAILED );
776+ }
777+
778+ public static function handle_order_status_on_hold ($ orderId )
779+ {
780+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_ON_HOLD );
781+ }
782+
783+ public static function handle_order_status_processing ($ orderId )
784+ {
785+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_PROCESSING );
786+ }
787+
788+ public static function handle_order_status_completed ($ orderId )
789+ {
790+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_COMPLETED );
791+ }
792+
793+ public static function handle_order_status_refunded ($ orderId )
794+ {
795+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_REFUNDED );
796+ }
797+
798+ public static function handle_order_status_cancelled ($ orderId )
799+ {
800+ return self ::executeOrderStatusTrigger ($ orderId , static ::ORDER_STATUS_SET_TO_CANCELLED );
801+ }
802+
768803 public static function handle_order_status_change ($ order_id , $ from_status , $ to_status , $ this_order )
769804 {
770805 if (!static ::isActivate ()) {
@@ -1335,6 +1370,21 @@ public static function getVariationOfProduct($requestPrarams)
13351370 wp_send_json_success ($ allVariation , 200 );
13361371 }
13371372
1373+ private static function executeOrderStatusTrigger ($ orderId , $ triggeredEntityId )
1374+ {
1375+ if (!static ::isActivate () || empty ($ orderId )) {
1376+ return false ;
1377+ }
1378+
1379+ $ flows = Flow::exists ('WC ' , $ triggeredEntityId );
1380+ if (empty ($ flows )) {
1381+ return false ;
1382+ }
1383+
1384+ $ orderData = WCHelper::processOrderData ($ orderId );
1385+ Flow::execute ('WC ' , $ triggeredEntityId , $ orderData , $ flows );
1386+ }
1387+
13381388 private static function executeProductTriggers ($ postId , $ triggeredEntityId , $ extra = [])
13391389 {
13401390 if (empty ($ postId ) || empty ($ triggeredEntityId )) {
0 commit comments