Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    303
    Plugin Contributions
    3

    Default exclude products from free shipping

    What I'm attempting to do is to turn off freeoptions for when someone orders all of a certain item to get to the free shipping threshold.

    for instance someone just ordered 27 quarts of oil to get free shipping, and the shipping KILLED us!

    I tried to impliment the following code into the freeoptions.php file with no luck:
    Code:
    //check for oil only orders and disable free shipping
    	  $how_many_items = $_SESSION['cart']->count_contents();
          $how_many_102 = $_SESSION['cart']->in_cart_check('products_model','60-102');
    	  $how_many_103 = $_SESSION['cart']->in_cart_check('products_model','60-103');
    	  $how_many_107 = $_SESSION['cart']->in_cart_check('products_model','60-107');
    	  $how_many_110 = $_SESSION['cart']->in_cart_check('products_model','60-110');
    	  
          if (($how_many_102 == $how_many_items)){ 
              $this->enabled = false;
    			if (($how_many_102 == $how_many_items) && ($how_many_102 > 38)) {
    			$messageStack->add('checkout_shipping', WARNING_NO_FREE_SHIP, 'caution');
    			} 
    		}
    	  
    	  if (($how_many_103 == $how_many_items)){ 
              $this->enabled = false;
    			if (($how_many_103 == $how_many_items) && ($how_many_103 > 26)) {
    			$messageStack->add('checkout_shipping', WARNING_NO_FREE_SHIP, 'caution');
    			}
    		}
    	  
    	   if (($how_many_107 == $how_many_items)){ 
              $this->enabled = false;
    			if (($how_many_107 == $how_many_items) && ($how_many_107 > 42)) {
    			$messageStack->add('checkout_shipping', WARNING_NO_FREE_SHIP, 'caution');
    			} 
    		}
    	  
    	   if (($how_many_110 == $how_many_items)){ 
              $this->enabled = false;
    			if (($how_many_110 == $how_many_items) && ($how_many_110 > 26)) {
    			$messageStack->add('checkout_shipping', WARNING_NO_FREE_SHIP, 'caution');
    			} 
    		}
    any ideas on why this isn't working are greatly appreciated!

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: exclude products from free shipping

    Do you mean to test only if the results of any of those categories is the same as the whole order? Or do you really mean if the total of those categories is the whole order?
    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!

  3. #3
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    303
    Plugin Contributions
    3

    Default Re: exclude products from free shipping

    I mean to:
    1. Test if the results of those items is the entire order. (only after free ship for orders over $350 is met)
    2. If so to turn off free ship and display warning stack message.

    For example if someone orders 27 of 60-103 and nothing else they will get free shipping. I want to turn that off.
    If some one were to order 10 of 60-103 and other items to get free shipping, I want to leave that on.
    Last edited by mikestaps; 7 Aug 2013 at 07:18 PM.

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: exclude products from free shipping

    What if I order 20 of 60-103 and 20 of 60-107 ... does that now fall in the NOT freeoptions?
    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!

  5. #5
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    303
    Plugin Contributions
    3

    Default Re: exclude products from free shipping

    Doh!

    I didn't think of that...
    I would say that any combination of those 4 items that equals free ship, if it is only those four items in the cart, should be excluded.
    Not sure what direction to take now!
    Is there a way to use your theory and code from this post - http://www.zen-cart.com/showthread.... to achieve that?

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: exclude products from free shipping

    That would be a good example ... to build from ...

    I do not have time at this exact moment to figure out the calculations, but if you can follow the bouncing ball and give it a try and see how far you get, that might be a start ...

    Otherwise, you'd have to think fond thoughts and twiddle your thumbs for awhile until I can get to it later ...
    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. #7
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    303
    Plugin Contributions
    3

    Default Re: exclude products from free shipping

    I'll give it a go in the am when i'm fresh and let you know...

  8. #8
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    303
    Plugin Contributions
    3

    Default Re: exclude products from free shipping

    The thumb twiddling has begun!

    The only thing I could think to do was to put a simple if/else statement around that chunk of code so it wouldn't calculate those items towards free ship if a certain qty of each was in the cart, but that still doesn't solve the 20 + 20 issue...

  9. #9
    Join Date
    Aug 2010
    Location
    Hartland, MI
    Posts
    303
    Plugin Contributions
    3

    Default Re: exclude products from free shipping

    I thought I had it figured out....

    I created functions/extra_functions/reduce_free_shipping.php
    Code:
    <?php
    // calculate amount not to be used for Products 144, 443, 148, 473 if all items in cart are from category 93
      function reduce_free_shipping() {
        global $cart;
        $how_many_items = $_SESSION['cart']->count_contents();
    	$how_many_oils = $_SESSION['cart']->in_cart_check('master_categories_id', '93');
    	if ($how_many_items == $how_many_oils) {  
    	$exclude_products = "144, 443, 148, 473";
        $products = $_SESSION['cart']->get_products();
        $chk_price = 0;
        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
          if (in_array((int)$products[$i]['id'], explode(",", $exclude_products))) {
            $chk_price += $products[$i]['final_price'] * $products[$i]['quantity'];
          }
        } // end FOR loop
    
        return $chk_price;
        }
      }
    ?>
    and added to freeoptions.php:
    Code:
    if (($_SESSION['cart']->show_total() - reduce_free_shipping()) >= MODULE_SHIPPING_FREEOPTIONS_TOTAL_MIN
    Nothing happened!?!?!

    Thumb twiddling continues!

  10. #10
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: exclude products from free shipping

    So your new function is only saying to do this when the number of Products in the cart is the same quantity as the Products in Category 93:
    Code:
        if ($how_many_items == $how_many_oils) {
    Is that what you really mean?

    Or do you mean, always do this and based on whether or not Products in the cart are any of the Products in Category 93, then do the test to reduce the total should any of those Products be in the 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!

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. exclude a few products from one shipping service
    By Princess in forum General Questions
    Replies: 3
    Last Post: 3 Nov 2012, 03:41 PM
  2. v139h Exclude FREE SHIPPING on Two Items
    By kstew923 in forum Built-in Shipping and Payment Modules
    Replies: 16
    Last Post: 6 Mar 2012, 11:34 PM
  3. v139h exclude non continental united states zones from free shipping.
    By gloerick in forum Built-in Shipping and Payment Modules
    Replies: 103
    Last Post: 6 Mar 2012, 02:25 AM
  4. exclude a product or category from Free Shipping freeoptions
    By gotlogos in forum Built-in Shipping and Payment Modules
    Replies: 18
    Last Post: 14 Feb 2012, 01:05 AM
  5. exclude certain products from free shipping
    By emtecmedia in forum Built-in Shipping and Payment Modules
    Replies: 24
    Last Post: 28 Sep 2010, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg