Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Nov 2007
    Posts
    7
    Plugin Contributions
    0

    Default Changing shipping methods based on item weight??

    I found some answers in an older post on changing modules based on order weight and tried using that information to solve my problem. Although, it works to say set it to turn off UPS and USPS if the orders total weight is say over 50 lbs. My problems come in as follows:
    We sell many items from .25 lbs to 2500 lbs.

    If a customer orders a statue lets say that weights 1500 lbs the cart will show local pickup only - which would be correct for the moment, since I can not cut the statue up into pieces and pack it in several boxes.

    If a customer orders 30 - 2 lb. items - or 60 lbs worth of stuff it also turns off the UPS and USPS modules as would be expected. But this is incorrect in that I could package those 30 items into two boxes and ship them UPS or USPS etc.

    So here is the question :)

    Is there a way to turn off the shipping modules based on item weight or item id number or would some type of attribute setting work?

    Now I already realize this may cause some issues if a customer orders a statue and some smaller items which could go by way off UPS or USPS and in those instances I may have to just contact the customer to see what they want to do. Unless, of course there is a way to have it split the calculation and only return a shipping price for those items which are shippable and flag the pick up only item as just that. down the line I would probably incorporate some zone shipping for freight shipping of large items as well but for now it is not required.
    Any help will be much appreciated.

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

    Default Re: Changing shipping methods based on item weight??

    It would take some custom coding, but you could test for how much the individual products weight and when nothing is over XXlbs then don't think it is the monument ...
    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
    Nov 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Changing shipping methods based on item weight??

    Quote Originally Posted by Ajeh View Post
    It would take some custom coding, but you could test for how much the individual products weight and when nothing is over XXlbs then don't think it is the monument ...
    would it be to much to ask which variable name(s) I would need to use in that?
    I am fairly new to the Zen, at least in respects to changing it up.
    Would I still use a $_SESSION['cart']-> call to load the individual weights?

    if (IS_ADMIN_FLAG === false) {
    if ($_SESSION['cart']->show_weight() > 60) $this->enabled = false;
    }

    is what I have in the shipping module at the moment, but that looks at the whole cart not individual products. It would be fine if it did as you said - look at individual products and if any are over weight then do not load module. Then at least if someone orders many small items, none of which are over it would still show.

    Thank You for the help in advanced.

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

    Default Re: Changing shipping methods based on item weight??

    You might be able to do something with this function ...
    PHP Code:
    <?php
    // individual product weights in the cart
    // does not include quantity
      
    function zen_get_products_weight() {
        
    $check_products $_SESSION['cart']->get_products();
        for (
    $i=0$n=sizeof($check_products); $i<$n$i++) {
          echo  
    'I see ' $check_products[$i]['id'] . ' Product weight ' $check_products[$i]['weight'] . '<br>';
        }

      }
    ?>
    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
    Nov 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Changing shipping methods based on item weight??

    Yeah I can not get that to do anything.
    First off I am not sure where to put it - if I put it in the shipping module it just turns off that module and DOES NOT echo back anything.
    My main problem here is I do not know the ins and outs of Zen, although I am trying to learn. Also, my PHP su@ks I suppose - at least for programming.

    The - not including qty - part of this is fine as that should not really come into play and I am trying to only look at the products_weight individually. I can not tell where or how your code would be pulling the proper information.

    How about a slightly different approach to explaining this.

    1- check cart for products in it - there has to be something there to check
    1b-load products_id into array ? ? - maybe
    2- check db - zen_products for products_weight - individual product weight not the whole cart.
    2b- Use array for products_id (s) to check weight of
    3- if products_weight is greater than 60 - since packed it couldn't go UPS or USPS
    3b- load products that are over 60 lbs. into an array - NOT REQUIRED but could be useful for future expansion!? ?
    4- $this_enabled = false; - turn off shipping module

    this would go directly in the UPS and USPS module code to stop the loading of the module if any one products individual rate was greater than 60. I would then have a third zoned type module load to display zoned freight charges, which would run the above code in reverse. Or to say that if all products individual weight is less than 60 then do not load the zoned rates.

    there by the customer would see either one of two things-
    UPS and USPS rates
    or
    Freight rates

    but never both.

    Someone here would contact the customer to handle any mixed weight orders and the like. So that we could then UPS the smaller items and freight the large ones - etc.

    Now I think this should be an easy db query and return to check against > or < 60 and then the kill module statement, but I can not for the life of me figure out how to code this up. I have tried several ways and I usually end up having it turn off for everything or I just get errors returned. I am sure my syntax is wrong or something and I have deleted most of what I have tried that has not worked. If someone could please code something up for me to try that should work I would be very thankful. Trying not to put it all on Ajeh's shoulders, so if anyone else has any ideas please HELP.

    I feel like my computer is doing this -
    Last edited by krhody; 12 Nov 2007 at 09:09 PM. Reason: added some info

  6. #6
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Changing shipping methods based on item weight??

    Quote Originally Posted by krhody View Post
    Y1- check cart for products in it - there has to be something there to check
    1b-load products_id into array ? ? - maybe
    2- check db - zen_products for products_weight - individual product weight not the whole cart.
    2b- Use array for products_id (s) to check weight of
    3- if products_weight is greater than 60 - since packed it couldn't go UPS or USPS
    3b- load products that are over 60 lbs. into an array - NOT REQUIRED but could be useful for future expansion!? ?
    4- $this_enabled = false; - turn off shipping module
    That's essentially what Ajeh posted above.
    1a, 1b:
    Code:
        $check_products = $_SESSION['cart']->get_products();
    2a, 2b:
    Code:
        for ($i=0, $n=sizeof($check_products); $i<$n; $i++) {
          echo  'I see ' . $check_products[$i]['id'] . ' Product weight ' . $check_products[$i]['weight'] . '<br>';
        }
    So, modifying it slightly to adapt to your needs, gives this:
    Code:
        $check_products = $_SESSION['cart']->get_products();
        for ($i=0, $n=sizeof($check_products); $i<$n; $i++) {
          if ($check_products[$i]['weight'] > 60 ) $this->enabled = false;
        }
    Last edited by DrByte; 13 Nov 2007 at 10:19 PM. Reason: removed extra )
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  7. #7
    Join Date
    Nov 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Changing shipping methods based on item weight??

    Thanks DrByte !!!!!!!!!!!!!!

    Had to remove one ) from it for it to work but I think I have it working now. I figured it was mostly me over complicating things :)

    Again thanks!
    I am working on adding some more functionality to it such as returning a message and getting another option to show - If I get it all nice and working I will share it with everyone here since I know some people could use this out there in their projects.


    but for now I changed the text that is returned in:
    includes/languages/english/checkout_shipping.php
    Line# 21 to explain what was going to happen from here to the customer when no shipping modules show up. :)

    Works great so far. I will put up more info after testing.

  8. #8
    Join Date
    Nov 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Changing shipping methods based on item weight??

    Been testing things out and so far it is all working fairly well for my needs.
    After placing this code:

    PHP Code:
    $check_products $_SESSION['cart']->get_products();
        for (
    $i=0$n=sizeof($check_products); $i<$n$i++) {
          if (
    $check_products[$i]['weight'] > 60 $this->enabled false;
        } 
    in the UPS module at around line # 177. I did the same for the USPS module at about line # 90. this is where I placed them and they are working just fine. In the UPS code I changed the test weight to 130 since they will ship up to 150 lbs and packaged a 130 pound item would be about 150 pounds. I left the USPS at 60 lbs since their max is 70 lbs. I adjusted my tare to 2:2 or 2% + 2 lbs, at this time these are the settings that appear to work the best and large item tare is set at 10:5 or 10% + 5 lbs. My max package weight is set at 150 lbs so as not to split heavier items into more than one package, this may not be right in all cases but should work for now.

    **** One thing I have noticed is that with this code in the shipping modules it throws a fatal error when trying to enter the shipping modules in ADMIN - it is a simple matter of commenting the new code out in the two modules and then entering the admin -> modules -> shipping screen. I am not certain why it does this but here is the message.

    Fatal error: Call to a member function on a non-object in html/shop/includes/modules/shipping/ups.php on line 177

    -which is of course the line where the new code is located.

    ****
    I also changed shop/includes/languages/english/checkout_shipping.php on line # 43 to a more descriptive explanation as to why Store Pickup was the only shipping option and what would happen from there. This line shows only when no shipping options are available; otherwise it tells you to choose your shipping method.

    That is all that has been done and tested so far but next I will be trying to clone the flat rate shipping table to as many zones as I need based on various weight ranges and delivery charges to different states. A little more involved :)

    I hope this helps someone else out there in the Zen Universe and thanks again to Ajeh and DrByte for their help. I will post more as things develop till then Happy Holidays everyone!

  9. #9
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Changing shipping methods based on item weight??

    Quote Originally Posted by krhody View Post
    **** One thing I have noticed is that with this code in the shipping modules it throws a fatal error when trying to enter the shipping modules in ADMIN - it is a simple matter of commenting the new code out in the two modules and then entering the admin -> modules -> shipping screen. I am not certain why it does this but here is the message.

    Fatal error: Call to a member function on a non-object in html/shop/includes/modules/shipping/ups.php on line 177

    -which is of course the line where the new code is located.
    To deal with the fact that the "check" should only happen when *not* in admin mode, wrap your block of custom code in another IF statement:
    Code:
    if (IS_ADMIN_FLAG === false) {
    ..... the custom code goes here
    }
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Nov 2007
    Posts
    7
    Plugin Contributions
    0

    Default Re: Changing shipping methods based on item weight??

    Of course that helps!

    No error anymore, I should have remembered that for the first code I tried to use that looked at the whole cart.

    Thanks Again DrByte !!!!!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Setting Shipping Methods Based on Weight
    By PeauProductions in forum Built-in Shipping and Payment Modules
    Replies: 14
    Last Post: 26 Sep 2010, 07:22 PM
  2. Different shipping per item (not based on weight)
    By stevelucky in forum General Questions
    Replies: 4
    Last Post: 29 Aug 2010, 04:40 PM
  3. Only showing shipping method based on per item or weight amount
    By chinook in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 30 May 2010, 09:54 AM
  4. Zone Shipping Cost based on Individual item weight, not total order weight
    By pohnean in forum Built-in Shipping and Payment Modules
    Replies: 15
    Last Post: 16 Sep 2009, 09:02 AM
  5. Changing shipping modules based on weight of the order?
    By tracyfloyd in forum Built-in Shipping and Payment Modules
    Replies: 17
    Last Post: 14 Sep 2006, 06:01 PM

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