Forums / Addon Shipping Modules / Hide/show shipping options by cart total dollar amount.

Hide/show shipping options by cart total dollar amount.

Views: 1,483

Results 1 to 5 of 5
10 Nov 2014, 9:29 PM
#1
barf avatar

barf

New Zenner

Join Date:
Jan 2012
Posts:
24
Plugin Contributions:
0

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.

11 Nov 2014, 1:32 AM
#2
ajeh avatar

ajeh

Oba-san

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

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:

      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.
      // -----

[B]// bof: turn off USPS if order > 75
if ($_SESSION['cart']->total > 75) {
  $this->enabled = false;
}
// eof: turn off USPS if order > 75
[/B]
      // -----
      // 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!]
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!

12 Nov 2014, 6:35 PM
#3
barf avatar

barf

New Zenner

Join Date:
Jan 2012
Posts:
24
Plugin Contributions:
0

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!

12 Nov 2014, 8:47 PM
#4
barf avatar

barf

New Zenner

Join Date:
Jan 2012
Posts:
24
Plugin Contributions:
0

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.

13 Nov 2014, 2:27 AM
#5
ajeh avatar

ajeh

Oba-san

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

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

Take out those changes and use these changes:

// 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

[B]// 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
[/B]
      for ($i=0; $i<$PackageSize; $i++) {
//$show_hiddenCost =  ' $hiddenCost: ' . $hiddenCost;
$show_hiddenCost = '';

[B]// 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>';
[/B]          $methods[] = array('id' => $type_rebuilt,
                             'title' => $title . $show_hiddenCost,
                             'cost' => $cost,
                             'insurance' => $usps_insurance_charge,
                            );
[B]}
// eof: turn off USPS if order > 75 First Class Mail Parcel
[/B]
//echo 'setting insurance: ' . $usps_insurance_charge . '<br>';
        } else {

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!