(Forgive me if there's already a thread for this contribution -- I couldn't find it with a search)
I've recently had the need to limit shipping to boxes of 6 or 12 items. Fortunately there's a contrib by georgfly for exactly this purpose. However, I did find a bug and thought I'd post a solution here for anyone else needing it. I'm currently testing it on ZC 1.5.0 -- looking good so far.
At the end of the classes/observers/class.weinkartons_amount.php file, in the case statement there is the following:
However, at this stage of the switch $prodincase hasn't been declared, so checkout pages were not redirecting if there was a conflict. I've replaced the above with this:PHP Code:case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
case 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
case 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION':
if ($prodincase > 0 && $bigcase > 0) {
if($prodincase % $bigcase != 0 && $_SESSION['cart']->count_contents() != $smallcase) {
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}
}
A big thanks to georgfly for providing the contrib in the first place.PHP Code:case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING':
case 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT':
case 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION':
if($_SESSION['cart']->count_contents() % $bigcase !=0 && $_SESSION['cart']->count_contents() % $smallcase !=0){
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
}


Reply With Quote
