Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Displaying "item" or "items" in minicart

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-30-2010, 09:43 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Displaying "item" or "items" in minicart

Hi, I'm trying to edit the language variable
lbl_cart_X_items_total

which I believe displays "item(s)" in the minicart, so that it displays "item" for one item, and "items" for more than one item.

Currently the language variable is:

<span class="minicart-items-value">{{x}}</span>&nbsp;<span class="minicart-items-label">item(s)</span>&nbsp;<span class="minicart-items-delim">/</span>&nbsp;<span class="minicart-items-total help-link" onmouseover="javascript: viewTooltip(this, txt_minicart_total_note);">{{total}}</span>

and I have used something similar to achieve this effect in another site, on the subcategory page, like this:

<td class="P_Count">{if $config.Appearance.count_products eq "Y"}{if $subcat.product_count}{ $subcat.product_count } {$lng.lbl_product}{if $subcat.product_count > 1}s{/if}

so I wondered if anybody knew what smarty parameter (sorry if that's the wrong word) I would use instead of
&subcat.product_count
(which I know is nothing to do with what I want!)

I would then just use something like
item{if $subcat.product_count > 1}s{/if}

instead of

item(s)

in the language variable shown above. (Obviously with the correct Smarty parameter!)
If you could also explain how I find out what Smarty parameter is being used, that would be a great help, so that I can try to find it out for myself next time.
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #2  
Old 06-30-2010, 11:07 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: Displaying "item" or "items" in minicart

I tried
item{if $minicart_total_items > 1}s{/if}
but that doesn't work - I suspect that Smarty tags don't work within a language variable.
I've also never seen a language variable used like this before, i.e. for code, rather than just text.
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #3  
Old 06-30-2010, 12:00 PM
 
Shamun Shamun is offline
 

X-Adept
  
Join Date: Jun 2009
Location: North Carolina
Posts: 841
 

Default Re: Displaying "item" or "items" in minicart

Login to your admin panel, go to General settings and near the bottom enable "Debug console". When you go back to your site, you'll get a pop-up which shows all available variables on that specific page.

Keep in mind that to get info from an associative array you will need something such as this:
arrayName1.arrayName2.arrayName3
__________________
- Shane Munroe
Reply With Quote
  #4  
Old 06-30-2010, 01:53 PM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: Displaying "item" or "items" in minicart

Thanks for your advice, Tal, I think it's definitely
$minicart_total_items
but I don't think I can put the Smarty tags into the language variable, as explained above, so I will somehow have to put the code in the language variable, into minicart_total.tpl, which uses this code:

Code:
{$lng.lbl_cart_X_items_total|substitute:x:$minicart_total_items:total:$total}
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #5  
Old 06-30-2010, 02:56 PM
  Vacman's Avatar 
Vacman Vacman is offline
 

X-Adept
  
Join Date: Sep 2005
Location: Torrance, CA
Posts: 792
 

Default Re: Displaying "item" or "items" in minicart

Please post the code here when you get it figured out. I too want that as well.
__________________
Carl Tice

X-Cart 4.6.6
X-Payments 3.0
ReBOOT 3.4.1

PHP 5.6.30
MySQL 5.6.35
Linux 2.6.32-042stab120.18
ionCube PHP Loader v4.7.3
Perl 5.10.1
Reply With Quote
  #6  
Old 07-01-2010, 01:26 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: Displaying "item" or "items" in minicart

I'm afraid that I am stuck on this one, Vacman, let's hope that somebody else knows the answer! It should be the default on X-Cart anyway, it's very unprofessional looking to have "item(s)".
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #7  
Old 07-01-2010, 01:38 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,509
 

Default Re: Displaying "item" or "items" in minicart

why not just have 2 language variables, 1 for item and 1 for items, then use the if statement to decide which one to display?
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #8  
Old 07-04-2010, 03:55 AM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: Displaying "item" or "items" in minicart

But I don't know how to set up the 'if' statement Amy, that's where I'm having trouble. You don't need to use two language variables, it's easier and clearer to use my method.
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #9  
Old 09-04-2010, 01:33 PM
 
Sisom Sisom is offline
 

eXpert
  
Join Date: Sep 2006
Posts: 310
 

Default Re: Displaying "item" or "items" in minicart

I've found the solution, which is quite simple (but you lose the minicart tooltip, which I don't think anybody will use anyway):

Edit customer/minicart_total.tlp


and on line 11 (I think, this may be a few lines out as I've moved things about a bit while working on this), delete the following line:
Code:
{$lng.lbl_cart_X_items_total|substitute:x:$minicart_total_items:total:$total}

and insert the following instead:
Code:
{$minicart_total_items}&nbsp;{$lng.lbl_item}{if $minicart_total_items > 1}s{/if}&nbsp;{$total}


That works fine, as long as you don't need the Minicart mouseover tooltip, because

the label 'lbl_cart_X_items_total' is as follows:
Code:
<span class="minicart-items-value">{{x}}</span>&nbsp;<span class="minicart-items-label">item(s)</span>&nbsp;<span class="minicart-items-delim">/</span>&nbsp;<span class="minicart-items-total help-link" onmouseover="javascript: viewTooltip(this, txt_minicart_total_note);">{{total}}</span>


My solution uses the much simpler label 'lbl_item' which is, of course, "item".
__________________
X-Cart Gold Version 4.3.2
Reply With Quote
  #10  
Old 12-16-2010, 12:13 AM
 
bjt bjt is offline
 

Advanced Member
  
Join Date: Jul 2008
Location: Vietnam
Posts: 32
 

Default Re: Displaying "item" or "items" in minicart

Just to add to your solution, I did the following to also display the words "is" or "are" depending on whether there is 1 or more items in the cart. Doesn't affect the tool tip either.

Code:
{if $minicart_total_items > 1} <td>There are {$minicart_total_items} {$lng.lbl_item}s{$total} in your cart</td> {else} <td>There is {$minicart_total_items} {$lng.lbl_item}{$total} in your cart</td> {/if}
__________________
X-Cart Gold 4.3.2 (Windows)
X-Cart Gold Plus 4.6.1 (Linux)
Magic Toolbox slider and zoom
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:42 PM.

   

 
X-Cart forums © 2001-2020