Product image on cart form
Does anyone know how you can get a product's image to show on the shopping cart form? In product types there is a line item display and I've added all the fields I want there including the products image but this does not seem to affect the cart form page at all.
I've looked at the line item type editor and it does not seem to offer anything like you get with a Product Display (e.g. Product: Image on the display editor). Nor does the View "Shopping cart form" seem to offer a option to show a field of the attached product.
Am I missing something or will I have to see if I can do something in the template itself? I suppose if I can get the product's ID I can load in the image but I've not checked if any of the line item fields expose the products ID, plus its a bit hackish.
Thanks
Comments
You need to edit the
You need to edit the "shopping cart form" view. If your image field is on the actual product then go to advanced and add the relationship "(Line Item) Commerce Line item: Product". Then go over to fields and add your image. Make sure you have some image styles defined because you'll probably want a smaller thumbnail there.
If you also want this to happen on the checkout page when confirming the order do the same thing to the "Shopping cart summary" view.
Thanks Manfred. That was spot
Thanks Manfred. That was spot on. I still need to learn more about relationships in Views. Just let me at the raw PHP code then things makes sense ;)
I tried this add the
I tried this but for some reason, it did not work but worked only for admin. Added the relationship "Line Item) Commerce Line item: Product " and under fields added "(Product) Field: Image (Image) ".
This worked for the admin but it removes the shopping cart block and shopping cart form for non logged in users. I have absolutely no idea why.
Please do you know of any reason why this could happen?
I have the same issue.
I have the same issue. followed the instructions and now anonymous can not see anything in the cart.
The same problem [resolved]
When I add relationship "(Line Item) Commerce Line item: Product" it removes cart block for all users instead of administrator.
It happened because non logged users don't have a permission to view the product entities.
You should give the "View any product of any type" permission to your user role ( /admin/people/permissions/list).
P.S. Be careful with this primission
Hi Prince Manfred. In
Hi Prince Manfred.
In relationship I have "Commerce Line item: Referenced product" when add this, in fields I have only Node:Product. I can not add pictures in the fields.
Where is problem?
Anyone can help me?
Anyone can help me?
Same issue
"Commerce Line item: Referenced product" appears to be the correct selection in "relationships". After selecting that in your view, you should find the fields you created on the store product type (not to be confused with fields that you created for your display content type).
But as others have mentioned, after doing this, the cart disappears for users who do not have the "View any product of any type" permission clicked on for anon users. Since that permission clearly states, "Warning: Give to trusted roles only; this permission has security implications," then this an unsuitable solution.
So we remain without a useful method of adding a product image to a cart.
lastar84,Found this issue
lastar84,
Found this issue regarding the security notice: http://drupal.org/node/1303194
In short (and from the original programmer's mouth), "You might test what happens with disabled products, but it could be there isn't a security problem and we should just remove that warning."
And later on in the issue, from someone who did a bit of history digging "In summary, I'm not really sure this permission was meant to be flag security sensitive in the first place."
I will state that the real bug is the security flag and not that the shopping cart is broken. Please ignore the notice, and we'll try to get that removed in Commerce-1.4 (please submit a patch if you are aware of how to do that).
Josh
Thanks.
Thanks.
We have had the permission
We have had the permission "View any product of any type" enabled for anonymous users for some time.
We added the 2nd reference to pull images from the product displays (nodes).
There are a total of (5) references:
Commerce Order: Line items
(Line Item) Line Item To Product
(PID 2 NID) Content Type A
(PID 2 NID) Content Type B
(PID 2 NID) Content Type C
Before adding any of the new fields.
The cart does NOT display the line items in the cart for anonymous users.
Help please.
Updated.
After finding -- http://www.drupalcommerce.org/comment/2613#comment-2613
and disable query rewriting
Problem seems fixed.
Good work, Josh
I think you're right. It doesn't seem like a security issue. I'm going with along with that, and allowing that permission. Mine's a testing site anyway, so it's no risk while this issue gets wrangled out, or patched. And no, I don't think you want any patch created by me; it would probably crash the whole Commerce project.
Anyone else who, like me, had
Anyone else who, like me, had the product image in the product display node rather than the in the product itself, you can get this to display in the checkout views using multiple relationships as described here - http://www.apsinfrastructure.co.uk/blog/drupal-commerce-cart-node-fields
Thanks a lot for sharing
@Steve
Thanks a lot for sharing this. This really helped to save great time and customize Commerce.
displaying image from product_display
so, (taken from the above link):
Can't find the relationship 'Commerce Product:Node'
Hi,
seems like, you hav found a solution but how did you get this relationship there,
because i can't find it.
Similar Issue, not showing for new variant types
I am handling the display of my products in the cart using the "products in cart" display within my variation type. This display the image is set to "product_thumbnail" and the cart view has the field "commerce line item: product" with the view mode set to the "products in cart". This seems to be all handle well with the kickstart installation and the existing variants (when they are added to cart), but new product variants I have created dont show the images when added to cart (or add to cart confirmation) even though they have the exact same display setup.
Solution in Kickstart
Just in case somebody needs to do this using Kickstart
1) If you use more than one product display, make sure to re-use the same image field on all product displays
2) Set up an image style e.g. product_image_cart
3) Go to shopping cart, use contextual link to "edit view"
and follow most of dilari's steps above
4) Add a relationship 'Commerce Line item: Referenced product'
5) Add a second relationship '(Product) Commerce Product: Node referencing products from field_product' (in Kickstart that works for all product displays)
6) Add field '(Node referencing products from field_product) Content: ', assign image style, reshuffle order
Done.
I hope this makes sense :).
I got this working using
I got this working using product attribute. The problem is that one products that has multiple images, it'll all show up and I CANNOT find a way to limit that to just one and may even to smaller picture.
Anyone can tell me where i can control these settings?
Drupal 7, no kickstart
https://drupal.org/project
https://drupal.org/project/image_delta_formatter
should do the job for you
Thanks but unfortunately this
Thanks but unfortunately this did not work.
If you dont' mind looking at this pic: http://www.fileconvoy.com/dfl.php?id=gd9448eaa55ca4ded9993652610b95ea1c2...
has the issue.
It has two big pictures. All I want there is just attribute (color and scent) and maybe one smaller picture. But even no picture is ok with me. Just not sure how to manage this.
Under view -> shopping cart form -> Fields -> Configure field: Commerce Line Item: Product Attributes
is where it's managed at as far as I can tell. But it doesn't have image display option which I need. It does have rewrite option and be able to limit to maximum character and when I set it to 1000, I only get one picture but no details.... This would work if I could display details first as I can be ok without display of pictures.
Any thoughts?
How to insert cart image from product display
I have a situation where the product image is handled by the product display node, rather than the variation. Consequently, I am not able to view a product image in either the cart confirmation view or the cart view.
When I try to modify the the cart views, I find that they do not appear to allow a relationship with the referenced content type, from where I could locate the image field.
Am I missing a trick here?
You should end up with
You should end up with something like this in your relationships
Commerce Order: Line items
(Line items referenced by commerce_line_items) Commerce Line item: Product
(Products referenced by commerce_product) Commerce Product: Referencing Node
Works for me !!
Thank you
I did not have my relationships properly configured - your advice was spot on!
Duplicate Referenced Nodes
This works as far as getting field values from the referenced node, but it introduces a new problem for me: If any single commerce product is assigned to multiple product display nodes, then all those nodes are shown in the Shopping Cart form view.
For example, Product X is shown on Page 1 and on Page 2. If I add Product X to my cart and go to the /cart page, then it shows field values from both Page 1 and Page 2.
I thought I could fix it by attempting something similar found in a different issue related to views and duplicate product display nodes, but no dice or at least I'm using the wrong filters.
Any ideas?
Well, it appears the best
Well, it appears the best solution is to probably add the image field/s to the Product Variation and not the display node.
I think that depends on what
I think that depends on what and how you are selling. Both methods have their pros and cons
I have a similar problem
I have a product, a content type to show it (product_ct). product_ct has the field Icon (image). What I need is to show that icon in the /cart page.... (shopping cart) , any ideas?