Вы можете использовать
woocommerce_package_rates
, чтобы манипулировать стоимостью доставки.
function woocommerce_package_rates( $rates ) {
//Assuming charge X you mentioned is 5
$custom_shipping_cost = 5;
$total_items = WC()->cart->get_cart_contents_count();
if($total_items > 3 && $total_items < 7) $custom_shipping_cost *= 2;
else if ($total_items > 6 && $total_items < 10) $custom_shipping_cost *= 3;
else if ($total_items > 9 && $total_items < 13) $custom_shipping_cost *= 4;
//you may add more else if statements here
//or try this which is smarter I believe:
/*
* $multiplier = floor( $total_items / 4 ) + 1;
* $custom_shipping_cost *= $multiplier;
*/
foreach($rates as $key => $rate )
{
$rates[$key]->cost = $custom_shipping_cost;
}
return $rates;
}
add_filter( 'woocommerce_package_rates', 'woocommerce_package_rates' );
Надеюсь, это поможет. Код идет в functions.php вашей темы или дочерней темы (что лучше).