1

I have set up a site for booking various conference events with each event represented by a product.

I am trying to output the booking options (set by the item_options) for each event. The following works but with a couple of problems:

 <table>
    {exp:channel:entries channel="orders"} 
{if first_item} <tr><td>Order ID</td>{item_options}<td>{option_label}    </td>{/item_options} </tr>{/if} 
    {exp:cartthrob:order_items order_id="{entry_id}" entry_id="{8647}"}
  {if first_item} <tr><td>Order ID</td>{item_options}<td>{option_label}</td>{/item_options} </tr>{/if}   
   <tr><td>{order_id}</td>{item_options}<td>{option_value}</td>{/item_options} </tr> 

    {/exp:cartthrob:order_items}
    {/exp:channel:entries}
     </table>

I am encountering two issues:

  1. The table heading is appearing for every row
  2. The out put works ok if the item entry id is set directly (ie in this case 8647) but I would like to be able to allow the user to select an event on another page and have the entry id fed to the results via a segment. The following code does not work:

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

Any help would be much appreciated! Thanks

EDIT: I managed to get the table header sorted by ysing the following code.

{exp:cartthrob:order_items entry_id="8646"} 
     {if item:first_item}
                <table>
        <thead>
        <tr>
        <td>entry_id</td>
        <td>title</td>
        {item_options}
            <td>{option_label}</td>
            {/item_options}
        </tr>
        </thead>
        <tbody>
        {/if}
    <tr>
        <td>{entry_id}</td>
   <td> {title}</td>
    {item_options}
    <td>{option_value} </td>
    {/item_options} 
</tr>
     {if item:last_item}


                        </tbody> 
  </table> 
                  {/if}
    {/exp:cartthrob:order_items} 

The Issue of not being able to output a specific list of order items using the entry_id="{segment_3}" still remains.

1

There is no such conditional as first_item in exp:channel:entries.
You need to do this:

{exp:channel:entries channel="orders"}
  {if count == 1}...{/if}
{/exp:channel:entries}

But you are repeating the first row inside and outside of the exp:cartthrob:order_items tag, so it will be shown anyway.

As for the order_id in exp:cartthrob:order_items, what does "doesn't work" mean? Nothing gets displayed? Have you tried adding parse="inward"?

| improve this answer | |
  • {exp:cartthrob:order_items entry_id="8646"} {if item:first_item} <table> <thead> <tr> <td>entry_id</td> <td>title</td> {item_options} <td>{option_label}</td> {/item_options} </tr> </thead> <tbody> {/if} <tr> <td>{entry_id}</td> <td> {title}</td> {item_options} <td>{option_value} </td> {/item_options} </tr> {if item:last_item} </tbody> </table> {/if} {/exp:cartthrob:order_items} – user579984 Sep 19 '13 at 19:53
  • sorry - ignore previous comment! As you can see by my update to the question I have solved the table header issue. In terms of outputting the order info for a specific entry - if I add the entry_id directly into the code I get a list of all the bookings made but if I try entry_id="{segment_3}" parse="inward" nothing gets displayed. – user579984 Sep 19 '13 at 20:10

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.