My shop has one category whose products must be shipped via Express Mail. All other products may be shipped either by Priority or Express. If an order contains one or more products from this particular category I need to force Express Mail.
So, both shipping methods are allowed, and I'm modifying the quote() function per Linda's code in this thread to check for products in category 69 in the cart and disable Priority Mail if that's the case. This code worked great in a past version of the USPS module, but now I'm using the update from March 27 and I can't get it to work.
Here's the code, from within quote():
I think the problem is how I check for the shipping type. I'm using the string 'Priority MailRM' because that's what I see when I print out the types[] array. I've also tried 'Priority Mail', which is what worked before, and 'Priority Mail®', which is what shows up on the shipping options page during checkout. Do I need to check for a different string? I also tried checking whether the array index was 15, which is where 'Priority MailRM' shows up when I look at the types[] array. Can anyone point me in the right direction?PHP Code:
// Disable Priority Mail for cheese. ecasteel
if (($this->types[$type] == 'Priority MailRM') && $_SESSION['cart']->in_cart_check('master_categories_id','69') > 0) {
$skip_this = true;
} else {
$skip_this = false;
}
if (!$skip_this) {
// eof ecasteel
if ((($method == '' && in_array($type, $types)) || $method == $type) && $usps_shipping_weight <= $maxweight && $usps_shipping_weight > $minweight) {
$methods[] = array('id' => $type,
'title' => $title,
'cost' => $cost,
);
}
// bof ecasteel
}
// eof ecasteel
}
Bookmarks