Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11
    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

    LOOOL, lhungil, talk about a simple solution... Now I wish I had a time machine and go just a few hours back to stop me from hitting my head... So, what do you do when you're not browsing the forums, teach Rocket Science over at MIT?

    Although this is a brilliant solution (as most coming from you are), isn't it a bit of an overkill for the purpose? Personally, I'd use your first solution with in_cart_check and just put the results (conditional, of course) into $_SESSION for it to be used on any other inner page...

    I might be missing something obvious here, but still - IMHO, a much simpler approach, and (possibly more important) understandable by most mortals, not just you MIT gals...

  2. #12
    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
    LOOOL, lhungil, talk about a simple solution... Now I wish I had a time machine and go just a few hours back to stop me from hitting my head... So, what do you do when you're not browsing the forums, teach Rocket Science over at MIT?

    Although this is a brilliant solution (as most coming from you are), isn't it a bit of an overkill for the purpose? Personally, I'd use your first solution with in_cart_check and just put the results (conditional, of course) into $_SESSION for it to be used on any other inner page...

    I might be missing something obvious here, but still - IMHO, a much simpler approach, and (possibly more important) understandable by most mortals, not just you MIT gals...


    I have to give it to him.. He's brilliant isn't he!!!??? He and lat9 are soooooooo dagone smart.. (and you ain't no slouch either mister..)

    But I keep telling him that I am not a developer.. I just play one on TV!
    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.

  3. #13
    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
    ... isn't it a bit of an overkill ... I might be missing something obvious here, but still - IMHO, a much simpler approach, and (possibly more important) understandable by most mortals...
    LOL, I definately have been enjoying reading your posts as of late. The humour (and possibly sarcasm) lately has been a very welcome beathe of fresh air.

    As for my reasons... I have an aversion to modifying core files... Mostly because I spent WAY too much time merging during my last few ZC upgrades...

    And since Zen Cart has an existing design pattern for just such a purpose, I figured "Why not"?

  4. #14
    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
    LOOOL, lhungil, talk about a simple solution... Now I wish I had a time machine and go just a few hours back to stop me from hitting my head... So, what do you do when you're not browsing the forums, teach Rocket Science over at MIT?

    Although this is a brilliant solution (as most coming from you are), isn't it a bit of an overkill for the purpose? Personally, I'd use your first solution with in_cart_check and just put the results (conditional, of course) into $_SESSION for it to be used on any other inner page...

    I might be missing something obvious here, but still - IMHO, a much simpler approach, and (possibly more important) understandable by most mortals, not just you MIT gals...
    I am sadly gonna have to agree and admit defeat.. Perhaps over the weekend, I'll spend some time trying to see if I can interpret lhungil's solution, but it's WAAAAY over my head to "figure out" on my own.... Your solution worked, and for now that's what I'm gonna go with 'cause I've got one other issue with this site launch to contend with that's giving me fits.. All my free shipping needs are firing on all cylinders now..

    Quote Originally Posted by lhungil View Post
    Code doing processing in an observer (or header files). Code displaying stuff (HTML / CSS) in the template files.


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

 

 
Page 2 of 2 FirstFirst 12

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