Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Created June 24, 2025 10:43
Show Gist options
  • Save xlplugins/26b2d9af2075f4bd59522440992bf1c9 to your computer and use it in GitHub Desktop.
Save xlplugins/26b2d9af2075f4bd59522440992bf1c9 to your computer and use it in GitHub Desktop.
Funnelkit Cart: Change the reward total using filter hook
class FKCART_Change_Reward_Total{
public function __construct(){
add_filter('fkcart_reward_total',[$this,'change_reward_total'],10,2);
}
public function change_reward_total($total,$calculation_mode){
$excluded_parent_ids = [25831, 27396, 26470, 26007, 27023, 22359, 26715];
if ( WC()->cart ) {
foreach ( WC()->cart->get_cart() as $cart_item ) {
$product = $cart_item['data'];
$check_id = $product->is_type( 'variation' )
? $product->get_parent_id()
: $product->get_id();
if ( in_array( $check_id, $excluded_parent_ids, true ) ) {
if ( 'total' === $calculation_mode ) {
$deduct = floatval( $cart_item['line_total'] )
+ floatval( $cart_item['line_tax'] );
} else {
$deduct = floatval( $cart_item['line_subtotal'] )
+ floatval( $cart_item['line_subtotal_tax'] );
}
$total -= $deduct;
}
}
}
return $total;
}
}
new FKCART_Change_Reward_Total();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment