Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Shipping Module Programming Question about weight and free shipping

Shipping Module Programming Question about weight and free shipping

Views: 7,629

Results 41 to 60 of 60
29 Jul 2011, 1:19 PM
#41
ajeh avatar

ajeh

Oba-san

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

Shipping Module Programming Question about weight and free shipping

Either you want the Free Shipping US Products to be setup as:

Mixed Cart -
UPS - total weight of order
USPS -total weight of order

Or, you want the Mixed Cart to be
UPS - weight of total order less Free Shipping
USPS - weight of total order less Free Shipping

Free Shipping ONLY Products in cart:
Free Shipping
UPS - total weight of order
USPS -total weight of order

Or, you want the Free Shipping ONLY Products in the cart:
Free Shipping
UPS - weight of total order less Free Shipping
USPS - weight of total order less Free Shipping

Which way do you want it?

29 Jul 2011, 1:45 PM
#42
voltar avatar

voltar

New Zenner

Join Date:
Apr 2011
Posts:
80
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

Is this do-able?

Mixed Cart:
UPS - total weight of order
USPS (Priority Mail) - weight of total order less Free Shipping
(Only display Priority Mail option for USPS)

Free Shipping ONLY Products in cart:
Free Shipping
UPS - total weight of order
USPS -total weight of order

29 Jul 2011, 2:28 PM
#43
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

This is not by any stretch easy to do ...

Going to need to take a real long think on it ... :blink:

29 Jul 2011, 2:34 PM
#44
voltar avatar

voltar

New Zenner

Join Date:
Apr 2011
Posts:
80
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

The reasoning behind the idea is that I can still give the customer a discounted reasonable shipping option (Priority Mail) for a mixed cart without the opportunity for confusion of them being able to select an express option at an unrealistic price that would be based only on the non Free Ship items in the cart. And at the same time give them the opportunity to pay for express for the total cart if they so choose.

Seems like a win-win... if it's possible of course. Thanks.

29 Jul 2011, 3:03 PM
#45
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

This is a problem:
Mixed Cart:
UPS - total weight of order
USPS (Priority Mail) - weight of total order less Free Shipping
(Only display Priority Mail option for USPS)

You have one shipping method with total weight and the other with total weight less the Free Shipping weight ...

vs the other scenario where both use the total weight ...

29 Jul 2011, 3:23 PM
#46
voltar avatar

voltar

New Zenner

Join Date:
Apr 2011
Posts:
80
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

True. I see how this could be difficult.

Is this the impossible dream?

29 Jul 2011, 4:34 PM
#47
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

It would really take quite a bit of customization to manage to have the shipping modules working off two different methods with USP using one method and USPS using another ...

29 Jul 2011, 4:54 PM
#48
voltar avatar

voltar

New Zenner

Join Date:
Apr 2011
Posts:
80
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

If I'm the only one that desires this sort of thing then it's really not worth the effort. Maybe if enough other Zen Cart users decide they would like really creative shipping options this could grow some legs... one day. Thanks for the assistance.

18 Nov 2011, 5:30 AM
#49
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

Hi-
I’m hoping this thread isn’t dead as it’s SO close to solving my problem. I am trying to do something similar as to what's been discussed here. I want to have specific products that are free shipping to US customers only. The 3 things I want in the shipping calculations are:

  1. All Free Shipping Items:
  • Free Shipping
    AND
    -Choice of other USPS shipping methods
  1. Mixed Cart:
  • Price of USPS shipping cost for weight of only NOT free shipping items
  1. International Cart:
    -Choice of USPS shipping methods (regardless of “always free shipping” being marked on the item. i.e. no free shipping)

I first attempted the instructions in post #11 with no luck. It just messed up my shipping calculator completely.

Then I followed the instructions on post #39. It appears that this is supposed to do everything I want and it did accomplish #1 and 3 above. The only thing that is not working is how I would like is the mixed cart. It appears to still be calculating the shipping costs for a mixed cart based on the entire cart weight. Is there a step missing to post #39 or any ideas on why this is not working?

Any help is greatly appreciated!

18 Nov 2011, 3:07 PM
#50
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

