New Zenner
- Join Date:
- Apr 2013
- Location:
- Southgate, KY
- Posts:
- 9
- Plugin Contributions:
- 0
USPS allow media mail based on cart contents?
Sorry to resurrect a 3 year old closed thread :blush:, but I am having trouble with Media Mail similar to the issue here
http://www.zen-cart.com/showthread.php?126077-Media-Mail-Option
Before I go further, I should mention I am doing this for someone else, and don't have direct access to the files, until the site owner sends them to me.
I downloaded the file in the Zip from reply/post #32, but it was Dated January 4 2010, and the one I am editing is January 2 2011. I found the block for Media Mail and pasted it where I thought I should, and the owner replied with:
"Initial tests are a bit troubled, I'm afraid. Here's what I saw occur:
-
When I added a media-mail-OK product and only had that in my cart, it showed two USPS shipping methods when I checked the shipping estimator
-
When I added another non-media-mail-OK product to the cart, it showed only one USPS method
The problems were...
-
It didn't name the USPS methods properly; and,
-
It showed each of them as having the same value ($3, which is the handling mark-up I've configured to be added to the baseline USPS system's rate quote) which implied that they were both getting evaluated as $0"
Here is what I pasted into his file, with a little before and after.
TEXT_SHIPPING_WEIGHT . ')';
break;
default:
$show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight,2) . TEXT_SHIPPING_WEIGHT . ')';
break;
}
}
// EOF: UPS USPS
// ----- My paste starts here
// bof: Media Check
// test contents for Media Mail
$skip_media = false;
$chk_media = 0;
/* ----------------------- here is where you can add more media mail categories in the future ....
Just copy and paste the following line including semicolon into the correct numerical order and replace the words at the end with the category number
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','category number goes here');
*/
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','77');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','78');
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','79');
if ($chk_media != $_SESSION['cart']->count_contents()) {
$skip_media = true;
}
//echo '<br>IN USPS I SEE ' . $chk_media . ' count: ' . $_SESSION['cart']->count_contents() . ' Skip Media: ' . ($skip_media == true ? 'YES' : 'NO') . '<br>';
$methods = array();
$size = sizeof($uspsQuote);
for ($i=0; $i<$size; $i++) {
list($type, $cost) = each($uspsQuote[$i]);
// BOF: UPS USPS
$title = ((isset($this->types[$type])) ? $this->types[$type] : $type);
if(in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) $title .= $transittime[$type];
/*
$methods[] = array('id' => $type,
'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
*/
if ($type == 'MEDIA' && $skip_media) {
// skip Media Mail
} else {
$cost = preg_replace('/[^0-9.]/', '', $cost);
$methods[] = array('id' => $type,
'title' => $title,
'cost' => ($cost * $shipping_num_boxes) + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING) );
}
}
// eof: Media Check
// ----- Paste ends here
// BOF: UPS USPS
$this->quotes = array('id' => $this->code,
'module' => $this->title . $show_box_weight);
// EOF: UPS USPS
$methods = array();
$size = sizeof($uspsQuote);
for ($i=0; $i<$size; $i++) {
list($type, $cost) = each($uspsQuote[$i]);
// fix new trademark and reg 01-02-2011
Any help is greatly appreciated.