Forums / Addon Shipping Modules / Shipping module setting weight independent of number of items ordered

Shipping module setting weight independent of number of items ordered

Started by arunachala on 3 Jul 2011, 1:22 AM · Views: 2,250

Results 1 to 18 of 18
3 Jul 2011, 1:22 AM
#1
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Shipping module setting weight independent of number of items ordered

Our store sells large size photographs. The weight of the photographs are based on the weight of the tube that are used to ship them. If a customer orders multiple copies of the same photo I do not want to multiply the weight by the number of items ordered.
For such products I want to set the weight as a negative number and use that as a test to skip the logic for multiplying by the number of units. Of course the weight will be reset to positive equivalent after skiping the weight multiplication. Can somebody please guide me to the file where this calculation is done. Thanks in advance. The shipping module is USPS.

3 Jul 2011, 7:12 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Shipping module setting weight independent of number of items ordered

Set the amount for one
Add a handling fee for the tube
It will be added only once while the pics will be incremental

Zen-Venom Get Bitten

3 Jul 2011, 12:33 PM
#3
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

We also sell many items which are not photographs. In such a case I am not sure how to set the handling charge for some products only.

3 Jul 2011, 9:13 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Shipping module setting weight independent of number of items ordered

We also sell many items which are not photographs. In such a case I am not sure how to set the handling charge for some products only.
This will require some custom code to make the determination

Advanced Search here for some pointers from Ajeh to another that needed something similar/special for firearms

search term shipping firearms - - with by Ajeh as the user name

Zen-Venom Get Bitten

4 Jul 2011, 6:19 AM
#5
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

Thanks Kobra. I found the thread and it is exactly what I am looking for. I would not have found it myself. Thanks again. Donuts for the team.:smile:

5 Jul 2011, 11:41 PM
#6
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

Our store is at https://www.arunachala.org/bookstore We sell books,
photographs, audio and video. We use USPS and most of the shipping weights are correctly calculated by the shopping cart. Large size photographs are shipped in a tube. The weight of the photograph is small compared to the weight of the tube. When a customer orders four copies of the same photograph the store multiplies the weight of each tube by four and bases the shipping cost on that. For photographs we do not want to do this because many photographs can fit into a single tube and customer needs to pay for one tube weight only regardless of how many similar photographs are purchased..
I had an idea to set the weights for these photographs negative and test for the sign of the weight to skip multiplication with number of items purchased for such photographs. However based on Kobra's reference to thread by Ajeh http://www.zen-cart.com/forum/showthread.php?t=165331
I wanted to set up a similar handling charge based not on category but products. I need to know if it possible to do it on item by item basis. Also what is the name of the variable to check.

5 Jul 2011, 11:54 PM
#7
ajeh avatar

ajeh

Oba-san

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

Re: Shipping module setting weight independent of number of items ordered

Do you use any 0 weight for Free Shipping or Always Free Shipping products?

Have you some products_id of these Products that are shipped by Tube?

If I order 1 Tube Product how much?

If I order 3 Tube Products how much?

If I order 12 Tub Products how much?

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!

6 Jul 2011, 12:28 AM
#8
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

I use 0 or zero weight for magazine subscriptions which are always free shipping. Our volume of sale is usually limited to a max of 3 or 4 copies of the same size. The tube weight is set to say .9 pounds. If a person orders 1 or 3 or 12 identical photogrphs I want the net weight to be 0.9 pounds not .9 times the number purchased. The category ID of one such photo is 5015. There four other items which are shipped this way with different IDs. I am using version 1.3.9f planning to upgrade soon.

6 Jul 2011, 1:35 AM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Shipping module setting weight independent of number of items ordered

You could customize the FREE SHIPPING freeshipper and Flat Rate flat shipping modules ...

Let's assume the Tube Products are products_id 193, 194, 195 and 196 ...

Edit the file:
/includes/modules/shipping/flat.php

and add the code in red:

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

// bof: show if products_id 193, 194, 195 or 196 are in the cart
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart = 0;
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '192');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '193');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '194');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '195');

        $full_count = $_SESSION['cart']->count_contents();

        if ($chk_products_in_cart > 0 && $full_count == $chk_products_in_cart) {
          $this->enabled = true;
        } else {
          $this->enabled = false;
        }
      }
// eof: show if products_id 193, 194, 195 or 196 are in the cart

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

Then, customize the file:
/includes/modules/shipping/freeshipper.php

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

// bof: do not show if products_id 193, 194, 195 or 196 are in the cart
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart = 0;
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '192');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '193');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '194');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '195');

        if ($chk_products_in_cart > 0) {
          $this->enabled = false;
        }
      }
// eof: do not show if products_id 12, 22, 27 or 122 are in the cart

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

Now set the Flat Rate shipping rate to the cost for the Tube Products ...

If you want to use USPS so that you have the USPS shipping rate for 0.9 to obtain all of the methods, you could customize that for the file:
/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);
    }

// bof: show if products_id 193, 194, 195 or 196 are in the cart
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart = 0;
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '192');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '193');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '194');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '195');

        if ($chk_products_in_cart > 0) {
          $this->enabled = true;
        }
      }
// eof: adjust weight if products_id 193, 194, 195 or 196 are in the cart

    if ($this->enabled) {

Then change the code:

    // usps doesnt accept zero weight send 1 ounce (0.0625) minimum
    $usps_shipping_weight = ($shipping_weight <= 0.0 ? 0.0625 : $shipping_weight);

// bof: show if products_id 193, 194, 195 or 196 are in the cart
      if (!IS_ADMIN_FLAG) {
        global $cart;

        $chk_products_in_cart = 0;
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '192');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '193');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '194');
        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '195');

        if ($chk_products_in_cart > 0) {
          if ($shipping_weight <= 0.0) {
            $usps_shipping_weight = 0.9;
          } else {
            $usps_shipping_weight += 0.9;
          }
        }
      }
// eof: adjust weight if products_id 193, 194, 195 or 196 are in the cart

    $shipping_pounds = floor ($usps_shipping_weight);

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!

6 Jul 2011, 2:26 AM
#10
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

Vow I am amazed at the bounty. It will take me time to digest all this. Will report to you after testing it. Thanks a million. Donuts on their way.:smile:

6 Jul 2011, 2:28 AM
#11
ajeh avatar

ajeh

Oba-san

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

Re: Shipping module setting weight independent of number of items ordered

NOTE: I have a goober in the Flat Rate flat.php ... I am not taking into account the mixed cart with Tube Products and non-Tube Products ...

NOTE: if you do not need it, then just ignore the code until I have to to review it again ...

The USPS and FREE SHIPPING! code seems to be working ...

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!

6 Jul 2011, 4:29 AM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Shipping module setting weight independent of number of items ordered

I fixed the flat.php to show only when the number of Products is the same as the Tube 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!

6 Jul 2011, 3:56 PM
#13
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

Thank you for your response. Is it sufficient to apply the mods to USPS module alone? Does the logic require that I set the weight of the tube items zero or negative?

6 Jul 2011, 5:22 PM
#14
ajeh avatar

ajeh

Oba-san

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

Re: Shipping module setting weight independent of number of items ordered

Set the weight on the Tube Products to 0 ...

The code for the FREE SHIPPING! freeshipper and USPS has the customizations for these ...

You just need to set the right products_id values in the code ...

If you need more products_id values you can add them by adding another:

        $chk_products_in_cart += $_SESSION['cart']->in_cart_check('products_id', '195');

below the other ones, where you can change the 195 to the next products_id ...

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 Jul 2011, 12:21 PM
#15
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

Eerything works A OK. God bless zen cart forum:clap:

7 Jul 2011, 12:32 PM
#16
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

One more question. Is tare weight calculation impacted by this mod? It appears tare weight ignores 0.9 for tube products.

7 Jul 2011, 12:39 PM
#17
arunachala avatar

arunachala

Zen Follower

Join Date:
Mar 2009
Location:
New York
Posts:
158
Plugin Contributions:
0

Re: Shipping module setting weight independent of number of items ordered

Never mind I can add it to tube weight!!

7 Jul 2011, 12:56 PM
#18
ajeh avatar

ajeh

Oba-san

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

Re: Shipping module setting weight independent of number of items ordered

Yes the tare is ignored on the Tube as this just assigns a flat weight so you need to add that to the .9 for the Tube Weight ...

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!