X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Displaying "item" or "items" in minicart (https://forum.x-cart.com/showthread.php?t=54424)

Sisom 06-30-2010 09:43 AM

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.

Sisom 06-30-2010 11:07 AM

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.

Shamun 06-30-2010 12:00 PM

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

Sisom 06-30-2010 01:53 PM

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}

Vacman 06-30-2010 02:56 PM

Re: Displaying "item" or "items" in minicart
 
Please post the code here when you get it figured out. I too want that as well.

Sisom 07-01-2010 01:26 AM

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)".

amy2203 07-01-2010 01:38 AM

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?

Sisom 07-04-2010 03:55 AM

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.

Sisom 09-04-2010 01:33 PM

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

bjt 12-16-2010 12:13 AM

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}



All times are GMT -8. The time now is 05:57 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.