Custom Function Question
-
Hi,
Just wondering if this custom function I put together will work? I’m trying to set the minimum payout of a tracked affiliate purchase to be $1 if the 10% rate is lower than that.
if ( defined( 'YITH_WCAF' ) && ! function_exists( 'yith_wcaf_custom_affiliate_rate' ) ) { function yith_wcaf_custom_affiliate_rate( $rate, $affiliate, $product ) { // Check if the product is a valid instance of WC_Product if ( isset( $product ) && $product instanceof WC_Product ) { // Calculate the commission based on the product price $commission = $product->get_price() * $rate; // If the calculated commission is less than $1, disable percentage rate and set it to $1 if ( $commission < 1 ) { add_filter( 'yith_wcaf_use_percentage_rates', '__return_false' ); return 1; } } // If no specific conditions are met, return the original rate return $rate; } add_filter( 'yith_wcaf_affiliate_rate', 'yith_wcaf_custom_affiliate_rate', 10, 3 ); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Function Question’ is closed to new replies.