Ok Thanks to Ajeh, I may finally have the solution to everyone's dilemma
Here is what the following accomplishes for me and how I set it up
I am able to mark a product Yes Always free shipping and on international orders charge the customer for shipping on that item, and at the same time if a domestic order is placed with an item in the basket marked Yes Always free shipping and with items that are not, the weight of the product that should be free shipping is not added to the shipping calculation.
First off I will say I am not a PHP, I have pieced this all together from alot of posts on here and played with it alot(BTW most of the code came from posts by Ajeh)
So here are the mods you will need to do.
I will assume you are only using UPS for shipping options to make this simpler, but you can go back and make the same mods to USPS and Fedex.
- Clone the UPS module.
You will use the original module for domestic shipping in your store so in the admin area only choose the domestic shipping options you want to use. In you clone of UPS - lets call that upsinternational, in the admin area you ill set it up to only offer the international shipping options you want to offer.
In the UPSINTERNATIONAL MOD you will need to alter the following code to allow this module to show up when Yes always free shipping is ,marked for a product.
// disable only when entire cart is free shipping
if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_UPS_STATUS == 'True') ? true : false);
}
change to
// disable only when entire cart is free shipping
// if (zen_get_shipping_enabled($this->code)) {
$this->enabled = ((MODULE_SHIPPING_UPSINTERNATIONAL_STATUS == 'True') ? true : false);
// }
Step 2
you need to add one line to /includes/classes/shopping_cart.php
I have a lot of mods to my file from other add ons so I can't tell you the exact line to go to but this is the code you want to find
// shipping adjustments
if (($product->fields['product_is_always_free_shipping'] == 1) or ($product->fields['products_virtual'] == 1) or (ereg('^GIFT', addslashes($product->fields['products_model'])))) {
$this->free_shipping_item += $qty;
$this->free_shipping_price += zen_add_tax($products_price, $products_tax) * $qty;
$this->free_shipping_weight += ($qty * $products_weight);}
and insert this line
$products_weight = $product->fields['products_weight'];
so now you will have it look like this
// shipping adjustments
if (($product->fields['product_is_always_free_shipping'] == 1) or ($product->fields['products_virtual'] == 1) or (ereg('^GIFT', addslashes($product->fields['products_model'])))) {
$this->free_shipping_item += $qty;
$this->free_shipping_price += zen_add_tax($products_price, $products_tax) * $qty;
$products_weight = $product->fields['products_weight'];
$this->free_shipping_weight += ($qty * $products_weight);}
Don't ask me to explain why this line of code is necessary, but it is.
- Go back to your original UPS module and find the following lines
/**
- Get quote from shipping provider's API:
- @param string $method
- @return array of quotation results
*/
function quote($method = '') {
global $_POST, $order, $shipping_weight, $shipping_num_boxest;
and change to
/**
- Get quote from shipping provider's API:
- @param string $method
- @return array of quotation results
*/
function quote($method = '') {
global $_POST, $order, $shipping_weight, $shipping_num_boxes, $free_shipping_weight;
$free_shipping_weight = $_SESSION['cart']-> free_shipping_weight();
then find the following code in the same module
$this->_upsWeight($ups_shipping_weight);
and change it to
$this->_upsWeight(($ups_shipping_weight)-($free_shipping_weight));
I have tested this out on my own site https://www.hornsales.com where I also have a cloned USPS module for international shipping added in as well. And with the limited testing I have done, everything seems to work perfect.
In my store Domestic shipping is always by UPS Ground
and international shipping is either by UPS or USPS.
only some items have free shipping but only in USA
for those items I mark Yes Always Free Shipping
and use the coding above to get international shipping to calculate and show up
Hope this helps some people, and if anyone can let me know if they see any possible problems using this code may create that I can't think of please let me know on here so that I might find a work around or at least let others who see this know that there are possible problems.
At the moment for the way I run my shop, I see no problems.