If you do not want to see Media when 1 or more Products from categories_id 65 is in the cart, then change the IF:
Code://if ($chk_media != $_SESSION['cart']->count_contents()) { if ($chk_media > 0) {
If you do not want to see Media when 1 or more Products from categories_id 65 is in the cart, then change the IF:
Code://if ($chk_media != $_SESSION['cart']->count_contents()) { if ($chk_media > 0) {
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Perfect! Thank you, it's working now.
Thanks for the update that this is now working for you ...
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Hi Ajeh,
I just found this thread today. This is exactly the problem I am working on. I am creating a 1.5.5e site, which has the USPS module (USPS_2016_0107_K8). My client sells a variety of types (and weights) of items, including books. She would like the media shipping option to only appear when ONLY books are being purchased. Mixed type purchases do not qualify for media mail, according to the USPS website. All my clients books are in one sub-category together, which should make this easier, I would guess. But as I read through this thread, I got confused - perhaps because I am working with newer versions of Zen Cart and the USPS module. I made the recommended edits, but resulted in (apparently) excluding media mail from appearing in ALL situations. First, I put a non-media item in cart. No media shipping option appeared = good. Then, added a book to the same cart. Still no media option = also good. Then, I removed the non-media item from my cart so I had just a book in my cart. Still no media option appeared. Could you, perhaps, take a fresh look at this in the 1.5.5e Zen Cart and latest USPS module files and give me some instructions to accomplish my goal of media mail only appearing when ONLY items from the Books category are in the cart?
Look around line 702 and add:
Then add:Code:$show_hiddenCost = ''; // bof: test contents for Media Mail $skip_media = false; $chk_media = 0; $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','65'); if ($chk_media != $_SESSION['cart']->count_contents()) { $skip_media = true; } // eof: test contents for Media Mail
See if that helps ...Code:// bof: test contents for Media Mail if ($type == 'Media Mail Parcel' && $skip_media) { // skip Media Mail } else { $methods[] = array('id' => $type_rebuilt, 'title' => $title . $show_hiddenCost, 'cost' => $cost, 'insurance' => $usps_insurance_charge, ); }
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Thank you! Worked like a charm!
Glad that all is working now!
Linda McGrath
If you have to think ... you haven't been zenned ...
Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!
Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
Officially PayPal-Certified! Just click here
Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!
Updated to latest USPS (2022-08-07 K11e_) but having an issue with limiting Media Mail Parcel
I would like to only allow Media Mail Parcel when a product from category 45 is in the cart.
If another product is added that is not from category 35, then don't show Media Mail Parcel
Noticed auto.usps_overrides.php
if (stripos($p1, 'Media Mail') !== false) {
$chk_media = 0;
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id', '45');
if ($chk_media == $_SESSION['cart']->count_contents()) {
$p2 = true;
}
Not understanding what to do
$p2 = false; (Should I change this to True? )
--------------------------------------------------------
usps.php - Do I still need to add this? I added it to line 565
// bof: test contents for Media Mail
$skip_media = false;
$chk_media = 0;
$chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','45');
if ($chk_media != $_SESSION['cart']->count_contents()) {
$skip_media = true;
}
// eof: test contents for Media Mail
--------------------------------------------------------
And this code? Not sure if the is needed since the auto.usps_overrides.php takes care of it? Add it in the Customization area?
// bof: test contents for Media Mail
if ($type == 'Media Mail Parcel' && $skip_media) {
// skip Media Mail
} else {
$methods[] = array('id' => $type_rebuilt,
'title' => $title . $show_hiddenCost,
'cost' => $cost,
);
}
// eof: test contents for Media Mail
The auto-loaded observer will take care of that; no need to provide additional edits to the usps.php shipping module. You'll change the observer's checking clause to read
Code:case 'NOTIFY_USPS_UPDATE_OR_DISALLOW_TYPE': // ----- // Disallow "Media Mail" unless all products in the cart have a master_categories_id of '45'. // if (stripos($p1, 'Media Mail') !== false) { if ($_SESSION['cart']->in_cart_check('master_categories_id', '45') !== $_SESSION['cart']->count_contents()) { $p2 = false; } } break;
I see what's going on with the override, in general. But I don't know how the services are defined any more.
For example, I've tried this code with the text "Small Flat Rate Box" and "USPS Priority MailTM Small Flat Rate Box" and "USPS Priority MailRM Small Flat Rate Box," and it isn't working with any of those. I recall when the designation changed from TM to RM, but neither of those appears to be correct any more.
I feel like I'm missing something obvious, sigh.PHP Code:
// Disallow Small Flat Rate Box
if (stripos($p1, 'Small Flat Rate Box') !== false) {
$chk_cart = 0;
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','1'); // golden paste
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','2'); // spicees
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','3'); // accessories
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','5'); // livestock feed
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','10'); // oils
$chk_cart += $_SESSION['cart']->in_cart_check('master_categories_id','11'); // pet products
$chk_cart += $_SESSION['cart']->get_quantity('148') > 0; // Soothamide
if ($chk_cart == $_SESSION['cart']->count_contents() ) {
$p2 = false;
}
Bookmarks