Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16
  1. #11
    Join Date
    Aug 2014
    Location
    Washington Township, Gloucester County, New Jersey, United States
    Posts
    11
    Plugin Contributions
    0

    Default Re: Free Shipping coupon for 1 item makes all shipping free

    Anyone ever figure this one out? I'm stuck in this same situation where my client needs to offer a free shipping coupon but only on certain items. It would even be acceptable if instead it would just refuse to validate the coupon and display a warning if the cart contains items that are not specifically allowed by the coupon. I suppose we would need to compare an array of the items in the cart to an array of allowed items in the coupon restrictions. In fact, the basic functionality for this proposed solution should already exist in normal coupon validation as a condition of proceeding beyond Step 2 of the checkout process. I will investigate.

  2. #12
    Join Date
    Aug 2014
    Location
    Washington Township, Gloucester County, New Jersey, United States
    Posts
    11
    Plugin Contributions
    0

    Default Re: Free Shipping coupon for 1 item makes all shipping free

    The following solution seems to be working as I intended in my previous post.

    Around line 200 of includes/modules/order_total/ot_coupon.php


    PHP Code:

            $products 
    $_SESSION['cart']->get_products();
            
    $foundvalid true;

            if (
    $foundvalid == true) {
              
    $foundvalid false;
              for (
    $i=0$i<sizeof($products); $i++) {
                if (
    is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id'])) {
                  
    $foundvalid true;
                  continue;
                }
              }
            }
    //BOF Restrictive Free Shipping -- Invalidate Coupon if order contains ANY restricted items
         
    if ($coupon_result->fields['coupon_type'] == 'S') {
         
    $products $_SESSION['cart']->get_products();
         
    $validproducts 0;
        
    $totalproductssizeof($products);
              
              for (
    $i=0$i<sizeof($products); $i++) {
                if (
    is_product_valid($products[$i]['id'], $coupon_result->fields['coupon_id'])) {
                  
    $validproducts$validproducts +1;
                  continue;
                }
              }
            }
         

    if (
    $totalproducts $validproducts) {
              
    $messageStack->add_session('redemptions'TEXT_INVALID_RESTRICTIVE_FREE_SHIPPING,'caution');
              
    $this->clear_posts();
              
    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT'''SSL',truefalse));
    }
    //EOF Restrictive Free Shipping

            
    if (!$foundvalid) {
              
    $this->clear_posts();
            } 


    add the following line somewhere in includes/languages/custom/english.php :


    PHP Code:
    define('TEXT_INVALID_RESTRICTIVE_FREE_SHIPPING''Some items in your cart do not qualify for FREE SHIPPING.  Remove them and re-enter coupon code.' 

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

    Default Re: Free Shipping coupon for 1 item makes all shipping free

    Thanks for the update on how you handled this ... I always assumed that was an obvious thing to do but it helps to know a simple solution like that (but simple is simple to us and not the average store owner) is posted on the Free Forums ...
    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: v1.5.5]
    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!

  4. #14
    Join Date
    Aug 2014
    Location
    Washington Township, Gloucester County, New Jersey, United States
    Posts
    11
    Plugin Contributions
    0

    Idea or Suggestion Re: Free Shipping coupon for 1 item makes all shipping free

    No problem. I also intend to add an additional configuration value to TABLE_COUPONS and edit admin/coupon_admin.php to insert a checkbox so that Restrictive Free Shipping can be toggled on or off for each individual coupon code. I will post an update when its complete.

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

    Default Re: Free Shipping coupon for 1 item makes all shipping free

    What specifically is the restriction that you want for the checkbox?
    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: v1.5.5]
    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!

  6. #16
    Join Date
    Dec 2011
    Location
    Wisconsin, USA
    Posts
    674
    Plugin Contributions
    21

    Default Re: Free Shipping coupon for 1 item makes all shipping free

    I had the same issue today where it was desired to have a "Free Shipping" coupon apply only to certain products, and if excluded products where in there they would be charged the difference of the shipping cost. So I thought I would share.

    Here is some general direction how to accomplish it, you will need some coding experience to make this work for your store this is just a general idea. This also really only works for stores that don't charge tax on shipping & are restricting the coupon on a per product level, NOT per category. So you would need to modify it further to do that. ALSO it doesn't account for % or additional discount besides to free shipping. But it is here to help provide so general direction.

    Everything I did was in the includes/modules/order_total/ot_coupon.php

    in the process() function comment out so the customer see the actual complete shipping cost:
    if ($od_amount['type'] == 'S' || $od_amount['type'] == 'E' || $od_amount['type'] == 'O') $order->info['shipping_cost'] = 0;

    towards then end of the calculate_deductions() function:
    After the end of the switch ($this->calculate_tax) {
    }

    I added this:
    PHP Code:
    $coupon_restrictions $db->Execute("SELECT * FROM " TABLE_COUPON_RESTRICT " WHERE coupon_id='" . (int)$_SESSION['cc_id'] . "'");
                        if (
    in_array($coupon->fields['coupon_type'], array('S''E''O')) && $coupon_restrictions->RecordCount() > 0) {
                            
    $restricted_items = array();
                            
    $allowed_items = array();
                            
    $restricted_items_in = array();
                            
    $allowed_items_in = array();
                            while (!
    $coupon_restrictions->EOF) {
                                if (
    $coupon_restrictions->fields['coupon_restrict'] == 'Y') {
                                    
    $restricted_items[] = $coupon_restrictions->fields['product_id'];
                                    if (
    $_SESSION['cart']->get_products($coupon_restrictions->fields['product_id']) > 0) {
                                        
    $restricted_items_in[] = $coupon_restrictions->fields['product_id'];
                                    }
                                } else {
                                    
    $allowed_items[] = $coupon_restrictions->fields['product_id'];
                                    if (
    $_SESSION['cart']->get_products($coupon_restrictions->fields['product_id']) > 0) {
                                        
    $allowed_items_in[] = array('product_id' => $coupon_restrictions->fields['product_id'],
                                            
    'quantity' => $_SESSION['cart']->get_quantity($coupon_restrictions->fields['product_id']),
                                            
    'weight' => zen_products_lookup($coupon_restrictions->fields['product_id'], 'products_weight')
                                        );
                                    }
                                }
                                
    $coupon_restrictions->MoveNext();
                            }
                            if (
    count($allowed_items_in) > && count($restricted_items_in) > 0) {
                                
    $od_amount['total'] = $this->_get_ups_cost_for_free_ship_items($allowed_items_in);
                            }
                        } 
    In this case using UPS shipping module, so I created a function _get_ups_cost_for_free_ship_items() to basically make a call to UPS and determine the shipping cost for those that are allowed, and the re-adjusting the total discount amount with the shipping cost for those approved products

 

 
Page 2 of 2 FirstFirst 12

Similar Threads

  1. v154 Free shipping item triggers all else in cart to be free shipping
    By avansant in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 25 May 2016, 04:20 PM
  2. Discount coupon with free shipping and free shipping if purchasing additional product
    By webmiss in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 4 May 2012, 02:04 PM
  3. Coupon or GC for free item with shipping
    By zb21hay in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 3
    Last Post: 26 Jan 2011, 07:33 AM
  4. "Always free shipping " option is change all item free shipping?
    By als88 in forum Built-in Shipping and Payment Modules
    Replies: 12
    Last Post: 23 Oct 2009, 04:32 AM
  5. Free shipping item weight calculated wrongly for non valid free shipping zone
    By firehorse in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 28 Oct 2006, 05:39 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR