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)
-   -   If statement to display 'check out' button (https://forum.x-cart.com/showthread.php?t=40740)

tqualizerman 06-26-2008 12:38 AM

If statement to display 'check out' button
 
Hi All,

I am not using the mini cart sidebox on my site, and would prefer to have an if statement that I can place in my home.tpl which would display a 'check out' button if there are items in the shopping cart.

Can anyone help?

pauldodman 06-26-2008 12:56 AM

Re: If statement to display 'check out' button
 
Hi
Just use this:

{if $minicart_total_items > 0}Button{/if}

JWait 06-26-2008 05:46 AM

Re: If statement to display 'check out' button
 
Here is what I use....
In customer/home.tpl I added the following at the top of the "menu" column

{if $main ne "fast_lane_checkout"}
{include file="customer/main/minicart-box.tpl" short_mode="short"}
<br />{/if}

Then I modified customer/main/minicart.tpl and named it minicart-box.tpl

Code:

{* $Id: minicart-box.tpl,v 1.17 2006/03/28 08:21:07 max Exp $ *}
{* Mods - BG yellow if cart full - added text *}
{if $short_mode eq "short"}
{if $minicart_total_items > 0}
<TABLE width="155" border="0" cellpadding="1" cellspacing="0" bgcolor="yellow">
<tr>
        <td align="center" nowrap="nowrap"><a href="cart.php"><img src="{$ImagesDir}/custom/top-cart-full.gif" alt="Your Shopping Cart" /><br />
        <b>Items in Cart:<IMG src="{$ImagesDir}/spacer.gif" width="1" height="6" border="0"> {$minicart_total_items}<br />
  <b>SubTotal:<IMG src="{$ImagesDir}/spacer.gif" width="2" height="6" border="0">{include file="currency.tpl" value=$minicart_total_cost}</b></a></TD>
</tr>
</table>

{/if}

{/if}


The image "top-cart-full.gif" shows a full cart and has text that says "Your Shopping Cart".

In essence, what it does is remain invisible until there is something in the cart, then it puts a highlighted box (in my case bright yellow) at the head of the menu column that shows the customer how many items are in the cart, a subtotal, and when clicked takes them to their shopping cart/checkout.

tqualizerman 06-26-2008 11:29 AM

Re: If statement to display 'check out' button
 
Thanks Paul,

That worked great but I'd like to add one more thing to the mix -

how would I create an exception that would prevent the link from being displayed if the page = cart.php?

WhiteDoveGifts 07-01-2008 01:36 AM

Re: If statement to display 'check out' button
 
Quote:

Originally Posted by JWait
Here is what I use....
In customer/home.tpl I added the following at the top of the "menu" column

{if $main ne "fast_lane_checkout"}
{include file="customer/main/minicart-box.tpl" short_mode="short"}
<br />{/if}

Then I modified customer/main/minicart.tpl and named it minicart-box.tpl

Code:

{* $Id: minicart-box.tpl,v 1.17 2006/03/28 08:21:07 max Exp $ *}
{* Mods - BG yellow if cart full - added text *}
{if $short_mode eq "short"}
{if $minicart_total_items > 0}
<TABLE width="155" border="0" cellpadding="1" cellspacing="0" bgcolor="yellow">
<tr>
    <td align="center" nowrap="nowrap"><a href="cart.php"><img src="{$ImagesDir}/custom/top-cart-full.gif" alt="Your Shopping Cart" /><br />
    <b>Items in Cart:<IMG src="{$ImagesDir}/spacer.gif" width="1" height="6" border="0"> {$minicart_total_items}<br />
  <b>SubTotal:<IMG src="{$ImagesDir}/spacer.gif" width="2" height="6" border="0">{include file="currency.tpl" value=$minicart_total_cost}</b></a></TD>
</tr>
</table>

{/if}

{/if}


The image "top-cart-full.gif" shows a full cart and has text that says "Your Shopping Cart".

In essence, what it does is remain invisible until there is something in the cart, then it puts a highlighted box (in my case bright yellow) at the head of the menu column that shows the customer how many items are in the cart, a subtotal, and when clicked takes them to their shopping cart/checkout.


Thanks for this nice mod, just what I was looking for! One thing I do not seem to accomplish is how to change the "Items in Cart" and "Subtotal" language variables. I added both variables minicart_total_items and minicart_total_cost as both text and lbl but they still show up in English. Anyone can help out here?

WhiteDoveGifts 07-04-2008 02:23 PM

Re: If statement to display 'check out' button
 
Anyone can help here? It seems I am missing lng.lbl_cart_items and lbl_total but I don't know how to add them correctly to minicart-box.tpl
[edit] never mind, I already sorted it out. The text was hardcoded ..

WhiteDoveGifts 07-09-2008 09:52 AM

Re: If statement to display 'check out' button
 
For this mod I'd like to change the "Items in Cart" behaviour. Right now if you add 1 product it will add "1" to the items. But if you change the quantity it still says "1 item in cart". Only if you add a different product the amount will change to 2. Does anyone know how to change this?

JWait 07-09-2008 12:02 PM

Re: If statement to display 'check out' button
 
Quote:

Originally Posted by WhiteDoveGifts
Thanks for this nice mod, just what I was looking for! One thing I do not seem to accomplish is how to change the "Items in Cart" and "Subtotal" language variables. I added both variables minicart_total_items and minicart_total_cost as both text and lbl but they still show up in English. Anyone can help out here?


In my example "Items in Cart" and "Subtotal" are hard-coded into minicart-box.tpl. You could make them language variables but I chose not to.

As for the other problem of having the cart say "1" is in the cart when the customer ordered 3 of the same item, I actually changed "Items in Cart" to "Unique Items" (again hard-coded). That way if the customer orders 3 of 1 item, 2 of another item, and 1 of a third item, it will say "Unique Items: 3". Not a perfect solution but without getting too complex it works. One thing I have found is that by high-lighting the "minicart box" in a contrasting color (in my case yellow) to the rest of your site, it draws attention to it, so the customer can see a visual difference and "knows" something is in the cart. You would be surprised how many times a customer will click "Add to Cart" if they are not directed to the cart (an option in x-cart to go or not).

You could actually change the minicart-box.tpl to
Code:

{* $Id: minicart-box.tpl,v 1.17 2006/03/28 08:21:07 max Exp $ *}
{* Mods - BG yellow if cart full - added text *}
{if $short_mode eq "short"}
{if $minicart_total_items > 0}
<a href="cart.php">
<TABLE width="155" border="0" cellpadding="1" cellspacing="0" bgcolor="yellow">
<tr>
        <td align="center" nowrap="nowrap"><a href="cart.php"><img src="{$ImagesDir}/custom/top-cart-full.gif" alt="Your Shopping Cart" /><br />
        <b>Items in Cart:<IMG src="{$ImagesDir}/spacer.gif" width="1" height="6" border="0"> {$minicart_total_items}<br />
  <b>SubTotal:<IMG src="{$ImagesDir}/spacer.gif" width="2" height="6" border="0">{include file="currency.tpl" value=$minicart_total_cost}</b></TD>
</tr>
</table>
</a>
{/if}

{/if}

and clicking any part of the "box" should redirect to the cart. I haven't done this but I think it should work.
Also, my "top-cart-full.gif" is not the standard one in x-cart. It has text that says "Your Shopping Cart" to the right of the standard top-cart-full.gif.

WhiteDoveGifts 07-09-2008 01:27 PM

Re: If statement to display 'check out' button
 
In my site I have changed the background to transparent since this matches the sites design best. Drawing the attention already happens when something is added to the cart because the box suddenly pops-up! I used the "full cart" default image since it has orange in it (one of my primary colors) Clicking on any part of the minicart box takes you to the cart page and that's exactly how I like it now. the only thing I am not sure about is if I want to display "unique items" instead of total items.

JWait 07-22-2008 05:51 AM

Re: If statement to display 'check out' button
 
You can always include other parts of the minicart if you wish (I chose to keep it simple). There is a thread at http://forum.x-cart.com/showthread.php?t=24999&page=7&highlight=descriptiv e+minicart that modifies the minicart to do all sorts of things. If you enclose it in the same "if" statement it will display or not... your choice.


All times are GMT -8. The time now is 10:56 AM.

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