You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We'd like to prevent TaxJar sync for any orders created more than 180 days ago. We're making this work by using the taxjar_order_sync_data filter, but it would be great to have a filter directly on the should_sync method.
Here's the code workaround we implemented to better explain the use case:
/**
* When TaxJar syncs orders to record tax, we don't want it syncing orders that are
* more than 180 days old. At this point, tax should have already been recorded.
*
* This hooks into the taxjar_order_sync_data filter, which is called when building
* the data that TaxJar will use to sync the order; if it's missing something critical,
* such as destination country, it will not sync the order.
*
* @see taxjar-simplified-taxes-for-woocommerce/includes/class-taxjar-order-record.php
* @see \TaxJar_Order_Record::should_sync(), \TaxJar_Order_Record::get_data_from_object()
*
* @param array $taxjar_order_data
* @param \WC_Order $order
* @return array
*/
public function maybe_prevent_old_order_sync( $taxjar_order_data, $order ) {
$days_old = absint( ( time() - strtotime( $order->get_date_created() ) ) / DAY_IN_SECONDS );
if ( $days_old > 180 ) {
// Set to blank value to trigger the should_sync check to return false.
$taxjar_order_data['to_country'] = '';
}
return $taxjar_order_data;
}
}
The text was updated successfully, but these errors were encountered:
We'd like to prevent TaxJar sync for any orders created more than 180 days ago. We're making this work by using the
taxjar_order_sync_data
filter, but it would be great to have a filter directly on theshould_sync
method.Here's the code workaround we implemented to better explain the use case:
The text was updated successfully, but these errors were encountered: