The product is set to indicate that it's always free shipping, which results in the call to zen_get_shipping_enabled to return (bool)false. What's needed for this site-specific requirement is the addition of a notifier in that function, not in a specific shipping method.
Give this a try, along with your observer. If that does the trick, I'll be happy to submit a PR.
Code:
function zen_get_shipping_enabled(string $shipping_module): bool
{
global $PHP_SELF;
// for admin always true
if (IS_ADMIN_FLAG && strstr($PHP_SELF, FILENAME_MODULES)) {
return true;
}
$check_cart_free = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping', '1');
$check_cart_cnt = $_SESSION['cart']->count_contents();
$check_cart_weight = $_SESSION['cart']->show_weight();
global $zco_notifier;
$override_enabled = false;
$zco_notifier->notify('ZEN_GET_SHIPPING_ENABLED_OVERRIDE', compact('check_cart_free', 'check_cart_cnt', 'check_cart_weight'), $override_enabled);
if ($override_enabled === true) {
return true;
}
// Free Shipping when 0 weight - enable freeshipper - ORDER_WEIGHT_ZERO_STATUS must be on
if (ORDER_WEIGHT_ZERO_STATUS == '1' && ($check_cart_weight == 0 && $shipping_module == 'freeshipper')) {
return true;
}
// Free Shipping when 0 weight - disable everyone - ORDER_WEIGHT_ZERO_STATUS must be on
if (ORDER_WEIGHT_ZERO_STATUS == '1' && ($check_cart_weight == 0 && $shipping_module != 'freeshipper')) {
return false;
}
if ($_SESSION['cart']->free_shipping_items() == $check_cart_cnt && $shipping_module == 'freeshipper') {
return true;
}
if ($_SESSION['cart']->free_shipping_items() == $check_cart_cnt && $shipping_module != 'freeshipper') {
return false;
}
// Always free shipping only true - enable freeshipper
if ($check_cart_free == $check_cart_cnt && $shipping_module == 'freeshipper') {
return true;
}
// Always free shipping only true - disable everyone
if ($check_cart_free == $check_cart_cnt && $shipping_module != 'freeshipper') {
return false;
}
// Always free shipping only is false - disable freeshipper
if ($check_cart_free != $check_cart_cnt && $shipping_module == 'freeshipper') {
return false;
}
return true;
}
Bookmarks