Zen Cart Logo
Forums / Addon Shipping Modules / Item has free shipping if ordered with a another item ??

Item has free shipping if ordered with a another item ??

Views: 1,739

Results 1 to 17 of 17
19 Sep 2015, 12:57 AM
#1
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Item has free shipping if ordered with a another item ??

Hi,

Let me say first the folks on these forums are first rate. Every issue I have had as a newbie has been addressed quickly. On the downside, there are so many topics and posts it is difficult to find succinct information regarding issues. So, hence the post.

What I am attempting to accomplish:
If a given product "B" is ordered with product "A" then there is no charge for product "B" shipping. Otherwise if product "B" is ordered without product "A", (or ordered with any other product other than product "A") then there is a shipping charge for product "B". In other words, if product "B" is ordered with product "A", then only charge for product "A" shipping.

Make sense?
Regards,
Ron

19 Sep 2015, 4:32 PM
#2
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Hi,

Any takers?

19 Sep 2015, 4:38 PM
#3
ajeh avatar

ajeh

Oba-san

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

Re: Item has free shipping if ordered with a another item ??

What shipping module(s) are you using?

19 Sep 2015, 4:39 PM
#4
lruskauff avatar

lruskauff

Totally Zenned

Join Date:
Sep 2008
Location:
WA
Posts:
559
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

I didn't get time to look but check through "that software guys", swguy, plugins. He has a bunch of free and then some for sale that handle stuff like this.

19 Sep 2015, 4:43 PM
#5
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Ajeh:

What shipping module(s) are you using?

The USPS shipping module.
Thanks,
Regards,
Ron

19 Sep 2015, 4:46 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Item has free shipping if ordered with a another item ??

Is this the only Product that gets Free Shipping if Product A is ordered?

19 Sep 2015, 4:54 PM
#7
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Ajeh:

Is this the only Product that gets Free Shipping if Product A is ordered?

Hi,

No, there will be three items available for free shipping if product "A" is ordered. Just a little bit of background. The product "A" is a Amateur radio device and it has three different connector options (and I suppose this would be product "B", "C", or "D".
However , I just had a thought. If it makes it easier I could list only one connector item, product "B" and have the customer fill out the notes section during ordering of which connector option they want since I can make the price for any of the three different connector options will the same.

Make sense?
Regards,
Ron

19 Sep 2015, 5:00 PM
#8
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Hi Again,

Obviously I have not thought this through completely. I could simply list the same device four times. Each one with different connector options (no connectors (product "A" for the purposes of this discussion), connector option "B", connector option "C", or connector option "D").

Regards,
Ron

(Some times I get stuck on the path and can't get off if it)

19 Sep 2015, 5:17 PM
#9
ajeh avatar

ajeh

Oba-san

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

Re: Item has free shipping if ordered with a another item ??

You could customize the code for:
/includes/classes/shipping.php

by adding the code in RED:

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

    $this->abort_legacy_calculations = FALSE;
    $this->notify('NOTIFY_SHIPPING_MODULE_PRE_CALCULATE_BOXES_AND_TARE');
    if ($this->abort_legacy_calculations) return;

[B]// bof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
$reduce_weight = 0;
if ($_SESSION['cart']->in_cart(10)) {
  $reduce_weight += $_SESSION['cart']->in_cart_product_total_weight(12);
  $reduce_weight += $_SESSION['cart']->in_cart_product_total_weight(13);
  $reduce_weight += $_SESSION['cart']->in_cart_product_total_weight(15);
  $total_weight = $total_weight - $reduce_weight;
}
// eof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
[/B]
    if (is_array($this->modules)) {

and customize the file:
/includes/classes/shopping_cart.php

by adding the code in RED:

     return $new_qty;
  }

[B]// bof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
/**
 * calculate products_id weight in cart regardless of attributes
 * USAGE:  $product_total_weight = $this->in_cart_product_total_weight(12);
 * USAGE:  $chk_product_cart_total_weight = $_SESSION['cart']->in_cart_product_total_weight(12);
 *
 * @param mixed $product_id
 * @return float
 */
  function in_cart_product_total_weight($product_id) {
    $products = $this->get_products();
    $in_cart_product_weight = 0;
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      if ((int)$product_id == (int)$products[$i]['id']) {
        $in_cart_product_weight += $products[$i]['weight'] * $products[$i]['quantity'];
      }
    } // end FOR loop
    return $in_cart_product_weight;
  }
// eof: reduce weight if products_id 10 is in cart for products_id 12, 13 and 15
[/B]
}

NOTE: the code added to the shopping_cart.php class will not need to be added in a future release of Zen Cart ...

19 Sep 2015, 5:22 PM
#10
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Thank you!

I will give this a try later on this evening and let you know how it goes.

Regards,
Ron

21 Sep 2015, 2:48 PM
#11
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Hi,
I assume I need to change the product ID's to the IDs listed in my system, correct. I just want to verify this before moving the modified files into place.

Regards,
Ron

21 Sep 2015, 2:54 PM
#12
ajeh avatar

ajeh

Oba-san

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

Re: Item has free shipping if ordered with a another item ??

That is correct ... products_id 10 is the trigger Product to give Free Shipping on the other products_id 12, 13 and 15 ... then change those values to the products_id that get Free Shipping ...

21 Sep 2015, 4:02 PM
#13
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Could you offer product A, as a very simplistic example,

Product A
Radio button Options:
Without Connectors (+ $0)
With BNC connectors (+ $6)
With N connectors (+ $15)
With PL-259 connectors (+ $2)

and not need any custom coding

22 Sep 2015, 12:56 AM
#14
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

Ajeh:

That is correct ... products_id 10 is the trigger Product to give Free Shipping on the other products_id 12, 13 and 15 ... then change those values to the products_id that get Free Shipping ...

Ajeh,

Thanks very much. All appears to be working. Adding products b, c or d do not incur additional shipping.

Regards,
Ron

22 Sep 2015, 12:58 AM
#15
w4mmp avatar

w4mmp

New Zenner

Join Date:
Sep 2015
Location:
Lovettsville,VA
Posts:
58
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

RixStix:

Could you offer product A, as a very simplistic example,

Product A
Radio button Options:
Without Connectors (+ $0)
With BNC connectors (+ $6)
With N connectors (+ $15)
With PL-259 connectors (+ $2)

and not need any custom coding

I will give your idea a go also. But would point me in the right direction on how to set up radio button options.

Regards,
Ron

22 Sep 2015, 1:18 AM
#16
ajeh avatar

ajeh

Oba-san

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

Re: Item has free shipping if ordered with a another item ??

Thanks for the update that this was able to work for you ...

22 Sep 2015, 2:06 PM
#17
rixstix avatar

rixstix

Totally Zenned

Join Date:
Aug 2009
Location:
North Idaho, USA
Posts:
2,015
Plugin Contributions:
0

Re: Item has free shipping if ordered with a another item ??

w4mmp:

I will give your idea a go also. But would point me in the right direction on how to set up radio button options.

Regards,
Ron
It would be a product with a basic attribute setup. Option name: Connectors Option Values: None, BNC, N, PL259

I avoid custom code insertion only because of what I perceive to be potential issues when it comes time to upgrade paired with my lack of skills required to properly merge into future code.

-.. .
-. ..... . -.-