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

Improved minicart display
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #1  
Old 09-16-2006, 07:53 PM
 
instink instink is offline
 

Advanced Member
  
Join Date: Aug 2006
Posts: 44
 

Default Improved minicart display

Hi guys, I am basically a hack so please excuse the messy code. Anyway I decided my miinicart needed improving and have got it to the point where I'm really in love with it, looks great, simple to use etc. here is a screenshot:

http://www.jctech.com.au/images/minicart.jpg

Improvements are:

Displays products individually
Product links are clickable
"Remove" link for easy product removal
Shipping and total costs displayed

Credit goes to forum user "mac" for his original minicart mod. I just edited it to make it the way I want. Works with 4.0.16 and should work with most other versions.

edit /minicart.php to be as follows:

Code:
<?php # # $Id: minicart.php,v 1.1.2.1 2005/01/12 07:41:43 svowl Exp $ # if ( !defined('XCART_START') ) { header("Location: home.php"); die("Access denied"); } x_session_register ("cart"); $MINICART["total_cost"] = price_format(0); $MINICART["total_items"] = 0; if (!empty($cart)) { if (!empty($cart["total_cost"])) $MINICART["total_cost"] = $cart["total_cost"]; $MINICART["total_items"] = ((!empty($cart["products"]) and is_array($cart["products"]))?count($cart["products"]):0) + ((!empty($cart["giftcerts"]) and is_array($cart["giftcerts"]))?count($cart["giftcerts"]):0); } $smarty->assign("minicart_total_cost", $MINICART["total_cost"]); $smarty->assign("minicart_total_items", $MINICART["total_items"]); $smarty->assign("minicart_contents", $cart["products"]); //added this line $smarty->assign("minicart_shipping", $cart["display_shipping_cost"]); //added this line $smarty->assign("minicart_delivery", $cart["delivery"]); //added this line $smarty->assign("minicart_delete", $cart["delete"]); //added this line ?>

Then edit /skin1/customer/main/minicart.tpl to be as such:

Code:
{* $Id: minicart.tpl,v 1.12 2004/07/06 14:00:12 svowl Exp $ *} {if $minicart_total_items > 0} {foreach from=$minicart_contents item=item} <table width="100%" border="0" cellpadding="1" cellspacing="0"> <tr><TD class="MiniCartTextSmall"><b>{$item.amount} X <a href="product.php?productid={ $item.productid }" title="{$item.product}">{$item.product|truncate:17:"...":true}</a> </b></tr></td></table> <table width="100%" border="0" cellpadding="1" cellspacing="0"> <tr><td> {include file="currency.tpl" value=$item.display_subtotal} </td><td align=right> {if $config.Adaptives.platform eq 'MacPPC' && $config.Adaptives.browser eq 'NN'}{assign var="js_to_href" value="Y"}{/if} {if $type eq 'input'}{assign var="img_type" value='INPUT type="image" class="blank"'}{else}{assign var="img_type" value='IMG'}{/if} {assign var="js_link" value=$href|regex_replace:"/^\s*javascript\s*:/Si":""} {if $js_link eq $href}{assign var="js_link" value="javascript: self.location='cart.php?mode=delete&productindex=`$item.cartid`'"} {else}{assign var="js_link" value=$href}{if $js_to_href ne 'Y'}{assign var="onclick" value=$href}{assign var="href" value="javascript: void(0);"}{/if}{/if} {if ($config.Adaptives.platform ne 'MacPPC' || $config.Adaptives.browser ne 'NN')}<a href="{$js_link}">Remove</a> {else} <A href="cart.php?mode=delete&productindex=`$item.cartid`"{if $onclick ne ''} onclick="{$onclick}"{/if}{if $title ne ''} title="{$title}"{/if}{if $target ne ''} target="{$target}"{/if}><FONT class="FormButton">{$button_title} </FONT></A> {/if} </td></tr></table> <HR size="1" NOSHADE class="VertMenuHr"> {/foreach} <table width="100%" border="0" cellpadding="1" cellspacing="0"> <tr> <TD class="ProductDetailsTitle">Shipping Cost</td><td align="right" class="MiniCartTextSmall">{$minicart_shipping}</td> </tr> </table> <table width="100%" border="0" cellpadding="1" cellspacing="0"> <tr> <TD class="ProductDetailsTitle">{$lng.lbl_total}: </td> <td align="right" class="MiniCartTextSmall">{include file="currency.tpl" value=$minicart_total_cost}</td> </tr> </table> {else} {$lng.lbl_cart_is_empty} {/if} <hr size="1" noshade class="VertMenuHr"> <A href="cart.php" class="VertMenuItems">{$lng.lbl_view_cart}</A><BR> <A href="cart.php?mode=checkout" class="VertMenuItems">{$lng.lbl_checkout}</A><BR>

Sorry its so messy, I just cut and pasted bits from all over the place. works a treat though

Finally, in skin1/customer/menu_cart.tpl comment out this section:

Code:
{if $cart} <A href="cart.php" class="VertMenuItems">{$lng.lbl_view_cart}</A><BR> <A href="cart.php?mode=checkout" class="VertMenuItems">{$lng.lbl_checkout}</A><BR> {/if}

By doing that last part you are preventing it from showing the "View Cart" and "Checkout" links twice when you are actually in the cart.

Lastly you need to add this to your skin1.css file

Code:
} .MiniCartTextSmall { FONT-SIZE: 11px; }

I hope this is of some use to someone... and that the code actually works in someone elses system and not just mine!!
__________________
X-cart 4.0.16
www.jctech.com.au
Reply With Quote
  #2  
Old 09-17-2006, 06:55 AM
 
gobligoo gobligoo is offline
 

Member
  
Join Date: Sep 2005
Posts: 26
 

Default Re: Improved minicart display

Works like a sharm Thanks for a good mod!

X-cart 4.019 (unix)
__________________
X-cart 4.0.19 (Unix)
--==::wicked::==--
Reply With Quote
  #3  
Old 09-17-2006, 06:41 PM
 
instink instink is offline
 

Advanced Member
  
Join Date: Aug 2006
Posts: 44
 

Default Re: Improved minicart display

Thanks dude, appreciate it.

If anyone can figure out how to make the "Remove" link return you to the page where you were when you clicked it, rather than straight to the cart (which may be empty after clicking the link) that would be great
__________________
X-cart 4.0.16
www.jctech.com.au
Reply With Quote
  #4  
Old 09-19-2006, 05:50 PM
 
yages yages is offline
 

eXpert
  
Join Date: Sep 2004
Location: Australia
Posts: 332
 

Default Re: Improved minicart display

Great mod just what I wanted
__________________
yages
x-cart version 4.5.5
Reply With Quote
  #5  
Old 09-20-2006, 05:40 AM
  Dongan's Avatar 
Dongan Dongan is offline
 

X-Wizard
  
Join Date: Jul 2005
Location: www.mercuryminds.com
Posts: 1,527
 

Default Re: Improved minicart display

was thinking of and got it now.
Reply With Quote
  #6  
Old 09-20-2006, 01:58 PM
  flyclothing's Avatar 
flyclothing flyclothing is offline
 

eXpert
  
Join Date: Aug 2004
Location: Gilbert, AZ
Posts: 357
 

Default Re: Improved minicart display

Quote:
Originally Posted by instink
Thanks dude, appreciate it.

If anyone can figure out how to make the "Remove" link return you to the page where you were when you clicked it, rather than straight to the cart (which may be empty after clicking the link) that would be great

I believe you remove this line (minicart.tpl) if you want the "REMOVE"...removed.

{if ($config.Adaptives.platform ne 'MacPPC' || $config.Adaptives.browser ne 'NN')}<a href="{$js_link}">Remove</a>
{else}
<A href="cart.php?mode=delete&productindex=`$item.car tid`"{if $onclick ne ''} onclick="{$onclick}"{/if}{if $title ne ''} title="{$title}"{/if}{if $target ne ''} target="{$target}"{/if}><FONT class="FormButton">{$button_title} </FONT></A>
{/if}
__________________
Jonathan
Flyclothing, LLC
PO Box 1490
Gilbert, AZ 85299-1571
P 480.422.7350
F 888.359.2568
www.flysportsgear.com?MMCF_xcartforum (X-Cart 4.5.2) FOR SALE
Reply With Quote
  #7  
Old 09-28-2006, 03:52 AM
  RichieRich's Avatar 
RichieRich RichieRich is offline
 

X-Adept
  
Join Date: Sep 2004
Location: London, England
Posts: 750
 

Default Re: Improved minicart display

Quote:
Originally Posted by instink
Thanks dude, appreciate it.

If anyone can figure out how to make the "Remove" link return you to the page where you were when you clicked it, rather than straight to the cart (which may be empty after clicking the link) that would be great

Great mod, yes this would be very useful.
__________________
Richard


Ultimate 5.3.6.4
Reply With Quote
  #8  
Old 10-04-2006, 04:15 PM
 
lootsale lootsale is offline
 

Member
  
Join Date: Sep 2006
Posts: 24
 

Default Re: Improved minicart display

does that code works on 4.1.3? ive tried it but it doesnt work properly. wt do u say?
and i cant find this file: Finally, in skin1/customer/menu_cart.tpl comment out this section:
Thanks
__________________
iddiboy..
lootsale.co.uk..
x-cart 4.1.3..
Reply With Quote
  #9  
Old 10-04-2006, 04:17 PM
 
instink instink is offline
 

Advanced Member
  
Join Date: Aug 2006
Posts: 44
 

Default Re: Improved minicart display

Hi mate, no idea sorry, I've only ever used 4.0.16
__________________
X-cart 4.0.16
www.jctech.com.au
Reply With Quote
  #10  
Old 10-05-2006, 04:24 PM
 
alru111 alru111 is offline
 

eXpert
  
Join Date: Dec 2005
Posts: 244
 

Default Re: Improved minicart display

small fix that will add a dolalr sign to the shipping cost

/skin1/customer/main/minicart.tpl
replace this
<TD class="ProductDetailsTitle">Shipping Cost</td><td align="right" class="MiniCartTextSmall">{$minicart_shipping}</td>



with this

<TD class="ProductDetailsTitle">Shipping Cost</td><td align="right" class="MiniCartTextSmall">{include file="currency.tpl" value=$minicart_shipping}</td>
__________________
X-Cart version 4.0.19
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 04:32 AM.

   

 
X-Cart forums © 2001-2018