0

I've got different types of products (in different channels) in a CartThrob store. Is it possible to add a conditional within the Checkout Form tag to enable certain checkout fields to only appear if there's a product from a certain channel in the cart? If so, how would I go about doing this?

I've been looking at the Checkout Form tag and the Cart Items Info tag, but there doesn't appear to be anything here to test for what I'm looking for (please correct me if I'm wrong!). I also looked at the Is In Cart tag, but this only seems to work for adding one entry ID at a time, not looping through lots of entry_id's in a channel (which rules out adding all the entries in this particular channel, though that might have been impractical anyway).

There is a Cart Entry ID's tag, but I can't figure out how to use this in a conditional that would output a single true/false result (for use in a conditional) if one of the pipe-delimited entry ID's belonged to a certain channel. Thanks for any advice on this.

1 Answer 1

1

You can probably get this done with stash. This is off the top of my head so please refer to the Stash documentation.

{exp:stash:set name="is_engravable" parse_tags="yes" parse_conditionals="yes" default="0"}{exp:cartthrob:cart_items_info}{if channel_name == "engravable_products"}1{/if}{/exp:cartthrob:cart_items_info}{/exp:stash:set}

{exp:stash:parse process="end"}
  {exp:cartthrob:checkout_form}
  {if {exp:stash:not_empty name="is_engravable"}}
  <label>Engraving</label>
  <input type="text" name="order_engraving">
  {/if}
  {/exp:cartthrob:checkout_form}
{/exp:stash:parse}
1
  • Thanks for this Rob. I don't use Stash, but I'll have a play around with CE Variables to see if that can do the same sort of thing, or if not, will come back to Stash.
    – Stephen
    Commented Aug 15, 2013 at 10:02

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.