WC Advanced Fees - custom subtotal
<?php | |
function custom_wcaf_fee_amount_subtotal( $subtotal ) { | |
$subtotal = 0; | |
$category_id = '61'; // Your category ID here. | |
$cart_items = WC()->cart->get_cart(); | |
foreach ( $cart_items as $key => $item ) { | |
if ( has_term( $category_id, 'product_cat', $item['product_id'] ) ) { | |
$subtotal += $item['line_subtotal'] + $item['line_subtotal_tax']; | |
} | |
} | |
return $subtotal; | |
} | |
add_filter( 'woocommerce_advanced_fees_get_fee_amount_subtotal', 'custom_wcaf_fee_amount_subtotal' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment