mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
25 lines
735 B
Text
25 lines
735 B
Text
function am_affwp_woocommerce_block_referrals_for_zero_dollar_orders( $create_referral, $args ) {
|
|
|
|
// Return if WooCommerce isn't active.
|
|
if ( ! class_exists( 'WooCommerce' ) ) {
|
|
return $create_referral;
|
|
}
|
|
|
|
// Get the order ID from AffiliateWP.
|
|
$order_id = $args['reference'];
|
|
|
|
// Get the WooCommerce order based on the order ID.
|
|
$order = new WC_Order( $order_id );
|
|
|
|
// Get the order total.
|
|
$order_total = $order->get_total();
|
|
|
|
// Block referrals from being created if the WooCommerce order total is $0.00.
|
|
if ( '0.00' === $order_total ) {
|
|
$create_referral = false;
|
|
}
|
|
|
|
return $create_referral;
|
|
|
|
}
|
|
add_filter( 'affwp_integration_create_referral', 'am_affwp_woocommerce_block_referrals_for_zero_dollar_orders', 10, 2 );
|