2

In the following code I'm using Expresso store to stash the current user's basket away.

Win it I'm setting a nested list so that I can loop through the options and display them as a definition list.

However that nested list doesn't seem to be returning.

Can anybody spot what's wrong here?

Set List

{exp:store:cart}
    {exp:stash:set name="basket-total"}{order_subtotal}{/exp:stash:set}
    {exp:stash:set_list name="basket-items" process_tags="yes"}
        {items}
            {stash:title}{title}{/stash:title}
            {stash:quantity}{item_qty}{/stash:quantity}
            {stash:entry-id}{entry_id}{/stash:entry-id}
            {stash:price}{exp:stash:embed:rcf:ecom_price stash:entry-id="{entry_id}"}{/stash:price}
            {stash:subtotal}{item_subtotal}{/stash:subtotal}

            {exp:stash:set_list:nested name="options"}
                {modifiers}
                    {stash:option}{modifier_name}{/stash:option}
                    {stash:value}{modifier_value}{/stash:value}
                {/modifiers}
            {/exp:stash:set_list:nested}
        {/items}
    {/exp:stash:set_list}
{/exp:store:cart}

Get List

    {exp:stash:get_list name="basket-items"}
        <tr>
            <td class="basket--image"><img src="http://placehold.it/90x90"></td>
            <td class="basket--item">
                <strong>{title}</strong>
                <ul class="basket--item--controls">
                    <li><a href="#">Remove</a></li>
                </ul>
            </td>
            <td class="basket--options">
                <dl>
                    {exp:stash:get_list:nested name="options"}
                        <dt>{option}</dt>
                        <dd>{value}</dd>
                    {/exp:stash:get_list:nested}
                    <dt>Quantity:</dt>
                    <dd>{quantity}</dd>
                </dl>
            </td>
            <td class="basket--item-sub-total">{subtotal}</td>
        </tr>
    {/exp:stash:get_list}
2

I found the solution. I was using process_tags instead of the correct parse_tags.

For people who found this, this is the code that works so far.

Setter

{exp:store:cart}
{exp:stash:set name="basket-total"}{order_subtotal}{/exp:stash:set}

{!-- Set a list of all the products in the user's basket and save it for 2 hours unless the user updates it --}
{exp:stash:set_list name="basket-items" scope="user" save="yes" refresh="120" {if segment_2=="added"||segment_2=="updated"}replace="yes"{/if} parse_tags="yes"}
    {items}
        {stash:title}{title}{/stash:title}
        {stash:quantity}{item_qty}{/stash:quantity}
        {stash:entry-id}{entry_id}{/stash:entry-id}
        {stash:price}{exp:stash:embed:rcf:ecom_price stash:entry-id="{entry_id}"}{/stash:price}
        {stash:subtotal}{item_subtotal}{/stash:subtotal}
        {stash:key}{key}{/stash:key}

        {!-- Stash the modifiers for this option away --}
        {exp:stash:set_list:nested name="options-{key}"}
            {modifiers}
                {stash:option}{modifier_name}{/stash:option}
                {stash:value}{modifier_value}{/stash:value}
            {/modifiers}
        {/exp:stash:set_list:nested}

    {/items}

{/exp:stash:set_list}
{/exp:store:cart}

Getter

<table>
<thead>
    <tr>
        <th colspan="2">In stock available to buy today</th>
        <th>Your Options</th>
        <th>Price</th>
    </tr>
</thead>
<tfoot>
    <tr>
        <td colspan="3">Subtotal</td>
        <td>{stash:basket-total}</td>
    </tr>
</tfoot>
<tbody>
    {exp:stash:get_list name="basket-items"}
        <tr>
            <td class="basket--image"><img src="http://placehold.it/90x90"></td>
            <td class="basket--item">
                <strong>{title} - {key}</strong>
                <ul class="basket--item--controls">
                    <li><a href="#">Remove</a></li>
                </ul>
            </td>
            <td class="basket--options">
                <dl>
                    {exp:stash:get_list:nested name="options-{key}" parse="inward"}
                        <dt>{option}</dt>
                        <dd>{value}</dd>
                    {/exp:stash:get_list:nested}
                    <dt>Quantity:</dt>
                    <dd>{quantity}</dd>
                </dl>
            </td>
            <td class="basket--item-sub-total">{subtotal}</td>
        </tr>
    {/exp:stash:get_list}
</tbody>

| 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.