Closed (fixed)
Project:
Commerce Ajax Add to Cart
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 Oct 2014 at 15:19 UTC
Updated:
22 Feb 2015 at 09:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nebel54Comment #2
nebel54I introduced too many empty lines in my patch… just removed them.
Comment #3
subhojit777Theme templates are used for cart block so that developers can alter it using theme preprocess functions. Usage of drupal_alter() is not required here as we already have theme preprocess functions to do so.
I agree on using a template variable that show product list information in array. There is also another issue #2363335: Please print product price total per each line item? that need this.
According to your patch, header and rows can be altered as they have known keys, but there is no clean way to alter product prices, name, quantity in
$row.Solution/Suggestion:
Create a template variable (associative array would be best) that stores product prices, quantity, name, etc. The array will be used to render block. The block HTML will be stored in
$variables['products_list_html']as before.Comment #4
discipolo commentedIt should be possible to show the product / line item rendered in a display mode imho.
But still get the remove button
Comment #5
nebel54@subhojit777: You are right preprocess functions should be sufficient. So we just need to add associative keys to the array and pass the array to the template. I will provide a new patch.
Comment #6
nebel54@discipolo leveraging view-modes would be great. I did replace the line-item title in a preprocess function with a rendered representation of it. It would be nice if there was an UI to select a view-mode for products in the cart. We should discuss this in a follow-up…
Comment #7
subhojit777Comment #9
subhojit777@Nebel54 I have updated the code and have added render array. Now the the cart will be fully rendered using the template file, earlier the table was rendered in the preprocess function, which is not a good approach. Now the template file will handle the rendering process. The preprocess function only adds additional values for rendering. @Nebel54 could you please the latest dev version of the code.
The teaser block and add to cart message templates are alright, therefore I am marking this issue as "Fixed". Please feel free to re-open if you face any problem.
Although this is a major change in module, but I am not releasing it in 2.x branch because it is just a change in rendering process, there is no major change in the implementation of the module.
@discipolo Please create a new issue for the view mode, we will discuss it over there.
@Nebel54++ thanks for raising this issue :)