1

I have set up a T-Shirt with the Options Configurator field type named 'inventory_and_options' but can't work out how to display its selected item options in an invoice.

The products options are:

Size: Red, Blue

Colour: Small, Medium

I have created an order for a medium blue Tshirt.

My invoice code:

{exp:cartthrob:order_items order_id="{entry_id}"}
    {item:title}<br>
    {item_options}
        Option Label = {option_label}<br>
        Option Name = {option_name}<br>
        Option Value = {option_value}<br>
    {/item_options}
{/exp:cartthrob:order_items}

This displays:

Great T-Shirt
Option Label = Inventory and Options
Option Name = Medium Blue
Option Value = sku-medium-blue
Option Label = Inventory And Options:size
Option Name = Medium
Option Value = Medium
Option Label = Inventory And Options:colour
Option Name = Blue
Option Value = Blue

So that has looped through all the item_options but all I want it to give me is:

Great T-Shirt
Size: Medium 
Colour: Blue

If I get rid of the item_options tag and hard code the fields created in the order items field in the orders channel..

{exp:cartthrob:order_items order_id="{entry_id}"}
    {item:title}<br>
    {item:inventory_and_options}<br>
    {if item:inventory_and_options:size}Size: {item:inventory_and_options:size}{/if}<br>
    {if item:inventory_and_options:colour}Colour: {item:inventory_and_options:colour}{/if}<br>
{/exp:cartthrob:order_items}

Displays:

Great T-Shirt
sku-medium-blue
Size: Medium
Colour: Blue

Which is close but obviously causes a problem if I add other product options other than size and colour as I would have to manually update the template whenever I add a new product option.

Sorry for the rambling explanation, has anyone else had problems displaying options in an invoice?

2

Use {if selected}{/if} inside your {item_options} tag.

| improve this answer | |
  • Oh my! I have been through the docs so many times but didn't see that before. I have just found some reference to {if option_selected}{/if} are there any differences in use? – Kenny Mar 23 '13 at 18:36
  • Unfortunately I don't think this has actually solved my issue (although it did solve another issue I had in the cart). I still think I am going to have to hard code the Size and Colour titles in to the invoice because this data isn't actually stored in the order_items field in the order channel. – Kenny Mar 23 '13 at 23:06
1

This was solved by Chris Newton making some tweaks to allow a sub_label tag..

    {exp:cartthrob:order_items order_id="{entry_id}"}

                            {order_items}
                            <tr>
                                <td valign="top"><b>{item:title}</b><br>
                                    <div>

                                        {item_options}
                                            {if sub_label}<i>{sub_label}: {option_value}</i><br>{if:else}<i>{option_label}: {option_value}</i><br>{/if}
                                        {/item_options}

                                    </div>

                                </td>
                                <td valign="top" align="right">{item:quantity}</td>
                                <td valign="top" align="right">{item:price_plus_tax}<br /></td>
                                <td valign="top" align="right">{item:subtotal_plus_tax}<br /></td>
                            </tr>
                            {/order_items}
{/exp:cartthrob:order_items}
| improve this answer | |

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.