Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2009
    Location
    Chicago, IL.
    Posts
    198
    Plugin Contributions
    0

    Default Which php variable calls for Total Items in Cart?

    I am trying to do something like this on tpl_shopping_cart_default.php

    Code:
    if ( $cart_quantity == "1" ) {
    	echo "Did you know a second box will ship for free!<br />";
    }
    ?>
    is that right? When there is only one item in shopping cart, I want to display the message above.

    is the variable $cart_quantity right for the number of items in cart?

    ( My first attempt at php, be gentle )

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,501
    Plugin Contributions
    88

    Default Re: Which php variable calls for Total Items in Cart?

    Assuming that "only one" in the shopping cart means that there's only 1 item of any type/product, then what you want is:

    Code:
    if ($_SESSION['cart']->count_contents() == 1) {
      echo "Did you know a second box will ship for free!<br />";
    
    }
    ... of course, it's always good practice to put language-specific stuff in a language file! You could add to /includes/languages/english/YOURTEMPLATE/shopping_cart.php:

    Code:
    define('CART_2ND_FOR_FREE', 'Did you know a second box will ship for free!<br />');
    and then change your template code to

    Code:
    if ($_SESSION['cart']->count_contents() == 1) {
      echo CART_2ND_FOR_FREE;
    
    }

  3. #3
    Join Date
    Nov 2009
    Location
    Chicago, IL.
    Posts
    198
    Plugin Contributions
    0

    Default Re: Which php variable calls for Total Items in Cart?

    You are awesome. I have been reading php resources all day to achieve this. Thank you.

    It works perfectly.

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,501
    Plugin Contributions
    88

    Default Re: Which php variable calls for Total Items in Cart?

    Glad to help! Good luck with your store.

  5. #5
    Join Date
    Nov 2009
    Location
    Chicago, IL.
    Posts
    198
    Plugin Contributions
    0

    Default Re: Which php variable calls for Total Items in Cart?

    Yup!

    Now, with the same statement how can i put another part in there.

    if total items in cart are 3 , display "did you know the 4th box ships free"

    and

    If total item are more between than 4 but less than 12, " did you know upto 12 boxes ship at no extra charge"


    ( of course i will use proper text and define files)

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,501
    Plugin Contributions
    88

    Default Re: Which php variable calls for Total Items in Cart?

    Sure, here you go (with 'hard-coded' language):

    Code:
    $itemsInCart = $_SESSION['cart']->count_contents();
    if ($itemsInCart == 1) {
      echo "Did you know a second box will ship for free!<br />"; 
    } else if ($itemsInCart == 3) {
      echo 'Did you know a fourth box will ship for free!<br />';
    } else if ($itemsInCart > 4 && $itemsInCart < 12) {
      echo 'Did you know that up to 12 boxes ship at no extra charge?<br />';
    }

  7. #7
    Join Date
    Nov 2009
    Location
    Chicago, IL.
    Posts
    198
    Plugin Contributions
    0

    Default Re: Which php variable calls for Total Items in Cart?

    That worked really well. thank you. I am going to use some cool images to display instead of the texts. I will send you my site over the weekend to check it out. now off to finding resources to create round edge boxes.

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,501
    Plugin Contributions
    88

    Default Re: Which php variable calls for Total Items in Cart?

    re: round-edge boxes ...

    I'm using the jquery.corner functionality (http://jquery.malsup.com/corner/) with good success.

  9. #9
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Which php variable calls for Total Items in Cart?

    If you can deal with people who have older browsers (basically only IE8 & older) not seeing the rounded cormers, you can get them entirely with CSS in your stylesheet, without adding any HTML divs or javascript etc. All major browsers except IE now support this.
    Code:
    .yourBoxElement {
        -moz-border-radius: tl tr br bl;;
        border-radius: tl tr br bl;
        border-style: solid;
        border-width: 2px;
        }
    http://ie.microsoft.com/testdrive/HT...s/Default.html

    A good description of how the property works in detail:
    http://www.css3.info/preview/rounded-border/
    Last edited by gjh42; 24 Sep 2010 at 10:03 PM.

 

 

Similar Threads

  1. v151 php help please - set variable based on items on order
    By philip937 in forum General Questions
    Replies: 11
    Last Post: 13 Aug 2014, 07:27 PM
  2. v151 Global variable for total shipment weight
    By d0ugparker in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 21 Sep 2013, 03:58 PM
  3. v151 which file calls tpl_index_product_list.php?
    By archelaus in forum Templates, Stylesheets, Page Layout
    Replies: 21
    Last Post: 8 May 2013, 08:55 AM
  4. knowing which php file calls which?
    By joemind in forum General Questions
    Replies: 0
    Last Post: 15 Oct 2008, 08:28 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