Page 1 of 7 123 ... LastLast
Results 1 to 10 of 62
  1. #1
    Join Date
    Feb 2014
    Location
    Austin, TX USA
    Posts
    48
    Plugin Contributions
    0

    Default Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Hi,

    I have a new ZC that I'm about to launch. Some of my products qualify for Media Mail and some do not. It is probable that my customers may choose a mix.

    I would like to restrict the display of the Media Mail option to ship if non-qualifying products exist in the cart or display Media Mail as a shipping option if only qualifying products are in the cart.

    There is an old forum discussion dated 2009 about adding a category filter within the usps.php module to do just this:

    http://www.zen-cart.com/showthread.p...ia-Mail-Option

    A solution similar to this would work just fine. However, the code within the usps.php has changed considerably since 2009. I can see that things are organized a bit differently and my attempts to read the code to find a suitable insertion point are failing.

    Can anyone give me a start on this? I'm not new to programming but am completely unfamiliar with php.

    many thanks!

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Are all of your Media Products in one specific master_categories_id or are they in multiple master_categories_id?

    If not, are they all in a few master_categories_id?

    If not, how are these Media Products identified?
    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!

  3. #3
    Join Date
    Feb 2014
    Location
    Austin, TX USA
    Posts
    48
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Hi Ajeh,

    I have a limited number of level categories that have Media Mail product candidates, probably 12. Eventually that might grow to 20 but no more. These categories only have Media Mail candidates and no other type of product. In other words my shop is organized in a way that excluding categories is probably the way to go (as opposed to products using, say, a keyword).

    Moreover there are only two higher level categories, meaning these 12 product carrying categories live under one of two higher level categories.

    thanks!

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Let's say your master_categories_id are 10, 12 an 15 ...

    You would add the code in RED around line 390:
    Code:
    // bof: test contents for Media Mail
            $skip_media = false;
            $chk_media = 0;
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','10');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','12');
            $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','15');
            if ($chk_media != $_SESSION['cart']->count_contents()) {
              $skip_media = true;
            }
    // eof: test contents for Media Mail
    
          for ($i=0; $i<$PackageSize; $i++) {
    then, add the code in RED:
    Code:
    //$show_hiddenCost =  ' $hiddenCost: ' . $hiddenCost;
    $show_hiddenCost = '';
    // bof: test contents for Media Mail
              if ($type == 'MEDIA' && $skip_media) {
                // skip Media Mail
              } else {
              $methods[] = array('id' => $type_rebuilt,
                                 'title' => $title . $show_hiddenCost,
                                 'cost' => $cost,
                                );
              }
    // eof: test contents for Media Mail
    
    This should then stop Media unless all Products in the cart are Media ...
    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!

  5. #5
    Join Date
    Feb 2014
    Location
    Austin, TX USA
    Posts
    48
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    I added the code mod for my categories but it's not working - nothing's broken either but Media Mail still appears on non-eligible items. I've refreshed and tried on several other browsers with clearing cache too.

    Would attach the php file but says file invalid. I've double checked the three insertion points and I'm pretty sure I have not made a mistake.

    any help on this?

    Here's my URL: http://192.185.60.92/~linbo/

    and my cats:

    // bof: test contents for Media Mail
    $skip_media = false;
    $chk_media = 0;
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','27');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','28');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','29');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','30');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','31');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','82');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','83');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','85');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','86');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','87');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','88');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','89');
    $chk_media += $_SESSION['cart']->in_cart_check('master_categories_id','391');
    if ($chk_media != $_SESSION['cart']->count_contents()) {
    $skip_media = true;
    }
    // eof: test contents for Media Mail


    thanks!

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Did you also do this part of the code:
    Code:
    // bof: test contents for Media Mail
              if ($type == 'MEDIA' && $skip_media) {
                // skip Media Mail
              } else {
              $methods[] = array('id' => $type_rebuilt,
                                 'title' => $title . $show_hiddenCost,
                                 'cost' => $cost,
                                );
              }
    // eof: test contents for Media Mail
    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!

  7. #7
    Join Date
    Feb 2014
    Location
    Austin, TX USA
    Posts
    48
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    OK I added this line

    print_r($type_rebuilt);

    immediately underneath the

    // eof test contents for Media Mail

    And this is what printed. So Media Mail is not being filtered out.

    First-Class Mail ParcelMedia MailRMStandard PostRMPriority MailTMPriority Mail ExpressTMFirst-Class Mail Parcel

    I wish I knew php better. It looks like the array needs to see if Media Mail is part of the group and then return a stripped version to the $type or $type_rebuilt array.

    I also noticed that the code patch references $type and not $type_rebuilt.

  8. #8
    Join Date
    Feb 2014
    Location
    Austin, TX USA
    Posts
    48
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    Hi Ajeh,

    Yes, I added the first piece with my own category ids, the second piece a bit later on, and then the close paren with comment. Identical to what you posted.

    Is there a restriction on uploading php code as attachments? I cannot get usps.php to attach - keeps saying invalid file

    here is a larger snip of the second code mod area:

    // USPS customize for filtering displayed methods and costs
    //echo '<br />USPS info: ' . '<br />$type: ' . $type . '<br />$type_rebuilt: ' . $type_rebuilt . '<br />$title: ' . $title . ' $cost: ' . $cost . '<br />';

    if ($this->usps_countries == 'US' && MODULE_SHIPPING_USPS_FIRST_CLASS_FILTER_US == 'True' && preg_match('#First\-Class#i', $type) && $cnt_first > 1) continue;

    // ADDITIONAL CUSTOMIZED CONDITIONS CAN GO HERE TO MANAGE $type_rebuilt or $title on $methods
    // switch comment marks to show $hiddenCost: from quote title
    //$show_hiddenCost = ' $hiddenCost: ' . $hiddenCost;
    $show_hiddenCost = '';

    // bof: test contents for Media Mail
    if ($type == 'MEDIA' && $skip_media) {
    // skip Media Mail
    } else {

    $methods[] = array('id' => $type_rebuilt,
    'title' => $title . $show_hiddenCost,
    'cost' => $cost,
    );
    }
    // eof: test contents for Media Mail

    } else {
    //echo 'MISSING! USPS $type: ' . $type . (in_array($type, $this->typeCheckboxesSelected) ? ' YES' : ' NO') . ' $method: ' . $method . ' $usps_shipping_weight: ' . $usps_shipping_weight . ' $minweight: ' . $minweight . ' $maxweight: ' . $maxweight . '<br>';
    }
    } // end for $i to $PackageSize

    thanks
    Last edited by linniedarling; 23 Mar 2014 at 05:57 PM.

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

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    My bad ... I forgot that the current USPS shipping module now has:
    Media MailRM vs MEDIA

    Change the IF to use Media MailRM ...
    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!

  10. #10
    Join Date
    Feb 2014
    Location
    Austin, TX USA
    Posts
    48
    Plugin Contributions
    0

    Default Re: Media Mail restriction mod to new, 3-7-14 usps module, any help?

    aha! that did the trick!

    You are most awesomeness personified! thank you.

 

 
Page 1 of 7 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. USPS-Offering Media mail on all items
    By flyred77 in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 2 Dec 2009, 12:04 AM
  4. Product Customization USPS Media Mail
    By rfloyd in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 30 May 2008, 09:46 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR