Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Conditional message on shopping cart page

    In one of my stores I have several products which can only be supplied if some conditions are being met.

    It was necessary that a manufacturer specific message is being displayed on the shopping cart page if the cart contains a product from a given manufacturer.

    I have only one manufacturer who requires one condition to be filled. That was easily solved by adding this to the tpl_shopping_cart_default.php page:

    <!--bof prescriptive advice required alert -->
    <div>
    <?php
    global $cart;
    if ($_SESSION['cart']->in_cart_check('manufacturers_id','1')) {
    echo TEXT_PRESCRIPTIVE_ADVICE_REQUIRED;
    } //above returns true for prescriptive advice required
    ?>
    </div>
    <!--eof prescriptive advice required alert -->
    If a customer adds a product made by the manufacturer with id=1 then the message (call it message A) shows just fine.

    Then there are several other manufacturers who's requirements are different from manufacturer 1 but they are all of a common nature.

    I managed to display a message different to the one applicable to manufacturer 1 if (per say) a product made by manufacturer 2 is added to the cart by modifying the code above with another id and another define.

    But - and here is my problem - what if the cart contains a product from manufacturers 2, 3 and 4 (all with the same conditional message to be displayed - let's call it message B)?

    Is it possible to put 2,3 and 4 into an array covering manufacturers 2,3 and 4 regardless of which product from these manufacturers is in the cart?

    To top it off, if the cart contains something from manufacturer 1 and also something from manufacturer 2, 3 or 4 then only message A needs to be shown - message B would be obsolete.

    I have been stuffing around with this idea for most of the day with varying results, but none of my attempts were satisfactory.

    Any ideas or pointers please?

    TIA

    Frank

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

    Default Re: Conditional message on shopping cart page

    Each has to be tested separately ...

    So you could use something like:
    Code:
    <!--bof prescriptive advice two required alert -->
    <div>
    <?php
    global $cart;
    $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','2');
    $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','3');
    $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','4');
    if ($chk_multi_manufacturers) {
    echo TEXT_PRESCRIPTIVE_ADVICE_REQUIRED_TWO;
    } //above returns true for prescriptive advice two required
    ?>
    </div>
    <!--eof prescriptive advice two required alert -->
    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
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Conditional message on shopping cart page

    To expand this to your other condition (message 2 not required if message 1 shown), you could do this
    PHP Code:
    <!--bof prescriptive advice required alert -->
    <div>
    <?php
    global $cart;
    $chk_single_manufacturer $_SESSION['cart']->in_cart_check('manufacturers_id','1');
    $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','2');
    $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','3');
    $chk_multi_manufacturers += $_SESSION['cart']->in_cart_check('manufacturers_id','4');
    if (
    $chk_single_manufacturer) {
      echo 
    TEXT_PRESCRIPTIVE_ADVICE_REQUIRED_ONE;
    } elseif (
    $chk_multi_manufacturers) {
      echo 
    TEXT_PRESCRIPTIVE_ADVICE_REQUIRED_TWO;
    //above returns true for prescriptive advice two required
    ?>
    </div>
    <!--eof prescriptive advice required alert -->

  4. #4
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Conditional message on shopping cart page

    Thanks to both of you.

    I will have a crack at this later in the day and let you know how it panned out.

  5. #5
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Conditional message on shopping cart page

    All configured and uploaded - works a treat

    Thanks again Linda and Glenn

 

 

Similar Threads

  1. Replies: 1
    Last Post: 22 Dec 2014, 08:55 PM
  2. Remove right sidebox shopping cart from when on shopping cart page
    By alterego55 in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 2 Oct 2010, 01:45 AM
  3. Shopping cart empty message
    By tbokich in forum Upgrading from 1.3.x to 1.3.9
    Replies: 8
    Last Post: 8 Apr 2009, 07:48 PM
  4. Shopping cart message
    By confused_aswell in forum General Questions
    Replies: 3
    Last Post: 10 Jun 2008, 03:24 PM
  5. Shopping cart message
    By enquirer66 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 8 Oct 2007, 01:18 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