Can anyone suggest how I prevent the duplication of related items in an Expresso Store cart (v2.5.1)? At present I'm using this code to generate associated items on the cart page

{items}
  {exp:channel:entries entry_id="{entry_id}"}
     {related_products channel="products"}
     <p><a href="{related_products:url_title_path='products/'}">{related_products:title}</a></p>
    {/related_products} 
  {/exp:channel:entries}
{/items}

This loops through each cart line and outputs it's associated items well enough however if 2 items (or more) in the cart have the same related item(s), then they get shown over and over again and I only ever want one instance of a related entry shown.

  • Are you wanting to display related items for each item in the cart, or for the cart overall? The former is trickier than the latter if you want to prevent duplication. – Derek Hogue Sep 21 '16 at 20:25
  • I want to output associated items for the cart overall. The code I posted above loops through every line in the cart and outputs the associated items for each one. This results in many duplications. I want to avoid this and even if 5 items in the cart have the same item associated with them, for that associated item to only be output once. – Jos Medinger Sep 22 '16 at 7:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.