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 21 to 40 of 60
28 Jul 2011, 5:05 PM
#21
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

Is the problem you are having just the "display" of the Weight in the Cart?

If so, then you will need to customize the:
/includes/modules/pages/shopping_cart/header_php.php

and change how the weight is calculated:

// build shipping with Tare included
// $shipping_weight = $_SESSION['cart']->show_weight();
$shipping_weight = $_SESSION['cart']->show_weight() + $_SESSION['cart']->free_shipping_weight;

NOTE: many of your Products have Attributes and if they are needed to buy the Product, you should add an Option Value such as:
Pick One
Display Only: YES
Default: YES
Sort Order: 0

so that the customer has to make a selection ...

28 Jul 2011, 5:20 PM
#22
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

Actually, the displayed weight is not a big deal. The shipping cost going up when adding additional free shipping quantities after adding a non-Free Shipping item is what's troubling. Add a bottle of ink to the cart and check the shipping estimator then add a stencil and the Free Shipping option goes away as it should. Then increase the ink bottle quantity and refresh the estimator and the cost will climb as the quantity of the Free Shipping item climbs.

Thanks for the attribute advice. I'll get it done.

28 Jul 2011, 5:25 PM
#23
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

If I want to ship a Product that is marked Always Free Shipping to the US or International ...

There is a Product Weight ... let's say 1lb on Product 1 and 2lbs on Product 2 ...

If I add Product 1 to the Cart ...
the US sees:
Free Shipping Options
UPS (for 1 lb)
USPS (for 1 lb)

the Rest of the World sees:
UPS (for 1 lb)
USPS (for 1 lb)

If I add Product 1 and Product 2 to the Cart ...
the US sees:
Free Shipping Options
UPS (for 3 lb)
USPS (for 3 lb)

the Rest of the World sees:
UPS (for 3 lb)
USPS (for 3 lb)

And the prices go up because there is more weight ...

Add Products that are not Always Free Shipping for the US still makes the weight go up and the UPS and USPS go up for both the US and Rest of the World ...

So what part do you think is behaving oddly? :unsure:

28 Jul 2011, 5:36 PM
#24
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 odd thing is that when increasing the quantity of the Free Shipping items this is causing the shipping cost to go up but only after a non Free Shipping item has been added to the cart. As long as only Free Shipping items are in the cart, the Free Shipping option is available and the other costs should go up since at this point the customer is choosing an alternate form of shipping for whatever reason. Generally to get a more efficient delivery option. The problem is that since the Free Shipping option can no longer be displayed, since a non-Free Shipping item has been added to the cart, the customer's only option is to pay shipping on the entire cart. This would require the customer to place 2 orders. One with only Free Shipping items and another for everything else to get the Free Shipping items for no shipping.

The ideal solution would be to only charge shipping for the non-Free Shipping items in the cart and not charge shipping for the Free Shipping items in the cart. Does this make sense?

28 Jul 2011, 5:46 PM
#25
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

Now I see the problem ... let me think about the solution to see if this issue is related to something in the calculation for the free_shipping_weight ... :blink:

It will probably be awhile before I get back on this ... a couple 3 hours or so ...

28 Jul 2011, 5:49 PM
#26
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

Thanks. I appreciate the assistance.

28 Jul 2011, 7:05 PM
#27
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

Actually that bug was not there ...

What version Zen Cart are you using?

What Specific Products are you testing and how is the weight configured on them for the Product and the Attributes?

More or less can you give me a click for click to reproduce this problem? :unsure:

28 Jul 2011, 8:12 PM
#28
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

ZC v1.3.9h

From the home page click Airbrush Tattoo Ink, Body Paint & Supplies, click Quick Dry Alcohol Based Ink, click Standard Colors, click White Quick Dry, click radio for 8oz. and Add To Cart, click Estimate Shipping, select United States, South Carolina, 29687, click Update. At this point, everything is good.

Go back to the home page. From the home page click Airbrush Tattoo Ink, Body Paint & Supplies, click Stencils, Click Stencils Only, add 1 under Holiday1 and press return to add to cart. Click Estimate Shipping. Notice that the Weight is 0.08lbs. The weight of the stencil, however the First Class Mail Option is no longer displayed. Increase White Quick Dry Quantity to 10 and update cart. Click Estimate Shipping. Notice that all of the shipping charges are increased by adding additional quantities of a Free Shipping item.

The weight for the White Quick Dry Ink is set via the attribute. The weight of the stencil is set in the catalog configuration page.

Is this what you are asking for ?

28 Jul 2011, 8:27 PM
#29
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

If you add more than the 13oz for First Class it will go away ...

As you increase quantity, unless the increase of quanty * the weight actually charges more for shipping then the shipping can be the same for multiple quantities or multiple Products ...

