Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

Free Shipping per Product


Recommended Posts

I have a need to present certain items with Free Shipping to the lower 48 US states. I installed the Free Shipping per Product, which I believe I can make work pretty much the way I want it to except for one issue:


In the setup for the mod, there is a provision to ship designated items worldwide or just to the shop's own country. I need to amend the code to reflect just the lower 48 US States instead of the entire US. There is already a zone set up in the cart for the lower 48, but I can't sort out which code to change to exclude Alaska and Hawaii from the free shipping availability.


The amended section of catalog/checkout_shipping.php is below, though I'm not sure if the last section of this where it says

if ($order->delivery['country_id'] != STORE_COUNTRY && FREE_SHIPPING_TO_ALL_COUNTRIES == "false") {

is the correct area to be looking or not:

94:	if ($free_shipping == false) {
95:	  $check_free_shipping_basket_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
96:	  while ($check_free_shipping_basket = tep_db_fetch_array($check_free_shipping_basket_query)) {
97:		$check_free_shipping_query = tep_db_query("select products_free_shipping from " . TABLE_PRODUCTS . " where products_id = '" . (int)$check_free_shipping_basket['products_id'] . "'");
98:		$check_free_shipping = tep_db_fetch_array($check_free_shipping_query);
99:		$check_free_shipping_array[] = $check_free_shipping['products_free_shipping'];
100:	  }
101:	  if (in_array("1", $check_free_shipping_array) && !in_array("0", $check_free_shipping_array)) {
102:		$free_shipping = true;
103:		include_once(DIR_WS_LANGUAGES . $language . '/checkout_shipping.php');
104:	  }
105:	}
107:	if ($order->delivery['country_id'] != STORE_COUNTRY && FREE_SHIPPING_TO_ALL_COUNTRIES == "false") {
108:	  $free_shipping = false;
109:	}

I believe that other files affected by the contribution only deal with text identification for free shipping items (index, product_info and product_listing in the catalog area) or with providing for selecting whether an item gets free shipping (categories in the admin area). Anyone have an ides how to make

$order->delivery['country_id'] !=

call the zone rather than the whole country?

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

Just in case anyone else needs to do this...


I didn't get it done by using the zone but did manage to get it by excluding the states (Alaska/Hawaii)

if ($order->delivery['country_id'] != STORE_COUNTRY && FREE_SHIPPING_TO_ALL_COUNTRIES == "false") {
 $free_shipping = false;
} elseif ($order->delivery['country_id'] == STORE_COUNTRY && $order->delivery['state'] == "Hawaii"){
 $free_shipping = false;
} elseif ($order->delivery['country_id'] == STORE_COUNTRY && $order->delivery['state'] == "Alaska"){
 $free_shipping = false;

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

  • 5 years later...

Thanks mugitty!


Now if I can only get the shipping insurance value right (free shipping item values are not getting taken off on the quote - the weight is working, but with the insurance value added to the shipment, it doesn't really make up for free shipping). If anyone has fixed this problem, please let me know.

Link to comment
Share on other sites

Ah-ha! OK, I am no oscommerce programmer, but I did find a way to get the insurace values to change:


in checkout_shipping.php



$free_shipping = false;


I added:

$free_insurance = $order->info['subtotal'];




$total_count -= $products[$i]['quantity'];


I added:

$free_insurance -= $products[$i]['price']*$products[$i]['quantity'];


in upsxml.php


I changed:

global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes, $total_weight, $boxcount, $cart, $packing;



global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes, $total_weight, $free_insurance, $boxcount, $cart, $packing;



I changed:

$this->pkgvalue = ceil($order->info['subtotal']);



$this->pkgvalue = ceil($free_insurance);



I hope that this helps someone from the hairpulling experience I just went through :) LOL

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...