Hi alexliii, there are always exceptions to the rule in every business. So the plugin allows different shipping estimates on the shipping method (since methods usually directly correlate to a timeframe), and the most granular level – for products, since different products may have different backorder rules, etc.
The plugin is extendable with your own rules. In plugin settings, you may scroll to the last section ‘Custom Code’. Then scroll to the bottom of the section inside Custom Code > Custom Rules. Here is an example where you can define your own rules.
The function wse_adjust_days() can be defined in a custom theme or custom plugin. Below is another iteration where I’ve added product categories, which you can extend. The end result will add additional days to a product if it is in shipping category=’your_shipping_category’ and there are more than 3 products in the cart.
function wse_adjust_days($method_title, $days, $type) {
if (is_admin()) return;
global $woocommerce;
$ship_days = 0;
$quantity = 0;
if ($type == 'max') {
foreach ($woocommerce->cart->get_cart() as $cart_item_keys => $cart_item) {
$product_id = $cart_item['product_id'];
$product = wc_get_product($product_id);
// Get product shipping category (replace 'your_shipping_category' with your actual category)
$shipping_category = $product->get_shipping_class();
// Check if the product belongs to a specific shipping category
$target_shipping_category = 'your_target_shipping_category'; // Replace with your target shipping category slug or ID
if ($shipping_category == $target_shipping_category) {
$quantity += $cart_item['quantity'];
}
}
if (isset($_SERVER['HTTP_COOKIE'])) {
$sess = sanitize_text_field(explode(';', $_SERVER['HTTP_COOKIE'])[0]);
if ($quantity > 0) {
set_transient("wse_qty_$sess", strtolower($quantity), 86400);
} else {
$quantity = get_transient("wse_qty_$sess");
}
}
}
if ($quantity > 3) {
$ship_days = $ship_days + ceil($quantity / 2);
}
return $ship_days;
}