Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Hello,
Great module, I found it better than the other commerce ajax cart module.
The only thing I prefer in the other module is that it use a view to render the cart whereas this module reinvent the wheel by creating the cart table from scratch in dc-ajax-shopping-cart.tpl.php
Proposed resolution
So, if you want to use the default shopping cart block provided by drupal commerce, just put that code in dc-ajax-shopping-cart.tpl.php (copy it into your theme directory before, as always).
<div class="ajax-shopping-cart-wrapper">
<?php print views_embed_view('commerce_cart_block', 'default'); ?>
</div>
It will render the view and you will be able to customize it more easily.
We will also require to do the following:
- Create views field that will provide a link to remove item from cart
Remaining tasks
- Identify other aspects of the module that we need to change
- Write a patch
User interface changes
- The admin interface may change
API changes
N/A
Data model changes
N/A
Comments
Comment #2
subhojit777Currently we are re-inventing the wheel, I agree. The AJAX functionality depends on the markup of the cart. Rather than embedding the view, I think it would be better to implement the AJAX functionality in existing shopping cart view itself.
Comment #3
subhojit777Comment #4
subhojit777Comment #5
subhojit777Comment #6
Neo13 CreditAttribution: Neo13 commentedProposed solution actually works. You just need to modify the view to add remove button and whatever else you need.
Comment #7
prjcarr CreditAttribution: prjcarr as a volunteer commentedI tried the above and it seems to work fine. Is there any way to add the remove button? I add a delete button in the view but it just redirects to the front page.
Comment #8
subhojit777We have to add the remove button in the view itself.
Comment #9
prjcarr CreditAttribution: prjcarr as a volunteer commentedDoes that mean the module needs to be updated or is it possible within views now?
Comment #10
subhojit777No the module does not provides remove button for view. I guess it should be possible to do inside views.
Comment #11
doxigo CreditAttribution: doxigo commentedWhen I add the Remove Button in Views using this approach it gives me an error:
So I added Line Item ID and excluded it from display, using Views Base url module as well, I added a Global Text field to my views:
it does work and removes the item from cart, but it's not ajax! I don't know how to fix this part, also note that the Quantity is whole another issue as well.
Comment #12
subhojit777@doxigo Not sure about the error. I guess you need to add
drupal.ajax
library to ajaxify the custom link. See http://cgit.drupalcode.org/dc_ajax_add_cart/tree/dc_ajax_add_cart.module...Comment #13
doxigo CreditAttribution: doxigo commentedI guess by enabling AJax in views, it adds the library, which I did, but still can't get it to work
Comment #14
sahaj CreditAttribution: sahaj commented@doxino Did you got that remove button working?
Comment #15
maxplus CreditAttribution: maxplus commentedYes great idea,
an update and remove button working with ajax would be great!
Comment #16
arefen CreditAttribution: arefen commentedHi. thanks for your perfect soulution. but ajax doesn,t work after enable ajax on views.
Comment #17
subhojit777The ajax won't work because it depends on specific selectors which comes from the block template, that this module provides.
Making this module compatible with the existing cart view will be a major change, and most probably I would like to see this in 8.x version. Still if anyone would like to do the same for 7.x, they are welcome.
Comment #18
VasyOK CreditAttribution: VasyOK commentedHi drupalers!
Delite button worked with this module https://www.drupal.org/sandbox/xandeadx/2621602
Simply check Ajaxify remove button and have a nice day.