Skip to content

Instantly share code, notes, and snippets.

@thejamescollins
Last active April 30, 2021 06:39
Show Gist options
  • Save thejamescollins/b5e3a1c5a186c1fada40155b48429105 to your computer and use it in GitHub Desktop.
Save thejamescollins/b5e3a1c5a186c1fada40155b48429105 to your computer and use it in GitHub Desktop.
WooCommerce Zapier send Order data immediately (rather than asynchronously), but send Customer data asynchronously
<?php
/*
The following code will tell the WooCommerce Zapier extension (v1.7.x - v1.9.x). to send Order data to
Zapier immediately, rather than sending the data asynchronously via WordPress cron.
Customer data is still sent asynchronously via WordPress cron.
Save this file as wczaper.php and place it in your wp-content/mu-plugins/ directory.
This snippet does not apply for WooCommerce Zapier version 2.0+, which uses WooCommerce core's webhook devliery mechanism instead.
*/
function wc_zapier_send_asynchronously_check( $async, $trigger ) {
if ( is_a( $trigger, 'WC_Zapier_Trigger_Order' ) ) {
// Order data, so send immediately
return false;
} else if ( is_a( $trigger, 'WC_Zapier_Trigger_New_Customer' ) ) {
// New Customer, so send asynchronously
return true;
} else {
// Other, so leave unchanged
return $async;
}
}
add_filter( 'wc_zapier_send_asynchronously', 'wc_zapier_send_asynchronously_check', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment