1

I've hit a wall with this one. I using Stash and template partials to set my page. Currently I am NOT caching anything.

I have products that have product options associated with them and I have tried several approaches to try at get this to work. The bottom line is, that if I have the Carthtrob {exp:cartthrob:item_options entry_id="{entry_id}"} tag on the page, the product fails to add to the cart.

I have tried to use this as a standalone and use Stash to pass an entry ID, I've also tried to set it as a stash item {stash:product_opt}code-here{/stash:product_opt}.

Stash is parsing the tags and outputting them. I am presuming it is a delightful parse order issue! Another thing I have tried is to embed it and also use it as a snippet. No cigar sadly.

Has anyone come across this?

{exp:stash:set_list name="{segment_1}-Product" parse_tags="yes" scope="site" save="no" replace="no" refresh="1440"} {exp:channel:entries channel="products" status="open" url_title="{last_segment}"}

{stash:title}{title}{/stash:title}

{stash:e_id}{entry_id}{/stash:e_id}

{stash:product_options}
{exp:cartthrob:item_options entry_id="{entry_id}" parse="inward"}
{if dynamic}
<dt>{option_label}</dt>
    <dd class="productOption">{input}</dd>
{if:else}

{if configuration} config{/if}
{if options_exist}
    {if configuration_label}{if:else} <dt>{option_label}</dt>{/if}
    <dd class="productOption">
        {select}
        <option {selected} value="{option_value}">
            {option_name}{if option_price_numeric > 0} +{option_price}{/if}
        </option>
        {/select}
    </dd>
    {/if}
{/if}
{/exp:cartthrob:item_options}
{/stash:product_options}

{/exp:channel:entries} {/exp:stash:set_list}

Many thanks

  • Have you tried adding parse_depth="2" to your set_list tag? You have some nested module tag pairs there. – Rob Sanchez May 7 '13 at 16:34
  • Thanks Rob. Yea, I have tried that. If the tag is parsing before Stash works with it, can you think of any other reason why this wouldn't work? – T2theC May 7 '13 at 19:12
1

I've completed something similar but we captured all entries to a to a series of big stash lists then used get_list name="{segment_1}-Product" match="#{last_segment}#" against="urltitle"} to pull in the relevant item or series of items.

This is the base theory we used, you'll have to experiment to get it to work in your scenario...

//Just capture the elements you require, leave styling to later…
//Set depth to 2, we're parsing exp:channel + also getting nested info from item:options
{exp:stash:set_list name="{segment_1}-Product" parse_tags="yes" scope="site" parse_depth="2"save="no" replace="no" refresh="1440"} {exp:channel:entries channel="products" status="open" url_title="{last_segment}"}
    {stash:title}{title}{/stash:title}
    {stash:urltitle}{url_title}{/stash:urltitle}
    {stash:e_id}{entry_id}{/stash:e_id}
    //Capture the options as a nested list
    {exp:stash:set_list:nested name="product_options{entry_id}" parse_tags="yes" scope="site"}
        {exp:cartthrob:item_options entry_id="{entry_id}" parse="inward"}
            {stash:optionlabel}{option_label}{/stash:optionlabel}
            {stash:optionname}{option_name}{/stash:optionname}
            {stash:optionvalue}{option_value}{/stash:optionvalue}
            {stash:optionprice}{option_price}{/stash:optionprice}
        {/exp:cartthrob:item_options}
    {/exp:stash:set_list:nested}
{/exp:channel:entries}
{/exp:stash:set_list}

//Grab the list and format it however you choose…
{exp:stash:get_list name="{segment_1}-Product" scope="site"}
    <h1>{title}</h1>
    <p>{e_id}</p>
    {exp:stash:get_list:nested name="product_options{entry_id}" scope="site"}
    Label: {option_label}
    Name: {optionname}  Value: {optionvalue} Price: {optionprice}<br>
    {/exp:stash:get_list:nested}
{/exp:stash:get_list}
  • Awesome! Thanks stuartmcd69. I shall give that a go. Looks promising. – T2theC May 8 '13 at 18:02

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.