2

I can't quite get my head around this one but I'm using Expresso Store, Playa, and Matrix. The parent entry has a Matrix field with a Playa relationship field in one of the cells. This links to a product which is of the Store field type. I need to retrieve the price of that product in the other channel. How?

To clarify, I have a 'Lists' channel and a 'Gifts' channel. The Gifts channel stores the product info using the Store field. The Lists channel is the parent and makes the relationship. The product is related (by title of the product) in a Matrix field in the parent. I can extract the title of the product successfully like this:

{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
    {/product}
{/product_list}

The above works. The following doesn't work but it's the kind of thing that I want to be able to do but don't know how with this level of nesting or retrieval:

{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
        {product_info} {!-- Store field of the related product in Gifts channel --}
            {regular_price} {!-- Price field within the Store field --}
        {/product_info}
    {/product}
{/product_list}
3

There are a couple of ways to approach this if you are just wanting to have price you would want do something along the following (as referenced here)

Most variables can also be used outside of the product form, inside a standard {exp:channel:entries} loop. For example, if your Store products custom field is named “product_details”, then the price is also accessible as: {product_details:price}

{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
        {product_info:price} {!-- This is the format of custom_field_name:value_to_retieve --}
        {product_info:regular_price}
        {product_info:sale_price}
    {/product}
{/product_list}

If you are wanting to add the item to the cart you would want to do something along the lines of:

{product_list} {!-- Matrix field of the parent --}
    {product}  {!-- Matrix cell of the above field --}
        {title} {!-- Title of the product successfully retrieved --}
        {exp:store:product entry_id="{entry_id}"} {!-- Store field of the related product in Gifts channel --}
            {regular_price} {!-- Price field within the Store field --}
Other fields here like quantity, modifiers, and a submit button
        {/exp:store:product}
    {/product}
{/product_list} 
| improve this answer | |
  • Dude, you rock HARD! That's exactly what I needed and works like a charm for both child info retrieval (product details from Gifts channel) and in terms of adding to the cart (which was the other bit I needed and was going to ask next). Nicely anticipated. I'd say it's worth an extra vote for the slightly unnerving but not unwelcome foresight into my next question too. :) Thanks for the quick response too. Legend! – Ian Feb 11 '13 at 22:30
  • Glad that it worked out for you. I edited my my answer to actually be properly formatted code block. – Justin Long Feb 12 '13 at 1:28

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.