Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    I have my settings so that the free shipping image appears on product info pages for products that are configured to have "always free shipping". And that's perfect.. Works as expected..

    Here's the what I'm trying to do however...

    The "always free shipping" only applies to certain products. UPS is the primary shipping method for anything not specifically set to "always free shipping".

    How can I visually flag/mark the "always free shipping" products in the shopping cart/checkout pages so that it's CLEAR that the calculated shipping costs will apply to all other items in the shopping cart and NOT the items flagged "always free shipping". Ideally what I would like to do is to add an asterisk "*" next to each one of the "always free shipping" products and have some text below the products list that explains what the asterisk means.

    Any thoughts??
    Last edited by DivaVocals; 17 Jun 2014 at 03:21 PM. Reason: Include Zen Cart version..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  2. #2
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    If I'm understanding it correctly, you just want to check if cart contains any products that are marked as "always free shipping" and add a disclaimer if so - correct?

  3. #3
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Quote Originally Posted by balihr View Post
    If I'm understanding it correctly, you just want to check if cart contains any products that are marked as "always free shipping" and add a disclaimer if so - correct?
    EXACTLY! and WHY you may be asking?? I don't want customers choosing UPS Next Day and expect that the entire order will be shipping that way.. In this particular case, the "always free shipping" items may in fact be shipped separately using a different carrier altogether (USPS Priority most likely).. We will include text in the order confirmation email, shipping policy and the product description for clarity.. We MAY use product attributes to allow customers to select a shipping "upgrade" for these items if they wish to pay the additional cost for expedited shipping.

    The disclaimer is a way of making sure that if the customer somehow misses the explanation in the shipping policy or the blurb in the product description which tells them this, they will know FOR SURE when they check out..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  4. #4
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Quote Originally Posted by DivaVocals View Post
    EXACTLY! and WHY you may be asking??
    Well, honestly, I don't care.

    includes/modules/pages/shopping_cart/header_php.php

    Around line 59 find:
    Code:
    $flagAnyOutOfStock = false;
    and add after:
    Code:
    // BOF Free Shipping Flag 1/3
    $flagAnyFreeShipping = false;
    // EOF Free Shipping Flag 1/3
    Around line 130 find:
    Code:
    if (STOCK_CHECK == 'true') {
        $flagStockCheck = zen_check_stock($products[$i]['id'], $products[$i]['quantity']);
        if ($flagStockCheck == true) {
          $flagAnyOutOfStock = true;
        }
      }
    and add after:
    Code:
    // BOF Free Shipping Flag 2/3
      $flagFreeShipping = zen_get_product_is_always_free_shipping($products[$i]['id']) == true ? '*' : '';
      if(zen_not_null($flagFreeShipping)) $flagAnyFreeShipping = true;
      // EOF Free Shipping Flag 2/3
    Around line 161 find:
    Code:
    'flagShowFixedQuantity'=>$showFixedQuantity,
    and add after:
    Code:
    // BOF Free Shipping Flag 3/3
    'flagFreeShipping'=>$flagFreeShipping,
    // EOF Free Shipping Flag 3/3
    Next, includes/templates/YOUR_TEMPLATE/templates/tpl_shopping_cart_default.php
    Find:
    Code:
    <a href="<?php echo $product['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $product['productsImage']; ?></span><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a>
    and replace with:
    Code:
    <a href="<?php echo $product['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $product['productsImage']; ?></span><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagFreeShipping'] . '</span>' . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a>
    Find:
    Code:
    <!--bof shopping cart buttons-->
    and add before:
    Code:
    <?php if($flagAnyFreeShipping) echo '<div id="freeShippingDisclaimer">some free shipping disclaimer here</div>'; ?>
    If you want some info on the checkout pages, I'd probably add a parameter in $_SESSION (set it includes/modules/pages/shopping_cart/header.php) and then just set an if-else in the checkout pages...

  5. #5
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Or one could just query the shopping cart directly. As usual, many different ways to get the same information :-)

    Code:
    // Check against the database directly using the shopping cart
    $cart_includes_free_shipping_product = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    
    // Calculate totals and return number of items in the shopping cart w/ free shipping
    $cart_includes_free_shipping_product  = (count($_SESSION['cart']->free_shipping_items()) > 0);
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  6. #6
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Quote Originally Posted by lhungil View Post
    Or one could just query the shopping cart directly. As usual, many different ways to get the same information :-)


    I was never really a fan of simple. If there's a complicated solution, I'll be the first to take it. I mean, why use "1+1" when you can use " (sin(45)^2)((4π) / π)" and get the same result... Now, if you'll excuse me, I'll be in the basement banging my head against the wall...

  7. #7
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Quote Originally Posted by lhungil View Post
    Or one could just query the shopping cart directly. As usual, many different ways to get the same information :-)

    Code:
    // Check against the database directly using the shopping cart
    $cart_includes_free_shipping_product = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    
    // Calculate totals and return number of items in the shopping cart w/ free shipping
    $cart_includes_free_shipping_product  = (count($_SESSION['cart']->free_shipping_items()) > 0);
    Quote Originally Posted by balihr View Post


    I was never really a fan of simple. If there's a complicated solution, I'll be the first to take it. I mean, why use "1+1" when you can use " (sin(45)^2)((4π) / π)" and get the same result... Now, if you'll excuse me, I'll be in the basement banging my head against the wall...
    You guys are funny!!!

    So lhungil if I understand this correctly, I could use either of these snippets to determine if "always free shipping" products are in the cart.. could I add a conditional that say "if this is true, then display this text"?? Something like this:

    Code:
    // Check against the database directly using the shopping cart
    <?php if
    $cart_includes_free_shipping_product = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    echo '<div id="freeShippingDisclaimer">some free shipping disclaimer here</div>'; 
    ?>
    (please say I guessed this correctly??)
    Last edited by DivaVocals; 17 Jun 2014 at 06:57 PM.
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  8. #8
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Quote Originally Posted by balihr View Post
    I was never really a fan of simple. If there's a complicated solution, I'll be the first to take it. I mean, why use "1+1" when you can use " (sin(45)^2)((4π) / π)" and get the same result... Now, if you'll excuse me, I'll be in the basement banging my head against the wall...
    May I interest you in some MIPS assembly, LaTex, LISP, or Java bytecode? In the case of the last two, I'll even throw in some bonus code which rewrites itself while executing!

    Coincidentally, I'm planning to use more bitwise arithmetic in some of my code. Why should I use separate options with "true / false" (or enable / disable) when a nice bitmask stored in a short unsigned integer (or byte) could be used?


    Quote Originally Posted by DivaVocals View Post
    ... if I understand this correctly, I could use either of these snippets to determine if "always free shipping" products are in the cart.. could I add a conditional that say "if this is true, then display this text"?? ...
    If all you want is to display a notice / link on the page(s) when "always free shipping" products are in the cart, yes. I would use the first snippet and separate out the code (header and template).

    Perhaps even using an observer to listen for those pages (NOTIFY_HEADER_END_SHOPPING_CART, NOTIFY_HEADER_END_CHECKOUT_SHIPPING, NOTIFY_HEADER_END_CHECKOUT_PAYMENT, NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION)...

    Sadly the popup_shipping_estimator does not include a notify in header_php.php so would need to be directly added to the end of the file...

    Code:
    $cart_includes_free_shipping_product = false;
    if(array_key_exists('cart', $_SESSION)) {
    	$cart_includes_free_shipping_product = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    }

    But if you want an indicator on EACH product listed in the shopping cart, you'll have to use something like balihr's example to add the flag to the productsArray (so it is accessible for use when listing the shopping cart contents).
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  9. #9
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    Quote Originally Posted by lhungil View Post
    If all you want is to display a notice / link on the page(s) when "always free shipping" products are in the cart, yes. I would use the first snippet and separate out the code (header and template).
    HUH??

    Quote Originally Posted by lhungil View Post
    Perhaps even using an observer to listen for those pages (NOTIFY_HEADER_END_SHOPPING_CART, NOTIFY_HEADER_END_CHECKOUT_SHIPPING, NOTIFY_HEADER_END_CHECKOUT_PAYMENT, NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION)...
    Sadly the popup_shipping_estimator does not include a notify in header_php.php so would need to be directly added to the end of the file...

    Quote Originally Posted by lhungil View Post
    Code:
    $cart_includes_free_shipping_product = false;
    if(array_key_exists('cart', $_SESSION)) {
        $cart_includes_free_shipping_product = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    }
    Got it.. THIS I think I get..

    Although I don't use the popup estimator.. I have always thought it was better to show the shipping estimator one the page versus some popup window.. So I set my settings accordingly..

    Quote Originally Posted by lhungil View Post
    But if you want an indicator on EACH product listed in the shopping cart, you'll have to use something like balihr's example to add the flag to the productsArray (so it is accessible for use when listing the shopping cart contents).
    I do in fact want an indicator next to each "always free shipping" product.. I might mess around and see if I can make myself a combo platter here..
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  10. #10
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: Visually Highlight/Flag "Always Free Shipping" products in the shopping cart

    ... separate out the code (header and template).
    Code doing processing in an observer (or header files). Code displaying stuff (HTML / CSS) in the template files.

    I do in fact want an indicator next to each "always free shipping" product [in the shopping cart and checkout].. I might mess around and see if I can make myself a combo platter here..
    Sounds like fun! I'd probably do something like the following (untested):

    Create "/includes/classes/observers/freeShippingObserver.php"
    Code:
    <?php
    class freeShippingObserver extends base {
    
    	protected $logfile;
    
    	function __construct() {
    		$this->attach($this, array(
    			'NOTIFY_HEADER_END_SHOPPING_CART',
    			'NOTIFY_HEADER_END_CHECKOUT_SHIPPING',
    			'NOTIFY_HEADER_END_CHECKOUT_PAYMENT',
    			'NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION'
    		));
    	}
    
    	function update(&$class, $eventID, $paramsArray = array()) {
    		global $cart_includes_free_shipping_product;
    
    		$cart_includes_free_shipping_product = false;
    		if(array_key_exists('cart', $_SESSION)) {
    			$cart_includes_free_shipping_product = $_SESSION['cart']->in_cart_check('product_is_always_free_shipping','1');
    
    			global $products;
    			$n=sizeof($products);
    			if($n > 0) {
    				switch($eventID) {
    					case 'NOTIFY_HEADER_END_SHOPPING_CART':
    						global $productArray;
    						for ($i=0; $i<$n; $i++) {
    							$productArray[$i]['product_is_always_free_shipping'] = $products[$i]['product_is_always_free_shipping'];
    						}
    						break;
    					case 'NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION':
    						global $order;
    						for ($i=0; $i<$n; $i++) {
    							$order->products[$i]['product_is_always_free_shipping'] = $products[$i]['product_is_always_free_shipping'];
    						}
    					default:
    				}
    			}
    		}
    	}
    }
    Create "/includes/auto_loaders/config.freeShippingObserver.php"
    Code:
    <?php
    if (!defined('IS_ADMIN_FLAG')) {
    	die('Illegal Access');
    }
    
    $autoLoadConfig[10][] = array(
    	'autoType'=>'class',
    	'loadFile'=>'observers/freeShippingObserver.php'
    );
    $autoLoadConfig[200][] = array(
    	'autoType'=>'classInstantiate',
    	'className'=>'freeShippingObserver',
    	'objectName'=>'freeShippingObserver'
    );
    Then in the templates for those four pages one can look use:
    Code:
    if($cart_includes_free_shipping_product) { // Do something }
    In the shopping cart template (inside the foreach starting at line 63) one can use:
    Code:
    if($product['product_is_always_free_shipping'] == '1') { // Do something }
    In the checkout_confirmation template one can use:
    Code:
    if($order->products[$i]['product_is_always_free_shipping'] == '1') { // Do something }
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. What is the mySQL command to reset "Always Free Shipping" NO
    By oavs in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 29 Jan 2014, 12:13 AM
  2. v150 "Always free shipping" becomes "not possible"
    By kalastaja in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 8 Mar 2013, 08:00 PM
  3. v139h Can I set all products "Always Free Shipping"?
    By zihaizi in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 12 Jul 2012, 02:12 PM
  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. Want to use "Always Free Shipping Products"
    By awaes786 in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 8 Jun 2008, 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