I've got a cartthrob site where I have two product channels and then an "on_the_fly" product, where a user will enter their data for account number, price and client fields. Here is my add_to_cart code:

    title="Online Bill Pay"
    <input type="text" name="item_options[account_number]" value="" placeholder="Account Number">
    <input type="text" name="price" value="" placeholder="Dollar Amount Owed">
    <input type="text" name="item_options[client]" value="" placeholder="Person Being Served">
    <input type="submit" value="Add to Cart">            

I would assume that would put an item in my cart titled: "Online Bill Pay" with the three options of account_number, price and client appearing in the cart. Only thing that appears in the cart is the title (obviously, its hard-coded) and the price.

And here is my cart template (the switchee conditional is hopefully used to help decipher between my two product channels and the one that I'm adding on the fly) which has no channel name. Perhaps there is a better way to detecting this -- if so I'm open to suggestions.

    {if no_items}There's nothing in your cart{/if}
    {if first_row}
        {exp:cartthrob:update_cart_form return="/cart/"}
    {exp:switchee variable='{channel_short_name}' parse='inward'}
    {case value='events|workshops'}
        {exp:channel_images:images entry_id="{entry_id}"}
            <img src="{image:url:large}">
    {case value=''}
        <img src="image.jpg">
    <a href="{exp:switchee variable='{channel_short_name}' parse='inward'}
    {case value='events'}/events/{url_title}{/case}
    {case value='workshops'}/workshops/{url_title}{/case}
    {case value=''}/pay{/case}{/exp:switchee}">{title}</a>
        {if dynamic}
            {exp:cartthrob:item_options row_id="{row_id}"}
    Quantity: {quantity} @ {item_price}/ea
    <a href="/cart/delete/{row_id}">Remove Item</a>

To recap: I'm not getting the item options for account number or client in the add to cart form to show in the cart. In the cart, I'm unable to detect if this is an existing product channel or my on the fly, user-populated product. Can anyone please advise where I'm going wrong? TIA.

1 Answer 1


I don't really see anything that is obviously wrong with your add to cart form. However, I'd like to check that you have the add_to_cart form loaded inside a channel_entries tag. If not, you will be missing an entry_id for the product. Also, do you have products set up via cartthrob's product channel settings? I'm going to assume that you don't because you are using on_the_fly but if you have the same products setup as entries, then I would recommend using them instead of on_the_fly for better control and inventory.

In my case, I build my products out via data from several channels and assign an entry_id in the form itself (via script) so I use a hidden input field name="entry_id" to do so. At the same time, I use a title input field to set the title instead of using the title parameter in the tag. I have a pretty unconventional setup, but since I needed inventory control, I set up products so that I don't need to use on_the_fly.

I do not use switchee but I do something similar in that I have another hidden input name="item_type" that I use to categorize my items. I then have the output tags set to check that field and change the display to fit the item being shown. As I mentioned above, the entry_id, all item_options etc are set to the form based on user input so I use jQuery to manage the input values and set things dynamically.

  • I have two product channels, but the on_the_fly item is not in a channel entry, as it is dynamically created - populated by user input (account_number, price and client).
    – soire
    Commented Jul 12, 2017 at 16:16

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.