Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Apr 2008
    Location
    Covington, Washington, United States
    Posts
    205
    Plugin Contributions
    1

    Default Switch from one shipping module to another dependent on product variables

    Hello all...

    I am trying to figure out if it is possible to use and show only FedEx by default, but if product weight <= 0, then use and show only table rates...?

    The reason for this is that I have the weight for only about half of my products entered... So the FedEx module will only show the lowest rate (based on 0 lbs).

    Thanks for your advice.

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

    Default Re: Switch from one shipping module to another dependent on product variables

    Shipping modules display based on the $this->enabled being true and do not display based on $this->enabled being false ...

    You could test the weight of the cart for 0 weight and set the $this->enabled to false and that would "turn off" the FedEx shipping module when the weight is 0 ...
    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
    Apr 2008
    Location
    Covington, Washington, United States
    Posts
    205
    Plugin Contributions
    1

    Default Re: Switch from one shipping module to another dependent on product variables

    Ajeh,

    Thank you. Would this do the trick then?

    PHP Code:
    function quote($method '') {

        global 
    $shipping_weight$shipping_num_boxes$cart$order;

            
    // FedEx not available if weight is 0 or null
        
    if ($shipping_weight ==$shipping_weight ==null) {
            
    $this->enabled = ((MODULE_SHIPPING_FEDEX_GROUND_STATUS == 'False');
            } else {
            
    $this->enabled = ((MODULE_SHIPPING_FEDEX_GROUND_STATUS == 'True');
        } 

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

    Default Re: Switch from one shipping module to another dependent on product variables

    NOTE: the OR connector is || vs the single | you have ...

    You should just be able to use is the $shipping_weight == 0 ...

    Be aware that if you have Tare Weight set that this would be added in, so in the Configuration ... Shipping/Packaging ... you would want those set to 0:0 ...

    Also, check where you are testing this and setting: $this->enabled

    If it is not tested in the code below what you are showing, you are not using the code in the right place ...
    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
    Apr 2008
    Location
    Covington, Washington, United States
    Posts
    205
    Plugin Contributions
    1

    Default Re: Switch from one shipping module to another dependent on product variables

    Good call on the "|" OR mistake, must have just been excited :)

    Well, the good news is it works... The bad news is it doesn't work perfectly :) It doesn't allow the customer to get a FedEx quote using the estimator, which is fabulous. However, on the checkout page where it breaksdown the charges, it still displays FedEx but says:

    No Rates Returned, E523 : Invalid weight.

    I would like nothing to display. Is there a better place I should do my check?

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

    Default Re: Switch from one shipping module to another dependent on product variables

    The better way to do this is at the start of the shipping module ... for example, USPS usps.php I would change this code:
    Code:
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
    to read:
    Code:
        // disable only when entire cart is free shipping
        if (zen_get_shipping_enabled($this->code)) {
          $this->enabled = ((MODULE_SHIPPING_USPS_STATUS == 'True') ? true : false);
        }
    
        global $cart;
        if (IS_ADMIN_FLAG == false && $_SESSION['cart']->show_weight() == 0) {
          $this->enabled = false;
        }
    
    This allows it to work in the Admin and the Catalog ...

    Notice I am using the $_SESSION['cart']->show_weight() as the $shipping_weight is not available at this point ...
    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!

  7. #7
    Join Date
    Apr 2008
    Location
    Covington, Washington, United States
    Posts
    205
    Plugin Contributions
    1

    Default Re: Switch from one shipping module to another dependent on product variables

    That makes sense. I will give this a shot. Thank you!
    Posted via Mobile Device

  8. #8
    Join Date
    Apr 2008
    Location
    Covington, Washington, United States
    Posts
    205
    Plugin Contributions
    1

    Default Re: Switch from one shipping module to another dependent on product variables

    Ajeh, another thing I appreciate is that you provide a "why" anytime you use code in a post. It helps all of us learn as opposed to just having the answer. Thanks again, your posts on every thread always seem to help me.
    Posted via Mobile Device

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

    Default Re: Switch from one shipping module to another dependent on product variables

    You are most welcome ... glad to be able to help you out ...
    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!

  10. #10
    Join Date
    Dec 2009
    Posts
    19
    Plugin Contributions
    0

    Default Re: Switch from one shipping module to another dependent on product variables

    Ajeh,
    I have installed this mod but have been running into problems when people change items in their cart after going to checkout page 1. I want to have it set so that any package below .813 lbs will only offer the table rate that equates to USPS First class, all packages over that weight ship UPS. This works great as long as they don't edit items in their cart. If they start off with an order less than .813lbs and go to checkout page 1, and then go back and add enough product to go over the weight limit it gets messy. Returning to checkout page 1 only shows the UPS option, but its not selected. USPS is still selected though not displayed. It works inversely going from a heavier order to a lighter order as well. Some times I will see both shipping options. I have also noticed that sometimes when the address has changed both shipping options will pop up when only one should be displayed. In order to clear the unwanted shipping options, I sometimes have to empty the cart and then log out and log back in.

    I put the code above into table.php, but wonder if it should be somewhere else?

    I am running version 1.3.9e
    Thanks
    Craig

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v154 Passing variables FROM the store TO another portion of site
    By ShortHorse in forum General Questions
    Replies: 0
    Last Post: 26 Jun 2015, 06:02 PM
  2. v151 Import product from one ZC store to another
    By shags38 in forum General Questions
    Replies: 10
    Last Post: 7 Jun 2015, 06:21 AM
  3. Shipping method dependent on one product
    By mdo82 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 21 Feb 2011, 07:49 PM
  4. Dependent variables (javascript?)
    By travellers in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 26 Nov 2008, 06:20 PM
  5. how to copy attributes from one product to another?
    By gsdcypher in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 21 Jun 2007, 06:15 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