Page 1 of 5 123 ... LastLast
Results 1 to 10 of 46
  1. #1
    Join Date
    Feb 2008
    Posts
    3
    Plugin Contributions
    0

    Default Media Mail Option

    I'm trying to figure out how to add a USPS Media Mail option to my cart for books.

    I found this thread which is exactly what I want to do
    http://www.zen-cart.com/forum/showth...ght=media+mail
    using the following code,

    Code:
             if ($type == 'MEDIA' && $_SESSION['cart']->in_cart_check('master_categories_id','10') != $_SESSION['cart']->count_contents()) {
                // skip MEDIA when whole cart is not from master_categories_id 10
              } else {
              $methods[] = array('id' => $type,
                                 'title' => $title,
                                 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
              }
    but I seem to be doing something wrong as the media mail option shows up for all sales, not just those restricted to the master_category_id. I'm sure I'm inserting the correct master category id, but I'm not sure I'm placing the code in the correct place in the usps.php file.

    So could someone please tell me where exactly the code should be placed in the file?

    Thanks for your help.

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Media Mail Option

    I added your code to my site and when categories_id 10 products, tested via the master_categories_id is equal to the full count of items I get the Media choice and when they are not equal I do not get the Media choice ...

    Make sure that you uploaded your changes to the right directory and that master_categories_id is actually 10 in the products table ...
    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!

  3. #3
    Join Date
    Feb 2008
    Posts
    3
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Thanks for your quick response, but where exactly do I place the code in the file? The file has a lot of code and I've tried placing it at different places sometimes with not very good results.

    Thanks so much for your help.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Media Mail Option

    In the USPS shipping module, around line 209, you find the code:
    Code:
              $methods[] = array('id' => $type,
                                 'title' => $title,
                                 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
    So you are adding your code for the IF around that piece of code and changing it ...

    Code:
             if ($type == 'MEDIA' && $_SESSION['cart']->in_cart_check('master_categories_id','10') != $_SESSION['cart']->count_contents()) {
                // skip MEDIA when whole cart is not from master_categories_id 10
              } else {
              $methods[] = array('id' => $type,
                                 'title' => $title,
                                 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
              }
    That will allow MEDIA to show only when ALL Products in the shopping cart are using master_categories_id 10 ...
    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!

  5. #5
    Join Date
    Feb 2008
    Posts
    3
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Thank you so much - it works! You are awesome!

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Media Mail Option

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

  7. #7
    Join Date
    Jul 2009
    Location
    Crystal Lake, IL
    Posts
    50
    Plugin Contributions
    0

    Default Re: Media Mail Option

    I am trying to get media mailing from USPS to only appear when all products in the cart are from category 21. I used the code:
    Code:
    if ($type == 'MEDIA' && $_SESSION['cart']->in_cart_check('master_categories_id','21') != $_SESSION['cart']->count_contents()) {
                // skip MEDIA when whole cart is not from master_categories_id 21
              } else {
              $methods[] = array('id' => $type,
                                 'title' => $title,
                                 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
              }
            }
    I just tried it out by putting one CD in my cart and it didn't show up. Does it matter that the CD is actually a sub category of category 21?
    Thanks,
    Matt

  8. #8
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Media Mail Option

    A master_categories_id is the specific Category that the Product is in where it is set as the master_categories_id of the Product ...

    If you edit the Product it will tell you the master_categories_id of that Product ...

    You appear to be testing a parent categories_id and that is not going to work ...
    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!

  9. #9
    Join Date
    Jul 2009
    Location
    Crystal Lake, IL
    Posts
    50
    Plugin Contributions
    0

    Default Re: Media Mail Option

    Thanks, so is there a way that I can check a parent category? If not, how can I get it to check each individual category. Right now, if I'm not mistaken, the code is checking if the entire cart is comprised of the selected category. If I have four categories that use media, if I simply duplicate the code and somebody orders one CD from one category and one CD from another, it won't show the media option since the cart is completely comprised of either category. I hope that made sense. Basically, here is my category structure:
    21 : Media (parent)
    22 : Amazon (child)
    29 : Barnes & Noble (child)
    52 : Calypso (child)
    58 : Steelpan (child)
    So if the cart is completely made up of only products from categories 22, 29, 52, and 58 I need media mail to display. I will also be adding more categories under the parent category Media in the future.
    Thanks for your help.
    -Matt

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Media Mail Option

    You would either need to write a new function to test based on parent categories_id or you could change the code to read something like:
    Code:
    // test contents for Media Mail
            $skip_media = false;
            $chk_media = 0;
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','22');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','29');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','52');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','58');
            if ($chk_media != $_SESSION['cart']->count_contents()) {
              $skip_media = true;
            }
    
            $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 {
                $methods[] = array('id' => $type,
                                   'title' => $title,
                                   'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
              }                             
            }
    
            $this->quotes['methods'] = $methods;
    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!

 

 
Page 1 of 5 123 ... LastLast

Similar Threads

  1. v139h USPS Media Mail problem.
    By Beau91324 in forum Addon Shipping Modules
    Replies: 4
    Last Post: 8 Jul 2014, 08:50 PM
  2. v150 USPS Module RateV3 -- trying to integrate Media Mail eligible option
    By jaheadlee in forum Addon Shipping Modules
    Replies: 1
    Last Post: 24 Jul 2012, 10:59 PM
  3. Media mail surcharge
    By Arunachala in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 13 Jun 2011, 01:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg