Forums / Built-in Shipping and Payment Modules / Free Shipping w/ Options ONLY on Free Ship Items?

Free Shipping w/ Options ONLY on Free Ship Items?

Locked

Views: 11,178

Results 21 to 29 of 29
This thread is locked. New replies are disabled.
16 Dec 2009, 1:26 AM
#21
ajeh avatar

ajeh

Oba-san

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

Free Shipping w/ Options ONLY on Free Ship Items?

This was not setup to work in this manner ...

Without a lot of fooling around with it I am not sure which is causing the problem, the product marked as Special/Combo or the weight ...

If I get time, I will try to setup something for this to test the issues involved but I am pretty tied up right now so it might be awhile ...

Always Free Shipping was designed to work for everyone ... not to be filtered for just one zone ... but there are a lot of ways to work with Always Free Shipping that can be coded around to make it work this way ...

Unfortunately, it isn't something I can just whip up off the top of my head ... :cool:

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!

16 Dec 2009, 3:28 PM
#22
jcit avatar

jcit

New Zenner

Join Date:
Nov 2009
Posts:
6
Plugin Contributions:
0

Re: Free Shipping w/ Options ONLY on Free Ship Items?

Ajeh:

Unfortunately, it isn't something I can just whip up off the top of my head ... :cool:

Ha-ha, good! Then it wasn't as simple as I thought it was. (Which lowers my annoyance factor a bit... :wink:)

I really appreciate the reply. There's no real rush, as we have a clunky-yet-functional work-around in place. I'm reviving what little of my rusty php skills remain in my head, so if I manage an elegant solution (as if), I'll update it here.

Thanks again!

10 May 2010, 3:47 AM
#23
hornsales avatar

hornsales

New Zenner

Join Date:
Nov 2007
Posts:
54
Plugin Contributions:
0

Re: Free Shipping w/ Options ONLY on Free Ship Items?

ctopher:

Oh please, they just asked where to start.

How about this:

edit includes/functions/functions_general.php and modify:

zen_get_shipping_enabled($shipping_module)