This sort of makes sense on what you want but you need to expand on the 1st one vs the 2nd one as that makes no sense:

  1. All Free Shipping Items:
  • Free Shipping
    AND
    -Choice of other USPS shipping methods
  1. Mixed Cart:
  • Price of USPS shipping cost for weight of only NOT free shipping items

If I have an Always Free shipping cart of 7lbs ... I am getting the choices of:
Free Shipping
USPS for 7lbs
UPS for 7lbs

But if I add a NON Free Shipping of 0.10 lbs ... I get:
USPS for 0.10lbs

So, being a savvy shopper ... I just find the cheapest lowest weight product to get my order for less shipping than ordering all Always Free Shipping Products to get a fast method of shipping ...

18 Nov 2011, 3:10 PM
#51
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

I've searched everywhere for this with no luck. I am using the USPS shipping module. Currently I only offer First Class or Priority Mail shipping. I would like to be able to offer various Flat Rate Boxes shipping options but I need to set some limits on them. I can't ship a large order in just a Small Flat Rate box.

What I want to do is actually limit these options based on the Order Total (not order weight). Is this possible?

18 Nov 2011, 3:35 PM
#52
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

Well, for #1, what I did already does show that. And yes, if you're smart you'd choose Free Shipping not the other shipping methods. But there's the occasional weird shopper that want's to KNOW they've paid for Priority mail or whatever. But like I said, with what you showed in post #39 - it already accomplished my goal #1 and #3.

The only issue remaining is the #2 - the mixed cart.

But if I add a NON Free Shipping of 0.10 lbs ... I get:
USPS for 0.10lbs

That's what I want, but in my tests, that's not happening. If I add a free shipping item of 1.5 lb I get the Free Shipping Option and the Priority Mail option of about $10.

BUT, if I add a non-free shipping item of another 1.7 lb to that, I now do not see the Free Shipping Option (which is correct), but the Priority Mail Option shows $16 (the price for 3+ lbs., not just the 1.7 lb it should be). This is the part that isn't correct. The cart should show shipping costs for ONLY the 1.7 lb non-free shipping item.

18 Nov 2011, 5:47 PM
#53
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

Make sure ALL Products have weight to them ...

For Products with Free Shipping to the US, mark those as:
Always Free Shipping

To have it so that a shopping cart of:

1 ALL Always Free Shipping
Free Shipping
USPS for FULL weight of Always Free Shipping

2 MIXED Cart
USPS for weight of ONLY Products NOT Always Free Shipping

3 International
USPS for FULL weight regardless of Always Free Shipping

Try this ...

Make your Zone Definition for the US and check what it's zID is in the URL ... that number should be used where you see the 21 for the:

        $valid_zone_id = 21;

to your zID ...

edit the file:
/includes/classes/shipping.php

