Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Configuring the Zen Cart Admin / Built-in Shipping and Payment Modules / Modifing shipping options avaible to customer by catigories in shopping cart

Modifing shipping options avaible to customer by catigories in shopping cart

26 Feb 2015, 1:52 AM
#1
beau91324 avatar

beau91324

Zen Follower

Join Date:
Jul 2009
Posts:
149
Plugin Contributions:
0

Post #1 by beau91324

We are using the latest version of the USPS shipping module, and it is working quite well but we have run into a problem with Media Mail and Priority mail. Usually our products are shipped via Priority Mail but some of them can be shipped with Media Mail. The media Mail eligible products are all in their own categories so I'd like to be able to have some way of getting ZenCart to check to see if the shopping cart is filled with only those categories and if it is give the customer the option of selecting Media Mail. I really don't want to dive into the USPS Module code and make the changes code if someone has already worked out how to do this.

Thanks

Beau

26 Feb 2015, 2:21 PM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #3 by ajeh

To control when Media mail is available for when the shopping cart contains only Products from specific master_categories_id you can edit the module:
/includes/modules/shipping/usps.php

and add to code in **RED **around line 370:

// eof: example to block USPS Priority MailTM Small Flat Rate Box when anything from master_categories_id 12 or 15 are in the cart

[B]// bof: Media for specific master_categories_id
  $media_categories = 0;
  $media_categories += $_SESSION['cart']->in_cart_check('master_categories_id','10');
  $media_categories += $_SESSION['cart']->in_cart_check('master_categories_id','12');
  if ($_SESSION['cart']->count_contents() != $media_categories) {
    $skip_media = true;
  } else {
    $skip_media = false;
  }
// bof: Media for specific master_categories_id
[/B]
      for ($i=0; $i<$PackageSize; $i++) {

and the code around line 629 in RED:

//echo '<br />USPS info: ' . '<br />$type: ' . $type . '<br />$type_rebuilt: ' . $type_rebuilt . '<br />$title: ' . $title . ' $cost: ' . $cost . '<br />';

[B]// bof: Media for specific master_categories_id
          if ($skip_media && preg_match('#MEDIA#i', $type)) {
            continue;
          }
// eof: Media for specific master_categories_id
[/B]
          if ($this->usps_countries == 'US' && MODULE_SHIPPING_USPS_FIRST_CLASS_FILTER_US == 'True' && preg_match('#First\-Class#i', $type) && $cnt_first > 1) continue;

Just change or add the master_categories_id for:

[B]  $media_categories += $_SESSION['cart']->in_cart_check('master_categories_id','10');
[/B]

to the ones you need and add additional ones if needed ...

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!]
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!