Are you sure the problem isn't just the weight of the shopping cart not raising to the next level for a charge or rising too high for First class?

28 Jul 2011, 8:55 PM
#30
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 adding non-Free Ship items, yes, the First Class option will go away above 13oz. As long as you are only adding Free Ship items, the First Class option remains as a selection. If the cart is full of Free Ship items the First Class option is available but as soon as you add, even a 0.08lbs non-Free Ship item, the First Class option is gone and the shipping charge reflect the weight of the entire cart.

28 Jul 2011, 9:10 PM
#31
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 Free Shipping US Product
/index.php?main_page=product_info&products_id=700

If I add 1 of the 2oz to the cart I have First Class ...

If I add 10 of the 2oz to the cart I DO NOT have First Class ...

This is a Non-Free Shipping Product
/index.php?main_page=product_info&products_id=555

If I add 1 to the cart I have First Class ...

If I add 10 to the cart I DO NOT have First Class ...

If I add 1 of each to the Cart I have First Class ...

If I add 1 Holiday and 2 White Quick Dry 2oz I have First Class ...

If I add 1 Holiday and 4 White Quick Dry 2oz I DO NOT have First Class ...

What do you think 0.08lbs is? If you want 8ounces, that is 0.5lbs ... weight is entered in pounds ...

NOTE: 1 ounce = 0.0625 pounds

Keep in mind All of the Products have weight ... it is hard to see the weight based on how you have things setup since the Weight showing in the Shopping Cart is not adjusted to show the true weight with the free_shipping_weight added in ...

28 Jul 2011, 9:27 PM
#32
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

Everything works great except for whenever a non-Free Shipping item is added to the cart that has Free Shipping items already added, the shipping charge is then reflective of the entire cart weight. Is there a way to make the cart only charge shipping for the non Free Shipping items while not charging shipping for the Free Shipping items when combined in the cart. I was using the stencils as a test since they only weigh about an ounce and should have little impact on the cost to ship.

28 Jul 2011, 9:35 PM
#33
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 thought your goal was to have Free Shipping Options and the Normal shipping rates using the total weights on UPS and USPS ...

Perhaps we are not speaking the same here ...

Do you want the UPS and USPS to be the "normal shipping" rates for the all of the Products?

EXAMPLE:
When the Cart ONLY holds Always Free Shipping US Products ... should the US see UPS and USPS?

If yes, then what are the weights based on?

Right now, it is showing Free Shipping Options ONLY when the Cart is the US and all Products are Always Free Shipping and showing the Total charge for UPS and USPS based on the Weight of those Products ...

28 Jul 2011, 9:48 PM
#34
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

My apologies for any confusion. I believe you have finally opened my eyes. If I don't add the cost of shipping back in when the customer selects a non Free Shipping item, that would potentially give the customer the opportunity to select overnight shipping for a cart full of Free Shipping products. Now I am totally confused as how to deal with Free Shipping and non Free Shipping. Again my apologies for my confused state.

28 Jul 2011, 9:59 PM
#35
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

Here is an option that probably won't work, but when a cart contains Free Ship and non Free Ship items would it be possible to calculate Priority Mail at the Free Ship item weight and the other options at the full cart weight? It would even work to drop all USPS options other than Priority Mail calculated at the Free Ship weight and let UPS calculate at the full cart weight.

29 Jul 2011, 12:16 AM
#36
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

The quote for UPS and USPS for the US is either quote them all as the total weight or quote them all as the total weight less the Free Shipping weight ...

Right now, they are being quoted for the US with the Free Shipping weight added back in ...

If the US quotes were quoted where the shipping quotes for the UPS and USPS only included the weight for the non-Free shipping products would that work?

Meaning a 1.5lb Free Shipping item and a 2lb non-Free Shipping Product would be quoted for a 2lb shipping rate quote with UPS and USPS ...

NOTE: that would mean an totally Free Shipping cart would only quote the Free Shipping Option with no UPS or USPS options ...

29 Jul 2011, 2:29 AM
#37
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 deeper I have gotten into this the muckier it seems to get. The overall goal here was to be able to offer certain products with free US shipping and not international. The problem that I can't seem to get my arms around is if a customer places a large number of Free Shipping items in the cart and than adds a small non-Free Shipping item, they could then select express shipping based on the single non-Free Shipping weight. The concept of Free Shipping is generally the vendor select the most cost effective mean.

Meaning 25lbs of Free Shipping items and a 1lb non-Free Shipping item in the cart would display all shipping options thereby giving the customer the option to select overnight shipping on the order based on 1lb and that is a recipe for losing money quick or make the customer angry.

I suppose it may be hopeless without major revisions to analyze the status of the cart items, Free vs Non-Free, and offer a single low shipping option, say Priority Mail, and list all other options to include the entire cart weight. It seems so easy for Amazon.:smile:

Keeping shipping cost low these days is so important to internet sales but trying to help the customer while not killing your small business is also like walking a tightrope.

Any ideas would be much appreciated.

29 Jul 2011, 3:24 AM
#38
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

Let me think about it for awhile ... I have done something like that before ... I think ... :lamo:

29 Jul 2011, 4:51 AM
#39
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

Okay let's try this one ...

REMOVE the Free Shipping Options freeoptions ...

INSTALL the FREE SHIPPING freeshipper and set the Zone to the US Only ...

Change the shipping class file:
/includes/classes/shipping.php

to read:

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

// Add in Free Weight for anyone not in 1 zone
// bof: allow 1 zone only for Always Free Shipping
    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 ($check_flag == false) {
          $total_weight += $_SESSION['cart']->free_shipping_weight;
        }
// bof: allow 1 zone only for Always Free Shipping

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

Change the UPS file:
/includes/modules/shipping/ups.php

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

    if ($this->enabled) {
      // check MODULE_SHIPPING_UPS_HANDLING_METHOD is in
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_UPS_HANDLING_METHOD'");
      if ($check_query->EOF) {
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_UPS_HANDLING_METHOD', 'Box', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
      }
    }

// bof: turn off if zone 1 and weight is 0
if (!IS_ADMIN_FLAG) {
    global $db, $order, $cart;

        $chk_weight = round($_SESSION['cart']->show_weight(),9);
        $chk_free_weight = round($_SESSION['cart']->free_shipping_weight, 9);

        $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 ($check_flag == true && $chk_weight == 0) {
          $this->enabled = false;
        } else {
          $this->enabled = true;
        }
//    echo '<BR>USPS shipping class delivery: ' . 'chk_weight: ' . $chk_weight . ' chk_free_weight: ' . $chk_free_weight . '<br>checkflag: ' . $check_flag .  '<br> shipping: ' . $order->delivery['country']['id'] . ' state: ' . $order->delivery['state'] . ' zone: ' . $order->delivery['zone']['id'] . '<br><br>';
}
// eof: turn off if zone 1 and weight is 0

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

Change the USPS shipping module:
/includes/modules/shipping/usps.php

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

    if ($this->enabled) {
      // check MODULE_SHIPPING_USPS_HANDLING_METHOD is in
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_USPS_HANDLING_METHOD'");
      if ($check_query->EOF) {
        $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Handling Per Order or Per Box', 'MODULE_SHIPPING_USPS_HANDLING_METHOD', 'Box', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
      }
    }

// bof: turn off if zone 1 and weight is 0
if (!IS_ADMIN_FLAG) {
    global $db, $order, $cart;

        $chk_weight = round($_SESSION['cart']->show_weight(),9);
        $chk_free_weight = round($_SESSION['cart']->free_shipping_weight, 9);

        $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 ($check_flag == true && $chk_weight == 0) {
          $this->enabled = false;
        } else {
          $this->enabled = true;
        }
//    echo '<BR>USPS shipping class delivery: ' . 'chk_weight: ' . $chk_weight . ' chk_free_weight: ' . $chk_free_weight . '<br>checkflag: ' . $check_flag .  '<br> shipping: ' . $order->delivery['country']['id'] . ' state: ' . $order->delivery['state'] . ' zone: ' . $order->delivery['zone']['id'] . '<br><br>';
}
// eof: turn off if zone 1 and weight is 0

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

Now see if a Cart of just Free US Products Only shows the FREE SHIPPING free shipper for the US and shows the UPS and USPS for the International ...

A Cart of Non-Free Shipping Products the US sees UPS and USPS and shows the UPS and USPS for the International ...

And a mixed cart for the US shows the UPS and USPS for only the weight that is not part of the Free Shipping Products and the International UPS and USPS shows the full weight of the Free Shipping Products plus the Non-Free Products ...

29 Jul 2011, 12:49 PM
#40
voltar avatar

voltar

New Zenner

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

Re: Shipping Module Programming Question about weight and free shipping

Thank you so much for your assistance and guidance. Here's my dilemma, if I only give the customer the Free Shipping option with cart full of Free Shipping items, that prevents them from selecting a faster shipping option if they were to be in desperate need.

Next, with a mixed cart of Free Shipping and non Free Shipping items only displaying the shipping cost based on the weight of the non Free Shipping items creates a situation where the customer could theoretically have a cart full of Free Shipping items and then add a single non-Free Shipping items and the full array of shipping options would be displayed using only the weight of the single non-Free Shipping item. As long as the customer chose a reasonable option that would be fine but considering they would be able to select overnight shipping based only on the weight of the single item, who could blame them.

The modifications you have created are perfectly implemented except for this one situation. Thank you again for your unbelievable patience and expertise.