Merge pull request woocommerce/woocommerce-admin#2425 from woocommerce/fix/potential-endless-syncs
Action Scheduler: fix potential endless sync
This commit is contained in:
commit
8aaa18c339
|
@ -432,6 +432,26 @@ class WC_Admin_Reports_Sync {
|
|||
* @return void
|
||||
*/
|
||||
public static function orders_lookup_import_order( $order_id ) {
|
||||
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
// If the order isn't found for some reason, skip the sync.
|
||||
if ( ! $order ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$type = $order->get_type();
|
||||
|
||||
// If the order isn't the right type, skip sync.
|
||||
if ( 'shop_order' !== $type && 'shop_order_refund' !== $type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the order has no id or date created, skip sync.
|
||||
if ( ! $order->get_id() || ! $order->get_date_created() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$result = array_sum(
|
||||
array(
|
||||
WC_Admin_Reports_Orders_Stats_Data_Store::sync_order( $order_id ),
|
||||
|
|
|
@ -358,6 +358,10 @@ class WC_Admin_Reports_Coupons_Data_Store extends WC_Admin_Reports_Data_Store im
|
|||
|
||||
$order = wc_get_order( $order_id );
|
||||
|
||||
if ( ! $order ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Refunds don't affect coupon stats so return successfully if one is called here.
|
||||
if ( 'shop_order_refund' === $order->get_type() ) {
|
||||
return true;
|
||||
|
|
|
@ -311,7 +311,12 @@ class WC_Admin_Reports_Taxes_Data_Store extends WC_Admin_Reports_Data_Store impl
|
|||
*/
|
||||
public static function sync_order_taxes( $order_id ) {
|
||||
global $wpdb;
|
||||
|
||||
$order = wc_get_order( $order_id );
|
||||
if ( ! $order ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$tax_items = $order->get_items( 'tax' );
|
||||
$num_updated = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue