0

I have a custom color selection option in Cart Throb. IT has been working great when all colors are the same price.

But now I need to have a color option that is a different price. I know this is easy using CT out of the box (product modifier)

But how would I do it using my code?

<select id="swatch_select_menu" name="item_options[colour]" onChange="showDiv(this.value);"> 
<option value="">Select Colour</option>
{exp:channel:entries channel="colours" category="5|35|34" orderby="title" sort="asc" limit="999" dynamic="no" disable="pagination"}
<option value="{url_title}">{title}</option>
{/exp:channel:entries}
</select>
1

You need to configure a price modifier fieldtype as part of your product channel entry. You then populate this field with all the different colours and prices available for each configurable product.

In your template, you can then use code similar to this (lifted from the docs)

{exp:channel:entries channel="products" url_title="{segment_3}"}

  {exp:cartthrob:add_to_cart_form entry_id="{entry_id}"}

    {exp:cartthrob:item_options entry_id="{entry_id}" }
        {select} 
            <option {selected} value="{option_value}">{option_name} {price}</option>
        {/select}
    {/exp:cartthrob:item_options}

  {/exp:cartthrob:add_to_cart_form}

{/exp:channel:entries} 

Notice how cartthrob gives you the {select} tag to help with generating the dropdown.

Hopefully this will help, but if not, there is some great documentation here: http://cartthrob.com/docs/tutorials/using_price_modifiers_and_product_options/index.html

Joe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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