Problems trying to show whats in the cart on any page

I am trying to show the cart contents to the customer at all times as they browse the website, so on the homepage, pages, products pages, etc etc.



To start, I put it on the homepage. Easy I think.



So, I add the “Cart” Block to the menu. I choose the “sidebox important” template and voila… nothing happens… Nothing showing at all even though I have items in the cart.



Ok, so I delete the “Cart” block and add the “Products in your order” block, I choose the “Summary” wrapper thinking this will solve my problems, and again choose the sidebox important block, and what do I get ?



[color=#333333][font=Arial, Tahoma, Helvetica, sans-serif][size=3]item(s)[/size][/font][/color]

[color=#333333][font=Arial, Tahoma, Helvetica, sans-serif][size=3]$0.00[/size][/font][/color]

[color=#333333][font=Arial, Tahoma, Helvetica, sans-serif][size=3]Shipping[/size][/font][/color][color=#333333][font=Arial, Tahoma, Helvetica, sans-serif][size=3] [/size][/font][/color]

[color=#333333][font=Arial, Tahoma, Helvetica, sans-serif][size=3][size=3][size=3]Order Total[size=3]$0.00[/size][/size]

[/size][/size][/font][/color]

[color=#333333][font=Arial, Tahoma, Helvetica, sans-serif][size=3][size=3]I’m not sure how this is possible seeing that I have 2 items in my cart for $62, so I change the “summary” wrapper to “Products in cart” And what does it show me?[/size][/size][/font][/color]



Products In your Cart

Edit Products>



Holy crap… WHY WONT IT SHOW THE DAMN CART CONTENTS???



Now I change the wrapper to “Order Information” and nothing at all is showing…



So I scrap that block and choose the “Order Summary” Block, needless to say the results are exactly the same as above…



So again, i scrap that and choose the “Order Information Block” and again same crap as above…



Basically the only page that any of these work on is the checkout page… but I want to be able to show people what they have in their carts, and I don’t understand why it shows nothing when they go back to the homepage even though there’s stuff in the cart…



I get so frustrated with this crap software…



Can anybody tell me how to fix this so I can actually show the cart contents as people browse the website? All i can get to work is the “Cart Content” block, but it only shows the quantity of items and the total price, it doesn’t show what the items actually are…



I’m about at my wits end with this stuff and desperately need help.

I found this problem exists yesterday, and it's on the list of things to fix for today.



Will hopefully update this by the end of the day with a fix.



Thanks

Thanks man… It is driving me crazy… how can a cart this far into it's life have so many damn bugs…

[attachment=6500:mini-cart.png]

Quick, simple solution. This is how I did it, no hooks used, just plain old horrible hacking for quickness, but will be redone in future…unfortunately not today.



Create a new template called 'mini_cart.tpl' in:

/skins/your_skin/customer/blocks/static_templates/



In this file, add this code:

```php




{if $smarty.session.cart.amount}

{hook name="index:cart_status"}
{assign var="_cart_products" value=$smarty.session.cart.products|array_reverse:true}
{foreach from=$_cart_products key="key" item="p" name="cart_products"}
{if !$p.extra.parent}

{if $block.properties.products_links_type == "thumb"}

{/if}


{/if}
{/foreach}
{/hook}
{include file="common_templates/image.tpl" image_width="40" image_height="40" images=$p.main_pair show_thumbnail="Y" no_ids=true} {$p.product_id|fn_get_product_name|unescape}


{$lang.qty} {$p.amount} X {include file="common_templates/price.tpl" value=$p.display_price span_id="price_`$key`_`$dropdown_id`" class="none"}









{if $smarty.session.cart.taxes}

{foreach from=$smarty.session.cart.taxes item="tax"}
{$lang.taxes} ({$tax.description}):
{include file="common_templates/price.tpl" value=$tax.tax_subtotal}
{/foreach}

{/if}

{$lang.order_total}:
{include file="common_templates/price.tpl" value=$_total|default:$smarty.session.cart.display_subtotal}



{else}

{$lang.cart_is_empty}


{/if}



```
Now go to Design>Blocks

Add the following block setup:

Add Block > Create New Block > Template (Block with a particular template)

Select 'mini cart' for the Template.

Wrapper: Sidebox General or Important

Save. View your new cart.

mini-cart.png

Thanks, its a good working solution!

Good instructions too, made it really easy to add this!

One problem I found with it, is that if you don't refresh the page, the mini cart wont be updated until you move away, this has now caused a knock-on problem where people keep adding to their cart because its not appearing in the mini cart !

Here's the correct code, including showing thumbnails

As soon as you add a product to your cart this wil automaticly updated


```php

{assign var=“dropdown_id” value=$block.snapping_id}

{assign var=“r_url” value=$config.current_url|escape:url}





{hook name="checkout:minicart"}


{if $smarty.session.cart.amount}

{hook name="index:cart_status"}
{assign var="_cart_products" value=$smarty.session.cart.products|array_reverse:true}
{foreach from=$_cart_products key="key" item="p" name="cart_products"}
{if !$p.extra.parent}









{/if}
{/foreach}
{/hook}
{include file="common_templates/image.tpl" image_width="40" image_height="40" images=$p.main_pair show_thumbnail="Y" no_ids=true} {$p.product_id|fn_get_product_name|unescape}


{$lang.qty} {$p.amount} X {include file="common_templates/price.tpl" value=$p.display_price span_id="price_`$key`_`$dropdown_id`" class="none"}


{if (!"CHECKOUT"|defined || $force_items_deletion) && !$p.extra.exclude_from_calculate}{include file="buttons/button.tpl" but_href="checkout.delete.from_status?cart_id=`$key`&redirect_url=`$r_url`" but_meta="cm-ajax cm-ajax-full-render" but_rev="cart_status*" but_role="delete" but_name="delete_cart_item"}{/if}






{if $smarty.session.cart.taxes}

{foreach from=$smarty.session.cart.taxes item="tax"}
{$lang.taxes} ({$tax.description}):
{include file="common_templates/price.tpl" value=$tax.tax_subtotal}
{/foreach}

{/if}

{$lang.order_total}:
{include file="common_templates/price.tpl" value=$_total|default:$smarty.session.cart.display_subtotal}



{else}

{$lang.cart_is_empty}


{/if}



{/hook}


```

This is great man!

thankyou!

Hi,

Did you ever upgrade this code for 4.x.x ?

I've upgraded my shop and I've tried to reinstall this.The problem is though, it doesn't seem to be compatible with the 4.x shops?

It gives errors that files are not found?



Is there anyone with code experience that can show me how to get it running again? It really was one of the nicest simple addons i had for my shop!



Thanks for any and all help!

[color=#282828][font=arial, verdana, tahoma, sans-serif]Create a new template called '[/font][/color]cart_content_side[color=#282828][font=arial, verdana, tahoma, sans-serif].tpl' in:[/font][/color]


design\themes\basic\templates\blocks\static_templates




[color=#282828][font=arial, verdana, tahoma, sans-serif]In this file add this code:[/font][/color]

```php

{assign var=“dropdown_id” value=$block.snapping_id}

{assign var=“r_url” value=$config.current_url|escape:url}



{if $smarty.session.cart.amount}

{$smarty.session.cart.amount} item(s) - {include file="common/price.tpl" value=$smarty.session.cart.display_subtotal}





{__("view_cart")}






{__("checkout")}



{else}

{__("cart_is_empty")}
{/if}



```

Create also an wrapper called 'sidebox_cart.tpl' in:
```php
design\themes\basic\templates\blocks\wrappers
```

[color=#282828][font=arial, verdana, tahoma, sans-serif]In this file add this code:[/font][/color]
```php
{if $content|trim}


{hook name="wrapper:sidebox_general_title"}
{if $smarty.capture.title|trim}
{$smarty.capture.title nofilter}
{else}
{$title nofilter}
{/if}
{/hook}


{$content|default:" " nofilter}


{/if}
```

[color=#282828][font=arial, verdana, tahoma, sans-serif]Now go to Design>Layouts[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Add the following block setup:[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Click on the 'gear' icon > Manage blocks > [/font][/color]Create New Block > [color=#282828][font=arial, verdana, tahoma, sans-serif]Template (Block with a particular template)[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Give it any name you want (this name will also display on your store)[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Select '[/font][/color]_cart_content_side[color=#282828][font=arial, verdana, tahoma, sans-serif]' for the Template.[/font][/color]

[color=#282828][font=arial, verdana, tahoma, sans-serif]Click on create.[/font][/color]


Place this block on the location/place where you want.

And set the block option at Wrapper '_sidebox_cart'

[color=#282828][font=arial, verdana, tahoma, sans-serif]Save. View your new cart. [/font][/color]

Thank you for updating this, it is very much appreciated, it is truly a great little informative display.



The old minicart used to show the items in the cart, with a nice little picture, a delete option and the quantity and individual price for each item, but this new one doesn’t show anything except the quantity of products and the total price.



This is how the new one that info@elektroshop.nl posted looks:







I really liked his old one much much better than the new, so I changed his code to mix the best of his old and new!

I also didn’t use his wrapper because I wanted something a little more obvious, and instead used the “important” one.













For anyone that wants this, the code all belongs to the original poster, any errors (though I’ve played with this for hours and haven’t found any) belong to me. I basically took his V3 code and mixed it with the V4 changes until it all worked. I don’t know how to center the buttons, or remove the spaces between the products. While the delete works, it doesn’t automatically refresh, so until the user changes pages it will still show the deleted product in the cart even though its not there.





the code I changed is in [color=#282828][font=arial, verdana, tahoma, sans-serif]‘[/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif]cart_content_side[/font][/color][color=#282828][font=arial, verdana, tahoma, sans-serif].tpl’ in:[/font][/color]

[color=#000000]design[/color][color=#666600][/color][color=#000000]themes[/color][color=#666600][/color][color=#000000]basic[/color][color=#666600][/color][color=#000000]templates[/color][color=#666600][/color][color=#000000]blocks[/color][color=#666600][/color][color=#000000]static_templates[/color]



The new code is as follows and will give you this awesome little mini-cart:


<br />
{assign var="dropdown_id" value=$block.snapping_id}<br />
{assign var="r_url" value=$config.current_url|escape:url}<br />
<div id="cart_status_{$dropdown_id}"><br />
					    {if $smarty.session.cart.amount}<br />
							 <table cellspacing="0" cellpadding="0" class="minicart-table"><br />
							    {hook name="index:cart_status"}<br />
							    {assign var="_cart_products" value=$smarty.session.cart.products|array_reverse:true}<br />
							    {foreach from=$_cart_products key="key" item="p" name="cart_products"}<br />
							    {if !$p.extra.parent}<br />
							    <tr class="minicart-separator"><br />
							   <br />
								 <td width="5%" class="cm-cart-item-thumb">{include file="common/image.tpl" image_width="40" image_height="40" images=$p.main_pair show_thumbnail="Y" no_ids=true}</td><br />
				 <br />
								 <td width="94%"><a href="{"products.view?product_id=`$p.product_id`"|fn_url}">{$p.product_id|fn_get_product_name|unescape}</a><br />
								 <p><br />
								  {$lang.qty} <span>{$p.amount}</span><span>&nbsp;X&nbsp;</span>{include file="common/price.tpl" value=$p.display_price span_id="price_`$key`_`$dropdown_id`" class="none"}<br />
								 </p><br />
								 </td><br />
	   <br />
				 <td width="1%" class="minicart-tools cm-cart-item-delete">{if (!"CHECKOUT"|defined || $force_items_deletion) && !$p.extra.exclude_from_calculate}{include file="buttons/button.tpl" but_href="checkout.delete.from_status?cart_id=`$key`&redirect_url=`$r_url`" but_meta="cm-ajax cm-ajax-full-render" but_rev="cart_status*" but_role="delete" but_name="delete_cart_item"}{/if}</td><br />
			   <br />
							    </tr><br />
							    {/if}<br />
							    {/foreach}<br />
							    {/hook}<br />
				   </table><br />
  <i class="icon-basket filled"></i><br />
							    <span class="minicart-title">{$smarty.session.cart.amount} item(s) - <strong>{include file="common/price.tpl" value=$smarty.session.cart.display_subtotal}</strong><br></span><br />
<span class="button button-wrap-left"><br />
<span class="button button-wrap-right"><br />
  <a href="{"checkout.cart"|fn_url}"="" rel="nofollow" class="view-cart">{__("view_cart")}</a><br />
</span><br />
</span>				  <br />
<span class="button-action button-wrap-left"><br />
<span class="button-action button-wrap-right"><br />
  <a href="{"checkout.checkout"|fn_url}"="" rel="nofollow" class="view-checkout">{__("checkout")}</a><br />
</span><br />
</span><br />
					    {else}<br />
							    <i class="icon-basket empty"></i><br />
							    <BR><span class="minicart-title empty-cart">{__("cart_is_empty")}</span><br />
					    {/if}	<br />
<!--cart_status_{$dropdown_id}--></div><br />