Forums / Addon Shipping Modules / how to not show USPS after X weight or certain products?

how to not show USPS after X weight or certain products?

Started by kelleymotorsports on 11 Jan 2013, 5:17 PM · Views: 1,741

Results 1 to 16 of 16
11 Jan 2013, 5:17 PM
#1
kelleymotorsports avatar

kelleymotorsports

New Zenner

Join Date:
Jul 2012
Posts:
58
Plugin Contributions:
0

how to not show USPS after X weight or certain products?

anyway to set the weight that USPS doesn't show up in the shipping options? i'm not sure if this is the option i want yet (not to be 2 sided) but i'm thinking i may have parts that weight over lets say 35 lbs that would still fit in a flat rate box. so maybe i could just disable USPS for certain items (EX. rims and tires)?

https://www.kelleymotorsports.com

i like disabling for certain products if its not a lot of work...

11 Jan 2013, 5:45 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

You could add the code in RED:

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }
[B]
// bof: disable shipping when weight > 35
if (!IS_ADMIN_FLAG) {
  global $total_weight;
  if ($total_weight > 35) {
    $this->enabled = false;
  }
}
// eof: disable shipping when weight > 35
[/B]
    if ($this->enabled) {
      // check MODULE_SHIPPING_USPS_HANDLING_METHOD is in

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!

11 Jan 2013, 8:19 PM
#3
kelleymotorsports avatar

kelleymotorsports

New Zenner

Join Date:
Jul 2012
Posts:
58
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

is there a method to only remove this option on certain items only?

thank you for the info btw

12 Jan 2013, 1:06 AM
#4
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

Could you be more specific on what you mean by "remove this option on certain items only"?

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!

16 Jan 2013, 3:31 AM
#5
kelleymotorsports avatar

kelleymotorsports

New Zenner

Join Date:
Jul 2012
Posts:
58
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

is there a way to remove US Mail from a certain category. If a customer were to order several "parts"and it weighed over 35lbs, it could still ship in a "if it fits it ships" box. i think it will work with the first option but was curious if it would work with option 2.

16 Jan 2013, 3:57 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

To disable USPS when the weight of Products in Category 10 is >= 35lb ... you could customize the code for:
/includes/modules/shipping/usps.php

by adding the code in RED:

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }

[B]// bof: turn off when weight is >= 35 in Category 10
    if (!IS_ADMIN_FLAG) {
      global $cart;
      $chk_weight = 0;
      $products = $_SESSION['cart']->get_products();
      for ($i=0, $n=sizeof($products); $i<$n; $i++) {
        if ($products[$i]['category'] == 10) {
          $chk_weight += $products[$i]['weight'] * $products[$i]['quantity'];
        }
      }
      if ($chk_weight >= 35) {
        $this->enabled = false;
      }
    }
// eof: turn off when weight is >= 35 in Category 10
[/B]
    if ($this->enabled) {
      // check MODULE_SHIPPING_USPS_HANDLING_METHOD is in

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!

21 Jan 2013, 7:44 PM
#7
kelleymotorsports avatar

kelleymotorsports

New Zenner

Join Date:
Jul 2012
Posts:
58
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

awesome! thanks!

if it ends up being more than 1 category, just repeat that?

21 Jan 2013, 11:09 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

You could use for categories_id 10 and 12:

        if ($products[$i]['category'] == 10 || $products[$i]['category'] == 12) {

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!

13 Aug 2013, 7:25 PM
#9
luvstoxstitch avatar

luvstoxstitch

New Zenner

Join Date:
Jun 2010
Location:
Ohio
Posts:
36
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

Ajeh:

To disable USPS when the weight of Products in Category 10 is >= 35lb ... you could customize the code for:
/includes/modules/shipping/usps.php

by adding the code in RED:

// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
  $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}

[B]// bof: turn off when weight is >= 35 in Category 10
if (!IS_ADMIN_FLAG) {
global $cart;
$chk_weight = 0;
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if ($products[$i]['category'] == 10) {
$chk_weight += $products[$i]['weight'] * $products[$i]['quantity'];
}
}
if ($chk_weight >= 35) {
$this->enabled = false;
}
}
// eof: turn off when weight is >= 35 in Category 10
[/B]

if ($this->enabled) {
// check MODULE_SHIPPING_USPS_HANDLING_METHOD is in

 I have a manufacturer that only uses UPS but has products in several categories. Would it be possible to use manufacturers instead of categories for this?
13 Aug 2013, 9:33 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

Do you just need to know that a manufacturers_id is in the cart? Or, do you need to know that manufacturers_id weight when in the cart? :lookaroun

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!

15 Aug 2013, 6:40 PM
#11
luvstoxstitch avatar

luvstoxstitch

New Zenner

Join Date:
Jun 2010
Location:
Ohio
Posts:
36
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

Ajeh:

Do you just need to know that a manufacturers_id is in the cart? Or, do you need to know that manufacturers_id weight when in the cart? :lookaroun

I'm not sure. I need the USPS option disabled for certain manufacturers -ex. Game Time & Northwest . They drop ship my orders and only ship UPS so I need to disable the USPS option so only UPS is shown.

16 Aug 2013, 2:22 AM
#12
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

In the new USPS July 28, 2013 J5 shipping module, you can customize whether the module is enabled or disabled a little differently than in the past ...

Look for the code for update_status() and add the code in RED:

  function update_status() {
    global $order, $db;
    if (IS_ADMIN_FLAG == TRUE) return;

    // disable only when entire cart is free shipping
    if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
    }

[B]// bof: turn off when manufacturers_id 3, 10
      $chk_manufacturers = 0;
      $products = $_SESSION['cart']->get_products();
      for ($i=0, $n=sizeof($products); $i<$n; $i++) {
        $chk_manufacturers_id = zen_get_products_manufacturers_id((int)$products[$i]['id']);
        if ($chk_manufacturers_id == 3 || $chk_manufacturers_id == 10) {
          $chk_manufacturers ++;
        }
//echo '(int)$products[$i][id]: ' . (int)$products[$i]['id'] . ' $chk_manufacturers_id: ' . $chk_manufacturers_id . ' $chk_manufacturers: ' . $chk_manufacturers . '<br>';
      }
      if ($chk_manufacturers > 0) {
        $this->enabled = false;
      }
// eof: turn off when manufacturers_id 3, 10
[/B]
    if ($this->enabled == true) {

manufacturers_id is a little different than checking the master_categories_id and some of the other fields as it is not really a part of the class shopping_cart so you need an extra step to identify which manufacturers_id belongs to the Product ...

This test is just counting how many times a manufacturers_id belongs to the Product for manufacturers_id 3 and 10 ... you can change those to the values you need or add more or less to be tested to the IF:

[B]        if ($chk_manufacturers_id == 3) {
[/B]
[B]        if ($chk_manufacturers_id == 3 || [/B][B]$chk_manufacturers_id == 10 || [/B][B]$chk_manufacturers_id == 12[/B][B]) {
[/B]

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!

16 Aug 2013, 3:50 AM
#13
luvstoxstitch avatar

luvstoxstitch

New Zenner

Join Date:
Jun 2010
Location:
Ohio
Posts:
36
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

Ajeh:

In the new USPS July 28, 2013 J5 shipping module, you can customize whether the module is enabled or disabled a little differently than in the past ...

Look for the code for update_status() and add the code in RED:

function update_status() {
global $order, $db;
if (IS_ADMIN_FLAG == TRUE) return;

// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
  $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
}

[B]// bof: turn off when manufacturers_id 3, 10
$chk_manufacturers = 0;
$products = $_SESSION['cart']->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
$chk_manufacturers_id = zen_get_products_manufacturers_id((int)$products[$i]['id']);
if ($chk_manufacturers_id == 3 || $chk_manufacturers_id == 10) {
$chk_manufacturers ++;
}
//echo '(int)$products[$i][id]: ' . (int)$products[$i]['id'] . ' $chk_manufacturers_id: ' . $chk_manufacturers_id . ' $chk_manufacturers: ' . $chk_manufacturers . '<br>';
}
if ($chk_manufacturers > 0) {
$this->enabled = false;
}
// eof: turn off when manufacturers_id 3, 10
[/B]

if ($this->enabled == true) {

> 
> manufacturers_id is a little different than checking the master_categories_id and some of the other fields as it is not really a part of the class shopping_cart so you need an extra step to identify which manufacturers_id belongs to the Product ...
> 
> This test is just counting how many times a manufacturers_id belongs to the Product for manufacturers_id 3 and 10 ... you can change those to the values you need or add more or less to be tested to the IF:
> ```
[B]        if ($chk_manufacturers_id == 3) {
[/B]

[B] if ($chk_manufacturers_id == 3 || [/B][B]$chk_manufacturers_id == 10 || [/B][B]$chk_manufacturers_id == 12[/B][B]) {
[/B]



Thanks so much! I downloaded the newest usps shipping module like you suggested and put in the following code after replacing the manufacturers ids with the correct ones. I created a couple of test products from that manufacturer but usps still shows at the checkout.

 > function update_status() {
>     global $order, $db;
>     if (IS_ADMIN_FLAG == TRUE) return;
> 
>     // disable only when entire cart is free shipping
>     if (zen_get_shipping_enabled($this->code)) {
>       $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
>     }
> // bof: turn off when manufacturers_id 182, 183
>       $chk_manufacturers = 0;
>       $products = $_SESSION['cart']->get_products();
>       for ($i=0, $n=sizeof($products); $i<$n; $i++) {
>         $chk_manufacturers_id = zen_get_products_manufacturers_id((int)$products[$i]['id']);
>         if ($chk_manufacturers_id == 182 || $chk_manufacturers_id == 183) {
>           $chk_manufacturers ++;
>         }
> //echo '(int)$products[$i][id]: ' . (int)$products[$i]['id'] . ' $chk_manufacturers_id: ' . $chk_manufacturers_id . ' $chk_manufacturers: ' . $chk_manufacturers . '<br>';
>       }
>       if ($chk_manufacturers > 0) {
>         $this->enabled = false;
>       }
> // eof: turn off when manufacturers_id 182, 183
> 
>     if ($this->enabled == true) {
Also  now the usps option is showing an odd string of characters in the estimated shipping calculator and at the checkout. Here's a link the the test product. <http://www.needleworkfool.com/index.php?main_page=product_info&cPath=8_9&products_id=182> I'm not sure what I did wrong :unsure:
16 Aug 2013, 4:17 AM
#14
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

I am not sure why you are showing those special characters as they are translated to by the Trademark or Registered Trademark ...

It also looks like you did not download the right USPS July 28, 2013 J5 so download it again:
http://www.zen-cart.com/downloads.php?do=file&id=1292

As to why it does not work, it looks like you are using the products_id vs the manufacturers_id on the IF ...

This line is currently commented out:

[B]//[/B]echo '(int)$products[$i][id]: ' . (int)$products[$i]['id'] . '  $chk_manufacturers_id: ' . $chk_manufacturers_id . ' $chk_manufacturers:  ' . $chk_manufacturers . '<br>';

Change it to test for the manufacturers_id by removing the two // marks to see what the true manufactures_id is for the Product(s) ... you can also see the manufacturers_id in your Zen Cart Admin if you click on the Manufacturer and hit edit ... it will be in the URL as:

mID=XXX

NOTE: Make sure when you edit the file:
/includes/modules/shipping/usps.php

that you are using a proper TEXT EDITOR and not something like MS Word ... as that may be the cause of the problems with the special characters ...

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!

16 Aug 2013, 5:02 AM
#15
luvstoxstitch avatar

luvstoxstitch

New Zenner

Join Date:
Jun 2010
Location:
Ohio
Posts:
36
Plugin Contributions:
0

Re: how to not show USPS after X weight or certain products?

I feel so silly I was trying to find the manufacturers id and I accidentally put in the test products id for one. :blush: It seems to work now. Just sent the Zen Cart Team a cup of coffee and a donut :hug: Thanks so much for the help.

16 Aug 2013, 1:35 PM
#16
ajeh avatar

ajeh

Oba-san

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

Re: how to not show USPS after X weight or certain products?

Thanks for the update that this is working for you now ...

Not to worry about feeling silly as clicking on that Manufacturer was showing the products_id but one might assuming it was a manufacturers_id based on testing ... had you had 2 or more Products setup for that manufacturer, then you would have seen the actual manufacturers_id referenced in the URL ...

NOTE: when testing it is could to test with 1 Product then test with 2 or more to help cover all of the bases ... and don't forget to test for a dozen Products to help test limits such as Maximum Values which are often defaulted to 10 ...

Thanks for the coffee and donut! The support is always appreciated to help keep us rolling along ... :cool:

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!