and use this code in RED:

  function calculate_boxes_weight_and_tare() {
    global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

// bof: allow 1 zone only for Always Free Shipping
//echo '<br>Starting weight: ' . $total_weight . '<br>';
    global $db, $order, $cart;
        $valid_zone_id = 21;
        $check_flag = false;
        $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $valid_zone_id . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
        while (!$check->EOF) {
          if ($check->fields['zone_id'] < 1) {
            $check_flag = true;
            break;
          } elseif ($check->fields['zone_id'] == $order->delivery['zone_id']) {
            $check_flag = true;
            break;
          }
          $check->MoveNext();
        }

        // if not valid_zone_id
        if ($check_flag == false) {
          $total_weight += $_SESSION['cart']->free_shipping_weight;
//echo 'International ' . $total_weight . '<br>';
        }

        // if not valid_zone_id
        if ($check_flag == true) {
          if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {
            // add in weight if NOT ALL Always Free shipping
            $total_weight += $_SESSION['cart']->free_shipping_weight;
//echo 'USA ALL FREE add weight ' . $total_weight . '<br>';
          } else {
            // do not add in weight if ALL Always Free shipping
//echo 'USA MIXED just non free shipping ' . $total_weight . '<br>';
          }
        }
// bof: allow 1 zone only for Always Free Shipping


    if (is_array($this->modules)) {

The USPS shipping module:
/includes/modules/shipping/usps.php

should have:

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

The Free Shipping Options freeoptions:
/includes/modules/shipping/freeoptions.php

Make sure that you have that set for:
Total >= 0.00

and you should then have the US Zone set on it ...

Then, you should have the code in RED:

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

// bof: Always Free Shipping
      if (!IS_ADMIN_FLAG) {
        global $cart;
        if ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1') == $_SESSION['cart']->count_contents()) {
          $this->enabled = true;
        } else {
          $this->enabled = false;
        }
      }
// eof: Always Free Shipping

      if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREEOPTIONS_ZONE > 0) ) {

Does this do what you are trying to do here?

I would really consider how you are managing the US Free Shipping Only vs the US Mixed Cart ... make sure you really want to charge for the USPS in this manner ...

Put in your heaviest Always Free Shipping Product and look at the shipping ...

Now add in your lightest NOT Always Free Shipping Product ... and look at the shipping ... are you sure you want it to work like that? :unsure:

18 Nov 2011, 6:34 PM
#54
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

Yes, this worked!! I know I had tried one of your solutions using freeoptions instead of freeshipper before, but maybe you added a few more lines of code! Also, not sure if I changed the zone code before. Either way, thanks a bunch!!

Now add in your lightest NOT Always Free Shipping Product ... and look at the shipping ... are you sure you want it to work like that?

Yes, this is exactly how I want it to look. I'm not sure I'm even seeing the problem you're alluding to here?

And maybe I'm the only one, but we get these strange customers now and again who pay out-the-wazoo just to ensure they received priority mail instead of first class shipping. I'm sure that'll be the case with the free shipping items on rare occasions too - thus allowing for ALL the options.

18 Nov 2011, 7:12 PM
#55
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

I added some extra code to make it do the bizzaro thing you wanted ... :blink:

What I am saying is, if I have a 7lb Always Free Shipping in the cart, I get:
Free shipping
USPS for 7lbs

If I then add a 0.10 lb NOT Always Free Shipping to the cart, I now get:
USPS for 0.10lbs

So this gives me a way to select USPS for dirt cheap faster USPS for 0.10lbs by just adding a cheap low weight 0.10lb product to the order to get a fast method of shipping for the whole 7.10lb order where before I had to pay for the faster USPS 7lbs -- or -- get the Free Shipping ...

18 Nov 2011, 7:32 PM
#56
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

Ah, I see what you mean. I guess I should have clarified that I ONLY ship First Class or Priority Mail (and those are the only options I have set to show in the cart). So if they select a heavy free shipping item, then I've already taken the shipping cost into account and adding any small not-free shipping item still won't allow them to select Express or other faster/more expensive shipping methods.

18 Nov 2011, 7:49 PM
#57
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

So I have 12lbs of Always Free Shipping in the cart and by shipping choices are:

Free Shipping
United States Postal Service (1 x 12.00lbs) (Priority Mail (2 - 3 days)) $13.00

I add a 0.10 non-free shipping to the cart, in addition to the 12lbs Always Free Shipping so now I have:

United States Postal Service (1 x 0.10lbs) (Priority Mail (2 - 3 days)) $5.10

Is that really what you want to happen?

18 Nov 2011, 7:59 PM
#58
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

Yep. If I say the 12lbs of product is free shipping, then I've already priced them accordingly. Then if they add a like 0.10 non-free shipping item, it actually shows them options of First Class Shipping for $2.40 or Priority Mail for $5.79. So yes, they can order 12.1 lbs of product for a total shipping of only $2.40.

18 Nov 2011, 8:02 PM
#59
ajeh avatar

ajeh

Oba-san

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

Re: Shipping Module Programming Question about weight and free shipping

So the idea is you do not lose either way ... and the customer can make out if they figure out how your shipping works ... and just add that cheap, low weight product to the cart ... correct? :unsure:

18 Nov 2011, 9:29 PM
#60
xariessa avatar

xariessa

New Zenner

Join Date:
Jul 2009
Location:
California
Posts:
18
Plugin Contributions:
0

Re: Shipping Module Programming Question about weight and free shipping

It's really not that complicated... ;) The customer will be able to know if they're buying a free shipping item before adding it to their cart. And if they add that cheap, low-shipping item to their cart, it really does nothing more for the customer unless they WANT the item. It's basically just buying the items they want - some they don't have to pay the shipping costs for - some they do. The cart now shows that pretty clearly I think, and if not, I do plan on adding a little note as to why the Free Shipping option doesn't show for a mixed cart.