First of all, Thank You for an awesome module that works!!! and works great!
In the cart block I noticed that the price per each product is just price of that product. It does not take into account the quantity. So right now it looks like this:
1x Walnuts _______ $1.50
3x Peanuts _______ $2.00
5x Cashew nuts ___ $1.00
Total: $12.50 _____ Checkout
What I would like to achieve is a display that looks like this:
1x Walnuts $1.50_______$1.50
3x Peanuts $2.00_______$6.00
5x Cashew nuts $1.00___$5.00
Total: $12.50__________Checkout
If this was Views, I could do it, but there doesn't seem to be a way to do this through the template because $products_list_html comes from inside the module and does not make such calculation.
Could this be incorporated into the module, please? Because it's pretty standard how cart blocks are displayed on the web.
And could you also make the product name be linked to it's Product Display node?
Many thanks!
Comments
Comment #1
subhojit777Comment #2
subhojit777The cart block is rendered through a template file so that anyone can customize it.
$products_list_htmlis there because I wanted to minimize any PHP execution in template file. The$products_list_htmlis evaluated in a preprocess function.The changes you are asking in shopping cart can be easily done by overriding template file. This is how
$products_list_htmlis processed.You need to write something similar in your shopping cart preprocess function. This request is user centric, so it cannot be incorporated inside module.
Your other request, show product name as link to product display, this can be done by overriding template file. This can be incoporated in the module if I see there are more requests.
It would be good if the shopping cart comes from a view (commerce module provides a shopping cart block), but such changes will be done in 2.x version of this module, or may be in 8.x release of this module.
Comment #3
drupalina commentedThank you for your reply!
Would it be possible to provide a temporary code for those of us who are not coders, please?
Thanks in advance!
Comment #4
subhojit777Comment #5
subhojit777I have updated the code. The variables are added in the template preprocess, and you can easily override them in your custom theme preprocess, and the template now handles the rendering of cart block. In
dc_ajax_add_cart.moduleyou will find this:In your custom theme preprocess you just have to change its value, just multiply the price with quantity, you will get the data in
$variables.Comment #6
joe huggansI would also like to say how great this module is, it has really brought my ecommerce website to life!
I am having a similar hiccup, in that I am creating a pizza shop. The extra toppings are defined in taxonomy and then rules updates the prices. The only issue is that although the total in the cart block is correct. The prices for the pizzas are wrong.
For example, if I add a pepperoni pizza at $5, this gets added fine, but then if I add a pepperoni with extra cheese, which would incur an extra charge of $1, the price for the pizza without extras is also changed in the actual cart block... Although again, the total is correct.
Furthermore, if I then add the same pizza with, for example, extras of cheese and pepperoni. All the pizza prices in the cart block which are of this pizza are changed.
Yet on the cart page, the prices are all correct, which makes me think that Rules is working fine and some configuration is required in this module.
Any help here would be awesome
Comment #7
joe huggansI'm wondering if this could be an issue with rules afterall, there seems to be similar issues with other modules.. Please see https://www.drupal.org/node/2420303
Comment #8
subhojit777Could you please open an issue regarding this. Your problem is not related to this issue.
This module only depends on Commerce API, and does not works with Rules. We need to investigate more on this bug.
Comment #9
joe huggansI have opened a ticket already :) thanks