I need to be able to limit how many of a certain product can be added to the cart.

I thought I could use {cart_items_info} with an {entry_id} parameter to limit to the product I'm targeting and then use a conditional based on {total_items}, e.g.

{exp:cartthrob:cart_items_info entry_id="XXX"}
{total_items} {!-- returns the total of other items in the cart too, not just the entry_id specified --}
{if total_items <=5} … {/if}

but the tag seems to return the whole cart total items regardless of whether I use the entry_id param or not.

Is this a bug with cart_items_info or is there another way I should be going about this?

1 Answer 1


We had a scenario where free samples are offered by the client, but they only wanted customers to be able to request 1 sample pack at a time to discourage people buying the cheaper samples instead of the real product.

On the product page we have the following:

<div class="add-to-basket">
  {if {exp:cartthrob:is_in_cart entry_id="249"}}
  <p>It looks like you've already added samples to your basket. Our sample packs are free (subject to postage) so they are limited to one per customer.</p>
  <button type="submit">Add To Basket</button>

The difference here is we didn't need to count the products as they were limited to just 1. Not sure whether you could use another conditional within {if {exp:cartthrob:is_in_cart entry_id="xxx"}}?

  • My situation involves samples too except they're paid samples (store is for fabric and sample is just a small square) and the site wants to limit how many samples can be ordered. Seems like the best approach will be to use cart_items_info and add them to a Stash list which can then be counted.
    – Tyssen
    Mar 9, 2015 at 1:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.