Forums / Built-in Shipping and Payment Modules / Shipping options question...

Shipping options question...

Started by voltar on 25 Apr 2011, 3:30 PM · Views: 3,107

Results 1 to 20 of 26
25 Apr 2011, 3:30 PM
#1
voltar avatar

voltar

New Zenner

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

Shipping options question...

I want to offer free USA shipping on a few categorizes and leave the others alone. I accomplished this by setting the weight of these products to 0 and setting free shipping options to weight <=0 to activate the free shipping option. In order to exclude international orders from the free shipping option I set zones for USA only. This all works great but although international orders are excluded from the free shipping option, having the weight set to 0 for this set of products the international shipping doesn't calculate properly. I am running ZC ver1.3.9h

Is there a way to accomplish this? Thanks.

25 Apr 2011, 3:41 PM
#2
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

What shipping method(s) are you using for International and the other Products that are not Free Shipping? :unsure:

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!

25 Apr 2011, 4:04 PM
#3
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

I'm using the stock modules for UPS and USPS. We show UPS but no international customers have ever selected it. They always choose USPS. Thanks.

25 Apr 2011, 5:32 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

When the Cart contains only Always Free Shipping and the customer is a US customer, do you want to:

1 Only see Free shipping ...

2 Or, see the Free shipping and the other shipping modules for UPS and USPS ...

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!

25 Apr 2011, 5:50 PM
#5
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

2 would be the best choice. I always want the customer to have the option of selecting free shipping along with all of the other shipping options in case they would prefer to have another shipping method ie. Express or UPS. Many of my customers seem to order at the last minute and they need the other option. Thanks.

25 Apr 2011, 6:01 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

First, create a Zone for the US and include in the Details what the US should be ...

Add the Zone to the Modules ... Shipping ... FREE SHIPPING! freeshipper shipping module ...

Next, you need to customize the code in:
/includes/classes/shipping.php

and around line 65 change the code:

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

// bof: add back in the Free Shipping Weight
    global $order, $cart;
      $total_weight += $_SESSION['cart']->free_shipping_weight();
// eof: add back in the Free Shipping Weight


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

Now, add Weight to ALL Products and the ones that should offer Free Shipping for the US mark as Always Free Shipping ...

What should happen is that the US, based on your US Zone Definition, should see the FREE SHIPPING! freeshipper and ALL of the other shipping methods ... any one else will only see ALL of the other shipping methods, excluding the FREE SHIPPING! freeshipper ...

You can then customize the Language file for the FREE SHIPPING! freeshipper shipping module to read as you would like to see it ...

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!

25 Apr 2011, 8:16 PM
#7
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

I have a zone configured under zone definitions for the USA with the country set to US with all zones included. I have the USA selected as the zone for Free Shipping! and Free Shipping Options with both enabled. I've modified the shipping.php code however the file wasn't located in the /includes/modules/ directory, it was in the /includes/classes/ directory. ?

I added weight back to the products via the attributes since that is how the products are configured and set the products to Always Free Shipping. When adding a US order, only the Free Shipping option appears without the other shipping options. The same is true for international orders.

Basically, the Free Shipping function is overriding everything else when it is set. I'm sure I've missed something. I've verified that my zones are working correctly because the free shipping option, <=0, works for USA and not international. The location of the shipping.php file is a mystery.

Thank you.

25 Apr 2011, 8:28 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

Good catch on the shipping.php it is in the :
/includes/classes

I missed one set of changes:
/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);
//    }

/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);
//    }

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!

25 Apr 2011, 9:03 PM
#9
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

It looks like we are beating this thing into submission. The only thing left is the Free Shipping image that comes along with the Free Shipping! module. Should I just change it to a null image or is there a more creative way to deal with it? Thanks.

25 Apr 2011, 9:03 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

Add something for the USA at the bottom of it ... :smile:

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!

25 Apr 2011, 9:08 PM
#11
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

Will do. Sometimes the simple way is the best way. Thanks a lot for your help.

25 Apr 2011, 9:26 PM
#12
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

After further review... It appears that when an item is added to the cart that does not qualify for Free Shipping, the entire weight of the cart is being used to calculate the shipping charge instead of just the items that are not free shipping. The weight shown on the cart shows only the non free shipping items but the cost is for the entire cart weight.

I added a free shipping item to the cart and the free shipping option displayed. I then added a light weight item that should have invoked a First Class Mail option but it only came back with a Priority option signifying the total weight was passed for the calculation. I verified this by removing the Free Shipping item and the First Class option was then made available. Does this make sense? Thanks.

25 Apr 2011, 9:30 PM
#13
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

You said you wanted the Free Shipping to show and the additional shipping modules to show for other methods of shipping ...

Currently, this includes the full weight ...

