Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Free shipping on one category and one zone only

Free shipping on one category and one zone only

Views: 2,177

Results 1 to 20 of 20
3 Nov 2014, 3:44 PM
#1
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Free shipping on one category and one zone only

I want to offer Free Shipping on certain products to only one zone.
At the Free shipping shipping module I selected the relevant zone.
But if I enable free shipping at those products it enables free shipping on all zones.

What am I doing wrong?

3 Nov 2014, 3:58 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

What version of Zen Cart are you using?

What Shipping Module(s) are you using?

3 Nov 2014, 4:23 PM
#3
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

Version v1.5.1
I tried both the "freshipper" and "freeoptions" modules with the same results

3 Nov 2014, 4:34 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

Could you share with me the Shipping Module(s) you will be using for Normal Products, please?

3 Nov 2014, 5:10 PM
#5
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

I use the table module for normal local products and for international parcels i use zones module

BUT I got the freeoptions to work now BUT there is still a problem. It now shows a value for local shipment (which is supposed to be free).
The amount it ads to local courier is far less than it would normally be.

At least now free shipment is not offered to International clients no more which is one step in the right direction.

3 Nov 2014, 5:16 PM
#6
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

Sorry, freeoptions is still not working, there was a product in the cart which is not marked "free shipping"

3 Nov 2014, 5:21 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

On your Table Rate and Zone Rate shipping modules, are they based on Weight?

3 Nov 2014, 5:24 PM
#8
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

yes they are based on weight

3 Nov 2014, 5:33 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

It will be a bit before I have all of the custom code for this to allow Free Shipping based on Always Free Shipping only to the Zones that you want to allow this for, but I should have it soon ...

Have you already defined a Zone and added it to the FREE SHIPPING! freeshipper shipping module for those allowed to have Free Shipping?

3 Nov 2014, 5:40 PM
#10
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

Yes, I added the relevant zone, but I now use freeoptions. I just read in the Zen Cart book that freeshipper will disable all other shipping options I have.

3 Nov 2014, 6:23 PM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

If you create a Zone Definition for who IS allowed to have Free Shipping for Products marked as Always Free Shipping, and add that Zone to the FREE SHIPPING! freeshipper shipping module ...

you can add the following code customizations in RED:
/includes/classes/shipping.php

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

[B]// bof: allow 1 zone only for Always Free Shipping
// Always Free Shipping added back except for anyone in MODULE_SHIPPING_FREESHIPPER_ZONE
    global $db, $order, $cart;
        $valid_zone_id = MODULE_SHIPPING_FREESHIPPER_ZONE;
        $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;
        }
// Always Free Shipping added back except for anyone in MODULE_SHIPPING_FREESHIPPER_ZONE
// eof: allow 1 zone only for Always Free Shipping
[/B]
    $this->abort_legacy_calculations = FALSE;
    $this->notify('NOTIFY_SHIPPING_MODULE_PRE_CALCULATE_BOXES_AND_TARE');

/includes/modules/shipping/table.php

[B]// bof: allow 1 zone only for Always Free Shipping
//[/B]      if (zen_get_shipping_enabled($this->code)) {
      $this->enabled = ((MODULE_SHIPPING_TABLE_STATUS == 'True') ? true : false);
[B]//[/B]    }
[B]// eof: allow 1 zone only for Always Free Shipping
[/B]
    if ($this->enabled) {
      // check MODULE_SHIPPING_TABLE_HANDLING_METHOD is in
      $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_TABLE_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_TABLE_HANDLING_METHOD', 'Order', 'Do you want to charge Handling Fee Per Order or Per Box?', '6', '0', 'zen_cfg_select_option(array(\'Order\', \'Box\'), ', now())");
      }
    }

[B]// bof: allow 1 zone only for Always Free Shipping
// Always Free Shipping added back except for anyone in MODULE_SHIPPING_FREESHIPPER_ZONE
if (!IS_ADMIN_FLAG) {
    global $order, $db;
//echo 'I see quantity: ' . ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping', 1)) . '<br>';

        $valid_zone_id = MODULE_SHIPPING_FREESHIPPER_ZONE;
        $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) {
          if ($_SESSION['cart']->count_contents() == $_SESSION['cart']->in_cart_check('product_is_always_free_shipping', 1)) {
            $this->enabled = false;
          } else {
            $this->enabled = true;
          }
        } else {
          $this->enabled = true;
        }
      }
// bof: allow 1 zone only for Always Free Shipping
[/B]
    if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_TABLE_ZONE > 0) ) {

/includes/modules/shipping/zones.php

      // disable only when entire cart is free shipping
[B]// bof: allow 1 zone only for Always Free Shipping
//[/B]      if (zen_get_shipping_enabled($this->code)) {
        $this->enabled = ((MODULE_SHIPPING_ZONES_STATUS == 'True') ? true : false);
[B]//[/B]      }
[B]// eof: allow 1 zone only for Always Free Shipping
[/B]
      // CUSTOMIZE THIS SETTING FOR THE NUMBER OF ZONES NEEDED
      $this->num_zones = 3;

[B]// bof: allow 1 zone only for Always Free Shipping
// Always Free Shipping added back except for anyone in MODULE_SHIPPING_FREESHIPPER_ZONE
if (!IS_ADMIN_FLAG) {
    global $order, $db;
//echo 'I see quantity: ' . ($_SESSION['cart']->in_cart_check('product_is_always_free_shipping', 1)) . '<br>';

        $valid_zone_id = MODULE_SHIPPING_FREESHIPPER_ZONE;
        $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) {
          if ($_SESSION['cart']->count_contents() == $_SESSION['cart']->in_cart_check('product_is_always_free_shipping', 1)) {
            $this->enabled = false;
          } else {
            $this->enabled = true;
          }
        } else {
          $this->enabled = true;
        }
      }
// bof: allow 1 zone only for Always Free Shipping
[/B]
      if (IS_ADMIN_FLAG === true) {
      // build in admin only additional zones if missing in the configuration table due to customization of default $this->num_zones = 3
3 Nov 2014, 6:28 PM
#12
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

Thanx a million.
I will add it now and will let you know

3 Nov 2014, 6:40 PM
#13
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

WOW, Thanks, it is working.
Will do some more tests now to make sure it is working with all the products.

Attachment 14653Attachment 14653

3 Nov 2014, 6:41 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

You are most welcome ... thanks for the update that this is working for you ... :smile:

Remember the Zen Cart Team when you are rich and famous! :cool:

3 Nov 2014, 6:49 PM
#15
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

Ajeh, I have one more question. I use the zone module for my International courier.
If I want to add international airmail on the same basis but different rates, can I just copy and clone the zone module and create a zoneairmail module?

If I can, will the new zoneairmail module be influenced by the free shipping products like the other modules which we have just modified?

3 Nov 2014, 6:55 PM
#16
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

You should be able to clone it and use the same type of modifications ... just be careful when cloning to make all changes so that they are case sensitive ...

3 Nov 2014, 7:03 PM
#17
pietpetoors avatar

pietpetoors

Zen Follower

Join Date:
Jun 2010
Location:
South Africa
Posts:
140
Plugin Contributions:
0

Re: Free shipping on one category and one zone only

Remember the Zen Cart Team when you are rich and famous!
I will :D

3 Nov 2014, 7:08 PM
#18
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

You might peek in the Plugins ... I have not looked at this in a long time, but I made a couple clones of Zone Rate zones:
http://www.zen-cart.com/downloads.php?do=file&id=977

3 Nov 2014, 9:01 PM
#19
ajeh avatar

ajeh

Oba-san

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

Re: Free shipping on one category and one zone only

I made some minor code changes on my post that may or may not be needed for issues with REMOVE/INSTALL in the Admin ...

If you run into an issue, see if the changes help ...