Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Posts
    24
    Plugin Contributions
    0

    Default Hide/show shipping options by cart total dollar amount.

    Using ZC version 1.3.9h and the latest USPS_2014_1030_K6 pluging. It seems to be working fine.
    Is there a plugin or setting or something that will hide Shipping options based on cart total dollar amount? This cart uses USPS and Fedex. Because of tracking issues they want the cart not to show the USPS option if the cart value is over $75 US. I saw where there was a line in includes/modules/shipping/usps.php for it not to exceed $2499 US per box. Would it work if I changed that to 75 or 0075 per box in the lines needed. Or does more code have to be added to total the cart because per box could be considered per piece and you could put 50 items below $75 and never exceed the limit.
    Here's where I mean:
    '<ValueOfContents>' . number_format(2499 > 0 ? 2499 : 2499, 2, '.', '') . '</ValueOfContents>' .

    Maybe change it to
    '<ValueOfContents>' . number_format(0075 > 0 ? 0075 : 0075, 2, '.', '') . '</ValueOfContents>' .

    Most of the products are not expensive, small, lightweight and usually ship in one box, envelope or whatever they can fit them in. They really don't use the weight or size feature in their shipping.

    The code above is about halfway down all the coding on that page.

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

    Default Re: Hide/show shipping options by cart total dollar amount.

    You can customize the file:
    /includes/modules/shipping/usps.php

    with the code in RED around line 208:
    Code:
          global $template, $current_page_base;
          // CUSTOMIZED CONDITIONS GO HERE
          // Optionally add additional code here to change $this->enabled to false based on whatever custom rules you require.
          // -----
    
    // bof: turn off USPS if order > 75
    if ($_SESSION['cart']->total > 75) {
      $this->enabled = false;
    }
    // eof: turn off USPS if order > 75
    
          // -----
          // eof: optional additional code
        }
    
        $this->notify('NOTIFY_SHIPPING_USPS_UPDATE_STATUS');
    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
    Jan 2012
    Posts
    24
    Plugin Contributions
    0

    Default Re: Hide/show shipping options by cart total dollar amount.

    Thank You so much! Doing a brief test it seemed to work just fine. I will have the store owner do more testing to make sure it works as he wants it to. Again, Thank you very much! I'm not a programmer, I just have a lot of fun working with websites and carts,etc. Just trying to help a friend!

  4. #4
    Join Date
    Jan 2012
    Posts
    24
    Plugin Contributions
    0

    Default Re: Hide/show shipping options by cart total dollar amount.

    I knew it was too easy to be true! LOL
    Seems he told me wrong. Your code worked great but he wasn't specific enough.
    They currently use the following services from USPS.

    First-Class Mail Parcel (2 - 5 days)
    Priority Mail™ (1-day)
    Priority Mail™ Flat Rate Envelope (1-day)
    Priority Mail™ Small Flat Rate Box (1-day)
    Priority Mail Express™ (1-day)
    Priority Mail Express™ Flat Rate Envelope (1-day)

    What he actually wanted was to turn off the "First Class Mail Parcel" "only" for orders over $75 because they have to have something for customers that use a P.O. Box. Is that possible?

    Also check your inbox please. I'm sending you a PM.

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

    Default Re: Hide/show shipping options by cart total dollar amount.

    Take out those changes and use these changes:
    Code:
    // see below use of $chk_cart
    // eof: example to block USPS Priority MailTM Small Flat Rate Box when anything from master_categories_id 12 or 15 are in the cart
    
    // bof: turn off USPS if order > 75 First Class Mail Parcel
    if ($_SESSION['cart']->total > 75) {
      $skip_FirstClassMailParcel = true;
    } else {
      $skip_FirstClassMailParcel = false;
    }
    // eof: turn off USPS if order > 75 First Class Mail Parcel
    
          for ($i=0; $i<$PackageSize; $i++) {
    Code:
    //$show_hiddenCost =  ' $hiddenCost: ' . $hiddenCost;
    $show_hiddenCost = '';
    
    // bof: turn off USPS if order > 75 First Class Mail Parcel
    if ($type_rebuilt != '' && $skip_FirstClassMailParcel && preg_match('#First\-Class Mail Parcel#i', $type_rebuilt)) {
    //echo 'SKIP IT - $type_rebuilt: ' . $type_rebuilt . ' $type: ' . $type . ' preg: ' . preg_match('#First\-Class Mail Parcel#i') . '<br>';
      // skip First Class Mail Parcel over 75
    } else {
    //echo 'SHOW IT - $type_rebuilt: ' . $type_rebuilt . ' $type: ' . $type . ' preg: ' . preg_match('#First\-Class Mail Parcel#i') . '<br>';
              $methods[] = array('id' => $type_rebuilt,
                                 'title' => $title . $show_hiddenCost,
                                 'cost' => $cost,
                                 'insurance' => $usps_insurance_charge,
                                );
    }
    // eof: turn off USPS if order > 75 First Class Mail Parcel
    
    //echo 'setting insurance: ' . $usps_insurance_charge . '<br>';
            } else {
    Last edited by Ajeh; 13 Nov 2014 at 04:52 AM. Reason: fixed IF on preg_match
    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!

 

 

Similar Threads

  1. v153 shipping based solely on dollar amount???
    By jpmill in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 23 Oct 2014, 07:01 AM
  2. Only Show/Offer Item if Specific Dollar Amount is Purchased?
    By Rick5150 in forum Managing Customers and Orders
    Replies: 1
    Last Post: 20 Jul 2012, 08:25 PM
  3. v139h Need actual price for options to show instead of added dollar amount
    By In2Deep in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 18 Jul 2012, 12:51 AM
  4. Percentage of Total Amount or Dollar Value
    By anshin in forum Built-in Shipping and Payment Modules
    Replies: 12
    Last Post: 16 Nov 2010, 03:02 PM
  5. Setup for FREE shipping over a dollar amount
    By precisioneng in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 17 Jan 2010, 01:41 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