Add To Cart Button Appearing For All Items On List

alt=
Ekwe
@ekwe
9 years ago
212 posts
So here is my code, when an item for sale comes up among others that are for free. The button shows up for all the items instead for the item that is higher than $0 only. when i remove the {foreach}, it shows the buy button, but it links to the wrong item on the list. Please do help

{foreach $_items as $item}
                                
    {jrFoxyCart_add_url module="jrAudio" item=$item field="audio_file" assign="cart_url"}

<a href="{$cart_url}">                                
<div class="aaddicon" alt="Buy" title="Buy {$item.audio_title} by {$item.profile_name}"><i class="fa fa-shopping-cart"></i></div>
</a>

{/foreach} 

updated by @ekwe: 09/17/15 09:28:29PM
douglas
@douglas
9 years ago
2,793 posts
What template is this in and what skin are you using?

Thanks!


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
michael
@michael
9 years ago
7,746 posts
Thats an easy one, check there is a price for the item before making a button for it. ;)

{foreach $_items as $item}
                          
{if isset($item.audio_file_item_price) && $item.audio_file_item_price > 0}      
    {jrFoxyCart_add_url module="jrAudio" item=$item field="audio_file" assign="cart_url"}

<a href="{$cart_url}">                                
<div class="aaddicon" alt="Buy" title="Buy {$item.audio_title} by {$item.profile_name}"><i class="fa fa-shopping-cart"></i></div>
</a>
{/if}
{/foreach}
alt=
Ekwe
@ekwe
9 years ago
212 posts
Almost worked. It's no more showing for tracks on the list that are free. But it still shows multiple "add to cart" button on each item for all the others on the list that are above $0.00
michael
@michael
9 years ago
7,746 posts
Try removing your code. Seams like your adding code when its not needed if your getting 2 add to cart buttons.

Tags