> 
> Something like this is probably overkill, but for me it gives the user all of the available shipping options.
> 
> ```php
////
// enable shipping
  function zen_get_shipping_enabled($shipping_module) {
    global $PHP_SELF, $cart, $order;

    // for admin always true if installed
    if (strstr($PHP_SELF, FILENAME_MODULES)) {
      return true;
    }

    $check_cart_free = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    $check_cart_cnt = $_SESSION['cart']->count_contents();
    $check_cart_weight = $_SESSION['cart']->show_weight();

    switch(true) {
      // for admin always true if installed
      case (strstr($PHP_SELF, FILENAME_MODULES)):
        return true;
        break;
      // Free Shipping when 0 weight - enable freeshipper - ORDER_WEIGHT_ZERO_STATUS must be on
      case (ORDER_WEIGHT_ZERO_STATUS == '1' and ($check_cart_weight == 0 and $shipping_module == 'freeshipper')):
        return true;
        break;
      // Free Shipping when 0 weight - disable everyone - ORDER_WEIGHT_ZERO_STATUS must be on
      case (ORDER_WEIGHT_ZERO_STATUS == '1' and ($check_cart_weight == 0 and $shipping_module != 'freeshipper')):
        //return false; - No, we want to offer other modules
        return true;
        break;
      case (($_SESSION['cart']->free_shipping_items() == $check_cart_cnt) and $shipping_module == 'freeshipper'):
        return true;
        break;
      case (($_SESSION['cart']->free_shipping_items() == $check_cart_cnt) and $shipping_module != 'freeshipper'):
        //return false; - No, we want to offer other modules
        return true;
        break;
      // Always free shipping only true - enable freeshipper
      case (($check_cart_free == $check_cart_cnt) and $shipping_module == 'freeshipper'):
        return true;
        break;
      // Always free shipping only true - disable everyone
      case (($check_cart_free == $check_cart_cnt) and $shipping_module != 'freeshipper'):
        //return false; - No, we want to offer other modules
        return true;
        break;
      // Always free shipping only is false - disable freeshipper
      case (($check_cart_free != $check_cart_cnt) and $shipping_module == 'freeshipper'):
        return false;
        break;
      default:
        return true;
        break;
    }
  }

This will enable other shipping options with Free Shipping. There is still a problem however because Zen Cart sets the weight of the product to 0 if it's set to "Yes, always free shipping". So we need to stop that from happening.

edit the calculate method in includes/classes/shopping_cart.php

wherever you see the code

if ($product->fields['product_is_always_free_shipping'] != 1 and ...

> 
> and it's part of the $products_weight calculation, comment it out.
> In some cases the if statement is looking for  product_is_always_free_shipping to be a 1 to add to the free_shipping_weight. Comment out those too.
> 
> You may have to tweak  it a bit for attributes etc, but since you asked to be pointed to the files needed to be customized, there you go!

I realize this thread has been quiet for awhile, but I just found it,

All the info here is so close to working for me, but I am missing something.

Here is what I am trying to do.

On certain products I want to enable "Yes Always free shipping"
But only on USA orders

So what I have done is cloned the  usps module to have a separate module only for  International orders, so the original USPS model can handle only domestic orders for the other non free shipping items.

I have configured my new ups module to actually show up when freeshipper is installed and the item is marked Yes always free shipping and the address is outside of the US.

Now my problem is that freeshipper is sending a weight of 0 to USPS and therefore my rate calculations are wrong.

SO as in the quoted message above I commented out the line is shopping_cart.php.  But that creates a new problem if a customer in the US orders a free shipping item and a non freeshipping item the shipping weight is calculated to include the weight of the free shipping item.

So I have thought of a simple solution but am unsure of the variable I need to use.

In the USPS module this line
$shipping_pounds = floor ($usps_shipping_weight); 
if changed to this line
$shipping_pounds = floor ($usps_shipping_weight) +10;

actually adds 10 pounds to the weight sent to USPS for calculations

So what I am trying to figure out is there a variable that already exists that stores the real total weight of all items in the cart.

So I could make the line read
$shipping_pounds = floor ($usps_shipping_weight) + $true_cart_weight;
where $true_cart_weight = what ever the correct name of the variable if it exists that stores the total weight of the entire cart

this way would require no changes to shopping_cart.php  or serious coding changes if this variable exists
Because then for this module and this module only which is all that would display when there is a free shipping item in a cart with a non US address the true cart weight would be sent to USPS.

and then this method could be used to clone and modify a UPS module as well
10 May 2010, 4:03 PM
#24
ajeh avatar

ajeh

Oba-san

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

Re: Free Shipping w/ Options ONLY on Free Ship Items?

You could obtain the amount of weight considered Always Free Shipping with:
$_SESSION['cart']->free_shipping_weight()

So if you had a Product Marked Always Free Shipping but added weight to it ... you could see how this adjusts the shipping ...

Or you can expand how the product_is_always_free_shipping is used in calculating the weight of the shopping cart ...

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!

10 May 2010, 5:12 PM
#25
hornsales avatar

hornsales

New Zenner

Join Date:
Nov 2007
Posts:
54
Plugin Contributions:
0

Re: Free Shipping w/ Options ONLY on Free Ship Items?

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.

  1. 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.

  1. 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.

16 May 2010, 1:59 PM
#26
jharradine avatar

jharradine

New Zenner

Join Date:
Mar 2010
Posts:
17
Plugin Contributions:
0

Re: Free Shipping w/ Options ONLY on Free Ship Items?

Hey guys,

this page seems the most appropriate for my 'little' issue.

Just to explain what's going on, i have a flat rate of £5 where orders are over £50 shipping is free. and this i setup using modules, order totals, shipping, that is set for national only.

I'd like to have the 'free shipping' logo displayed next to products worth more than £50 and have set those products to 'always free shipping'.

the trouble is with international orders, it's fine with orders under £50 - shows the £5 flat rate. Also fine if other items worth less than £50 are added so the order total is over £50 it shows the flat rate of £5!! cool. Trouble is, if a product who's value is over £50 and therefore set to 'always free shipping' -- then the dreaded message 'Sorry, we are not shipping to your region at this time.'

So i've not got added complications with weights or express shipping, any ideas?

Joe

<a href="http://mymultitools.co.uk">My Multi Tools</a>

16 May 2010, 3:39 PM
#27
ajeh avatar

ajeh

Oba-san

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

Re: Free Shipping w/ Options ONLY on Free Ship Items?

Always Free Shipping is designed to work with everyone ...

If you put a Zone on the Free Shipping freeshipper then you will not be able to check out if not in that zone ...

What do you want to happen for people not in the Zone that you have set on the Free Shipping freeshipper shipping option?

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!

16 May 2010, 5:47 PM
#28
hornsales avatar

hornsales

New Zenner

Join Date:
Nov 2007
Posts:
54
Plugin Contributions:
0

Re: Free Shipping w/ Options ONLY on Free Ship Items?

This sounds easy enough to solve, but since you are not in the US, I am not sure. It will all depend on what shipping module you use for your international shipping.

If it has the ability like the UPS module to only select shipping methods that are international, you are fine.

In that case clone that shipping module. You will find how to do that in that FAQs.

Then in that shipping module find this text

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

and change it to this:

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

This will now let that shipping module display when Always free shipping is on an item. And since you have it set to only display international shipping options then it won't show up for domestic orders.

Now if the shipping module you use for international shipping does not allow you to only select international shipping options, I am not sure how you could set it up

24 Jul 2010, 1:20 PM
#29
enzo_ita avatar

enzo_ita

Zen Follower

Join Date:
Jul 2009
Posts:
402
Plugin Contributions:
0

Re: Free Shipping w/ Options ONLY on Free Ship Items?

Hi,
I have istalled the 139d.

I would like to have the free shipping icon pop up close to the product when a product has a price higher then the value set in freeshipping options for the total order.

I do not know if this is possible, I have dwld the free_shipping_rules_1-1.zip and installed taking care of renaming the folder your template with my folder name, and installed also the italan language folder, but nothing happens.

Am I looking for something impossible or doing something wrong?
Thanks
enzo