1

I'm trying to retrieve an image stored within a Grid fieldtype.

I'm getting grid_parser errors using EE 2.7.2 and Cartthrob 2.4

{exp:cartthrob:cart_items_info}
      {exp:channel:entries channel="products" entry_id="{entry_id}"}
          {product_detail_image limit="1"}
              <img src="{product_detail_image:product_image}" alt="{title}" />            
          {/product_detail_image}
      {/exp:channel:entries}
{/exp:cartthrob:cart_items_info}

The changelog says that Cartthrob has been updated to fix Grid compatibility.

Or perhaps an example if my code is freaky.

1

I know this was asked over 3 months ago, but the question is still valid and the answer that was given is not.

With CartThrob, a lot of information is stored in the cart_items_info tag that needs to be displayed. In my case, I'm using a conditional whether or not to allow someone to update the quantity in the shopping cart. I'm using Grid to set details about the product and without the ability to parse the Grid data, the conditional doesn't work.

A work-around for most scenarios is to embed a template with

entry_id="{entry_id}"

and then using the channel:entries tag in the embedded template to display the Grid data.

CartThrob was updated to 2.5 which added some Grid support but has not fixed the issue with the cart_items_info tag.

Here's the error it's throwing when a Grid field type is within the cartthrob:cart_items_info tag:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: 106

Filename: libraries/Grid_parser.php

Line Number: 155

Update - I was able to get my conditional to work by using the embedded template and the entry_id variable, adding the conditional with Grid :total_rows parameter, adding another cartthrob:cart_items_info tag within the conditional and adding the entry_id as a parameter so it will only display a single item as opposed to looping through all items. It's the long way around the situation, but it does fix my problem.

Hoping CartThrob will have full Grid support in the near future.

  • The embedded route is exactly what I ended up doing, which has worked. The errors you're getting is exactly what I got, what was reported before, and what Cartthrob's changelog said was fixed. – kurtsamson Feb 14 '14 at 6:20
0

It seems a problem with cartthrob not parsing grid field data properly with paired tags. For a workaround I just created a small plugin till this issue is really resolved.

Download At : cartthrob_gridimage_fix

This helps in not using too many embeds and also a workaround without modifying the cartthrob core.

Tip : SUBSTANTIALLY THIS PLUGIN CAN ALSO BE USED TO LOAD GRID IMAGES FOR A GIVEN ENTRY AT ANY PLACE WITHOUT USING CHANNEL ENTRIES TAGS THUS HELPING IN, AVAID UNWANTED CHANNEL FIELDS.

-1

Here is how it should work:

{exp:channel:entries channel="products"}
   {product_detail_image}
      <img src="{product_detail_image:product_image}" alt="{title}" />
   {/product_detail_image}
{/exp:channel:entries}

Or:

{exp:channel:entries channel="products"}
       {product_detail_image}
          {product_detail_image:product_image limit="1"}
             <img src="{url}"/>
          {/product_detail_image:product_image}
       {/product_detail_image}
    {/exp:channel:entries}

i think that you dont need this:

{exp:cartthrob:cart_items_info}

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.