2

I am using CarThrob for purchasing places on training courses. Each course type (singing, acting, dance etc) is an entry. Each entry has a Matrix field used for options.

Matrix column names are: option_value (text), age-range (text), time (text), price (text), booked (P&T Pill), student_name (text).

I have CartThrob set so multiple quantities are always added as single items.

On my checkout page in the update_cart_form I would like the customer to be able to fill in the "Student name" field for each item.

At the moment I am getting the student_name input field displayed but as soon as you enter text into it and update it creates a duplicate field next to itself. I can't work out why?

This is my Update cart form.

                    {exp:cartthrob:update_cart_form 

                    id="update_cart_form"
                    class="simple"
                    return="weekend-courses/checkout"
                    }

                    {exp:cartthrob:cart_items_info}

                    {if first_row}
                    <table>
                        <thead>
                            <tr>
                                <th>Subject</th>
                                <th>Quantity</th>
                                <th>Course</th>
                                <th>Cost</th>
                                <th>Student Name</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>
                    {/if}
                            <tr>
                                <td>{title}</td>
                                <td><input class="short" type="text" name="quantity[{row_id}]" size="2" value="{quantity}" /></td>
                                {exp:cartthrob:item_options row_id="{row_id}"}
                                {options}
                                {if selected}
                                <td>{option_value}</td>     
                                <td>{price}</td>
                                <td><input type="text" name="item_options[{row_id}][student_name]" value="{item_options:student_name}" /></td>
                                {/if}
                                {/options}
                                {/exp:cartthrob:item_options}
                                <td>
                                    <label class="checkbox" for="delete_this_{row_id}">
                                        <input type="checkbox" id="delete_this_{row_id}" value="yes" name="delete[{row_id}]">
                                        Remove item
                                    </label>
                                </td>
                            </tr>
                    {if last_row}
                            <tr class="shaded">
                                <td>Total</td>
                                <td></td>
                                <td></td>
                                <td>{cart_total}</td>
                                <td><button type="submit" value="weekend-courses/checkout" name="return" class="btn">UPDATE</button></td>
                                <td></td>
                            </tr>

                        </tbody>
                    </table>
                    {/if}

                    {/exp:cartthrob:cart_items_info}

                {/exp:cartthrob:update_cart_form}   

1 Answer 1

1

I don't think you need the row_id in the name attribute.

It should be like this

<input type="text" name="item_options[student_name]">
3
  • er, nope. I get 4 extra inputs...
    – Tim Print
    May 13, 2013 at 16:02
  • They all have {student_name} in. hmmm.
    – Tim Print
    May 13, 2013 at 16:03
  • If you haven't already, try placing <input type="text" name="item_options[student_name]"> outside the {exp:cartthrob:item_options} tag.
    – SyA
    Aug 6, 2014 at 16:55

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .