Your account is limited to posting only in the Pre-Sales Questions forum.
Support forum access is limited to members with a purchase history.

If you are working on behalf of another member, please contact us with the name of the license holder and we will upgrade your account.
   
 
Displaying option_value and option_name when using {exp:cart throb:item_options}
Posted: 27 February 2012 07:37 AM   [ Ignore ]
Has a Great Personality
Rank
Total Posts:  34
Joined  2012-01-30

When using the code below…. CT displays the {option_value} just fine… but when it tries to display the {option_name} it literally displays “{option_name}” and NOT the name of the option.

Please advise.

{exp:cartthrob:cart_items_info}   
    
<tr>
    <
td>{title}</td>
    <
td align="center">
 
{exp:cartthrob:item_options row_id="{row_id}" entry_id="{entry_id}" }
  {option_value}
  
</td>
    <
td align="center">
  
{option_name}
  {
/exp:cartthrob:item_options}</td>
    <
td align="center">{quantity}</td>
    <
td align="center">{product_price}</td>
    <
td align="right">{item_subtotal}</td>
    </
tr>
{/exp:cartthrob:cart_items_info} 
Profile
 
 
Posted: 27 February 2012 10:42 AM   [ Ignore ]   [ # 1 ]
Has a Great Personality
Rank
Total Posts:  34
Joined  2012-01-30

Chris… can you help us out?

Profile
 
 
Posted: 27 February 2012 01:23 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRank
Total Posts:  465
Joined  2008-09-30

CT displays the {option_value} just fine… but when it tries to display the {option_name} it literally displays “{option_name}” and NOT the name of the option.

To display a list of selected options you need to loop through the options using the {options} tag pair.

{exp:cartthrob:cart_items_info}   
    
<tr>
    <
td>{title}</td>
    <
td align="center">
 
{exp:cartthrob:item_options row_id="{row_id}" entry_id="{entry_id}" }
     {options}
          {if selected}
                {option_value}
                
</td>
                <
td align="center">
                
{option_name}
          {
/if}
    {
/options}
  {
/exp:cartthrob:item_options}</td>
    <
td align="center">{quantity}</td>
    <
td align="center">{product_price}</td>
    <
td align="right">{item_subtotal}</td>
    </
tr>
{/exp:cartthrob:cart_items_info} 
Profile
 
 
Posted: 28 February 2012 06:56 AM   [ Ignore ]   [ # 3 ]
Has a Great Personality
Rank
Total Posts:  31
Joined  2010-03-05

Hi Chris,
Thanks for that - is this different behavior from previous CT stores? Its just i used the base code from the installed demo templates?
I see from your docs how this would make sense, i’ll play, thanks, N

Profile
 
 
Posted: 28 February 2012 08:36 AM   [ Ignore ]   [ # 4 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  10218
Joined  2008-09-29

Thanks for that - is this different behavior from previous CT stores? Its just i used the base code from the installed demo templates?

Well… maybe. Though we try to be consistent, we have a lot of docs and samples, and ultimately a lot of the documentation process is a manual one so it’s possible there are mistakes. When we come across a mistake, we fix it.

One note though: we do have both field types & dedicated tags which operate in a slightly different. I recommend ONLY using the dedicated tags (like Barrett notes above) rather than the field types.

 Signature 

We’re moving away from the forums, though not entirely and not immediately. Lack of support lately is coincidental to that. Unfortunately we’ve had a bad month with it, but we do not forsee that we will have any continued problems with support through our portal going forward, or on forums while we’re still transitioning. We will send out a newsletter and make additional notifications through twitter and other outlets over the coming weeks.

Moving forward; things returning to normal.

Profile
 
 
Posted: 28 February 2012 08:46 AM   [ Ignore ]   [ # 5 ]
Has a Great Personality
Rank
Total Posts:  31
Joined  2010-03-05

Hi Chris,
Thanks again for the reply - i was only asking the above as i wondered if the installed example templates maybe worked in a different way, or were outdated.
I think i will always refer to the manual as opposed to the installed example in future cases - thanks again though.

Can i just clarify what you mean by:
I recommend ONLY using the dedicated tags (like Barrett notes above) rather than the field types.

The code i pasted was from the cart_view sample template. Do you mean i should use the following loop:

{exp:cartthrob:item_options row_id="{row_id}" entry_id="{entry_id}" }
{options}
...{/options}
{
/exp:cartthrob:item_options} 

As opposed to the example templates code as below:

{exp:cartthrob:item_options row_id="{row_id}" entry_id="{entry_id}" }
...
{/exp:cartthrob:item_options} 

Cheers, Support has been great, apologies for all the little nagging enquiries!

Profile
 
 
Posted: 28 February 2012 01:24 PM   [ Ignore ]   [ # 6 ]
Administrator
Avatar
RankRankRankRankRank
Total Posts:  10218
Joined  2008-09-29

I mean using our tags vs field type tags:

http://cartthrob.com/docs/tags_detail/item_options/

versus this:
http://cartthrob.com/docs/#specialty-fieldtypes

http://cartthrob.com/docs/fieldtypes/price_modifiers/index.html

AND use this:
http://cartthrob.com/docs/tags_detail/order_items/index.html

not this;
http://cartthrob.com/docs/fieldtypes/order_items/index.html

We started out with outputting a lot of things using custom field types. However, over time, we’ve pulled most custom field type functionality into CT itself for easier support and better consistency which is why I suggest using dedicated tags vs. field type tags. Most people don’t get the difference in syntax, or that a field type variable pair is different than our module tags, and it causes problems for me and them. While I haven’t deprecated those field type docs yet, we may eventually do so.

Regarding what to follow: Generally the docs DO get updated faster than the sample templates. I regularly update both for factual errors, but it’s a fact I can update the online docs, and I CAN’T update your installed templates.

 Signature 

We’re moving away from the forums, though not entirely and not immediately. Lack of support lately is coincidental to that. Unfortunately we’ve had a bad month with it, but we do not forsee that we will have any continued problems with support through our portal going forward, or on forums while we’re still transitioning. We will send out a newsletter and make additional notifications through twitter and other outlets over the coming weeks.

Moving forward; things returning to normal.

Profile
 
 
Posted: 29 February 2012 10:50 AM   [ Ignore ]   [ # 7 ]
Has a Great Personality
Rank
Total Posts:  31
Joined  2010-03-05

Hi Chris,
Thanks for the clarification on that, i see what you mean now, and why i have been getting a little bit lost. As it was my first step into CT i have been learning/building from templates and as such not really knowing which are the right tags to use other than the ones i come across first! But i understand dedicated tags vs fieldtype tags now, and it makes sense, i will implement.

Thanks again, support is great here, N

Profile