Are you saying on the Additional shipping methods that you want the weight removed for the US customers for the Free Shipping products?

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!

25 Apr 2011, 9:33 PM
#14
voltar avatar

voltar

New Zenner

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

Re: Shipping options question...

many apologies. That is correct. I want to deliver the free shipping products as such regardless of the rest of the order. I should have stated that initially. Thank you.

23 Feb 2012, 2:11 PM
#15
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: Shipping options question...

hello all

i have followed all steps and i could show the all shipping options in the shopping cart now, even if the cart only contain AWALYS FREE SHIPPING PRODUCT.

but i could not make the shopping cart to calculate the actual weight. the shopping cart still shows weight = 0 for AWALYS FREE SHIPPING PRODUCT.

i am using zen cart 1.5 now, is it something being modified for the new 1.5 version? thank you.

23 Feb 2012, 3:24 PM
#16
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

What shipping modules do you have installed?

Who is suppose to get Free Shipping when the products are marked as Always Free Shipping?

Do you have weight set on all of your Products, both those marked Always Free Shipping and regular Products?

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!

23 Feb 2012, 3:46 PM
#17
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: Shipping options question...

hi ajeh,

thank you for your reply.

shipping modules used : perunitweight and zone
all buyers are supposed to get free shipping for products with ALWAYS FREE SHIPPING, we provide free international shipping.

yes we have set the weight for all products, including the ALWAYS FREE SHIPPING products.
i have followed your #6 post and made the changes, i then tested with one of the ALWAYS FREE SHIPPING product, with weight set to 2lbs, when added to cart, the weight is still 0

thank you.

23 Feb 2012, 4:24 PM
#18
ajeh avatar

ajeh

Oba-san

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

Re: Shipping options question...

Make sure that you edit your shipping modules and have commented out the part that turns them off on Always Free Shipping ...

Example: for Per Unit perweightunit you would have:

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

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!

23 Feb 2012, 4:50 PM
#19
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: Shipping options question...

yes this step has been done.
and the shipping option is available for ALWAYS FREE SHIPPING product.

the only problem is the weight problem, the weight is still 0 when the ALWAYS FREE SHIPPING product added to the cart, i confirmed that the weight is set to 2 for that product. but the cart shown 0 weight.

23 Feb 2012, 4:55 PM
#20
kitkitng avatar

kitkitng

New Zenner

Join Date:
Dec 2010
Posts:
44
Plugin Contributions:
0

Re: Shipping options question...

i am using zen cart 1.5 and as you said in #6 post,
Next, you need to customize the code in:
/includes/classes/shipping.php

and around line 65 change the code:

// bof: add back in the Free Shipping Weight
    global $order, $cart;
      $total_weight += $_SESSION['cart']->free_shipping_weight();
// eof: add back in the Free Shipping Weight

but for my shipping.php, it's at line 133

i will post the full code below
/includes/classes/shipping.php

<?php

/**

 * shipping class

 *

 * @package classes

 * @copyright Copyright 2003-2010 Zen Cart Development Team

 * @copyright Portions Copyright 2003 osCommerce

 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

 * @version $Id: shipping.php 15880 2010-04-11 16:24:30Z wilt $

 */

if (!defined('IS_ADMIN_FLAG')) {

  die('Illegal Access');

}

/**

 * shipping class

 * Class used for interfacing with shipping modules

 *

 * @package classes

 */

class shipping extends base {

  var $modules;



  // class constructor

  function shipping($module = '') {

    global $PHP_SELF, $messageStack;



    if (defined('MODULE_SHIPPING_INSTALLED') && zen_not_null(MODULE_SHIPPING_INSTALLED)) {

      $this->modules = explode(';', MODULE_SHIPPING_INSTALLED);



      $include_modules = array();



      if ( (zen_not_null($module)) && (in_array(substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)), $this->modules)) ) {

        $include_modules[] = array('class' => substr($module['id'], 0, strpos($module['id'], '_')), 'file' => substr($module['id'], 0, strpos($module['id'], '_')) . '.' . substr($PHP_SELF, (strrpos($PHP_SELF, '.')+1)));

      } else {

        reset($this->modules);

        while (list(, $value) = each($this->modules)) {

          $class = substr($value, 0, strrpos($value, '.'));

          $include_modules[] = array('class' => $class, 'file' => $value);

        }

      }



      for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) {

        //          include(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/shipping/' . $include_modules[$i]['file']);

        $lang_file = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/shipping/', $include_modules[$i]['file'], 'false');

        if (@file_exists($lang_file)) {

          include_once($lang_file);

        } else {

          if (IS_ADMIN_FLAG === false && is_object($messageStack)) {

            $messageStack->add('checkout_shipping', WARNING_COULD_NOT_LOCATE_LANG_FILE . $lang_file, 'caution');

          } else {

            $messageStack->add_session(WARNING_COULD_NOT_LOCATE_LANG_FILE . $lang_file, 'caution');

          }

        }

        $this->enabled = TRUE;

        $this->notify('NOTIFY_SHIPPING_MODULE_ENABLE', $include_modules[$i]['class']);

        if ($this->enabled)

        {

          include_once(DIR_WS_MODULES . 'shipping/' . $include_modules[$i]['file']);

          $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];

        }

      }

    }

  }



  function calculate_boxes_weight_and_tare() {

    global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;

// bof: add back in the Free Shipping Weight
    global $order, $cart;
      $total_weight += $_SESSION['cart']->free_shipping_weight();
// eof: add back in the Free Shipping Weight

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

      $shipping_quoted = '';

      $shipping_num_boxes = 1;

      $shipping_weight = $total_weight;



      $za_tare_array = preg_split("/[:,]/" , SHIPPING_BOX_WEIGHT);

      $zc_tare_percent= $za_tare_array[0];

      $zc_tare_weight= $za_tare_array[1];



      $za_large_array = preg_split("/[:,]/" , SHIPPING_BOX_PADDING);

      $zc_large_percent= $za_large_array[0];

      $zc_large_weight= $za_large_array[1];



      // SHIPPING_BOX_WEIGHT = tare

      // SHIPPING_BOX_PADDING = Large Box % increase

      // SHIPPING_MAX_WEIGHT = Largest package



      /*

      if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {

        $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;

      } else {

        $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);

      }

      */



      switch (true) {

        // large box add padding

        case(SHIPPING_MAX_WEIGHT <= $shipping_weight):

          $shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight;

          break;

        default:

        // add tare weight < large

          $shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight;

          break;

      }



      if ($shipping_weight > SHIPPING_MAX_WEIGHT) { // Split into many boxes

//        $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);

        $zc_boxes = zen_round(($shipping_weight/SHIPPING_MAX_WEIGHT), 2);

        $shipping_num_boxes = ceil($zc_boxes);

        $shipping_weight = $shipping_weight/$shipping_num_boxes;

      }

    }

    $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_BOXES_AND_TARE');

  }



  function quote($method = '', $module = '', $calc_boxes_weight_tare = true) {

    $quotes_array = array();



    if ($calc_boxes_weight_tare) $this->calculate_boxes_weight_and_tare();



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

      $include_quotes = array();



      reset($this->modules);

      while (list(, $value) = each($this->modules)) {

        $class = substr($value, 0, strrpos($value, '.'));

        if (zen_not_null($module)) {

          if ( ($module == $class) && ($GLOBALS[$class]->enabled) ) {

            $include_quotes[] = $class;

          }

        } elseif ($GLOBALS[$class]->enabled) {

          $include_quotes[] = $class;

        }

      }



      $size = sizeof($include_quotes);

      for ($i=0; $i<$size; $i++) {

        $quotes = $GLOBALS[$include_quotes[$i]]->quote($method);

        if (is_array($quotes)) $quotes_array[] = $quotes;

      }

    }

    $this->notify('NOTIFY_SHIPPING_MODULE_GET_ALL_QUOTES', $quotes_array);

    return $quotes_array;

  }



  function cheapest() {

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

      $rates = array();



      reset($this->modules);

      while (list(, $value) = each($this->modules)) {

        $class = substr($value, 0, strrpos($value, '.'));

        if ($GLOBALS[$class]->enabled) {

          $quotes = $GLOBALS[$class]->quotes;

          $size = sizeof($quotes['methods']);

          for ($i=0; $i<$size; $i++) {

            //              if ($quotes['methods'][$i]['cost']) {

            if (isset($quotes['methods'][$i]['cost'])){

              $rates[] = array('id' => $quotes['id'] . '_' . $quotes['methods'][$i]['id'],

                               'title' => $quotes['module'] . ' (' . $quotes['methods'][$i]['title'] . ')',

                               'cost' => $quotes['methods'][$i]['cost'],

                               'module' => $quotes['id']

              );

            }

          }

        }

      }



      $cheapest = false;

      $size = sizeof($rates);

      for ($i=0; $i<$size; $i++) {

        if (is_array($cheapest)) {

          // never quote storepickup as lowest - needs to be configured in shipping module

          if ($rates[$i]['cost'] < $cheapest['cost'] and $rates[$i]['module'] != 'storepickup') {

            $cheapest = $rates[$i];

          }

        } else {

          if ($rates[$i]['module'] != 'storepickup') {

            $cheapest = $rates[$i];

          }

        }

      }

      $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_CHEAPEST', $cheapest);

      return $cheapest;

    }

  }

}