Updated possibly_schedule_import function to return order id (#35743)

Co-authored-by: Néstor Soriano <konamiman@konamiman.com>
This commit is contained in:
sanesh-acowebs 2023-10-09 15:36:59 +05:30 committed by GitHub
parent 2731c41268
commit 1c711eeb16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Modify the possibly_schedule_import function to return the order id

View File

@ -40,7 +40,7 @@ class OrdersScheduler extends ImportScheduler {
// Order and refund data must be run on these hooks to ensure meta data is set. // Order and refund data must be run on these hooks to ensure meta data is set.
add_action( 'woocommerce_update_order', array( __CLASS__, 'possibly_schedule_import' ) ); add_action( 'woocommerce_update_order', array( __CLASS__, 'possibly_schedule_import' ) );
add_action( 'woocommerce_create_order', array( __CLASS__, 'possibly_schedule_import' ) ); add_filter( 'woocommerce_create_order', array( __CLASS__, 'possibly_schedule_import' ) );
add_action( 'woocommerce_refund_created', array( __CLASS__, 'possibly_schedule_import' ) ); add_action( 'woocommerce_refund_created', array( __CLASS__, 'possibly_schedule_import' ) );
OrdersStatsDataStore::init(); OrdersStatsDataStore::init();
@ -210,13 +210,15 @@ AND status NOT IN ( 'wc-auto-draft', 'trash', 'auto-draft' )
* @param int $order_id Post ID. * @param int $order_id Post ID.
* *
* @internal * @internal
* @returns int The order id
*/ */
public static function possibly_schedule_import( $order_id ) { public static function possibly_schedule_import( $order_id ) {
if ( ! OrderUtil::is_order( $order_id, array( 'shop_order' ) ) && 'woocommerce_refund_created' !== current_filter() ) { if ( ! OrderUtil::is_order( $order_id, array( 'shop_order' ) ) && 'woocommerce_refund_created' !== current_filter() ) {
return; return $order_id;
} }
self::schedule_action( 'import', array( $order_id ) ); self::schedule_action( 'import', array( $order_id ) );
return $order_id;
} }
/** /**