(Add to Cart) product button AJAX
I want the user to add the products to the cart with ajax, with my little knowledge of Drupal, i was able to add to the function (commerce_cart_add_to_cart_form) the Form Control #ajax to the submit form in the cart module file, this works as expected, the form is submitted using ajax.
After the calls complete nothing happens, because i haven't added any functions as callback, and if i refresh the page, the cart block gets updated, and the added to cart message appear. so this part is working (but i don't know if this breaks something yet).
The problem comes with the updating of the shopping cart block, i want the newly added product to appear but i haven't bean able to do this.
I think this is very easy to do, but my lack of knowledge is making it a big deal.
If someone could help me with this, i would greatly appreciate it.
I am in the same boat... and I'm sure it is easy- have you had any luck with this?
I think you should be able to
I think you should be able to set up a basic module to return the data from the cart view via the call back, as in this tutorial:
Drupal & Ajax - How to dynamically update view display
Set the callback function to fetch the data, and you'll have a fresh version of the cart view to insert.
Could I ask you to elaborate on how you created the custom form? I'm interested in doing the same thing, but I'm new to creating forms in Drupal, and not sure how to begin interacting with commerce_cart_add_to_cart_form.
Hey verges, I've did the same
I've did the same to have an ajax add to cart behavior, but for some reason, the form does add the product the first time i click on it, but if i click a 2nd time, the product is not added twice (unless i select another product variation, then re-select the one i want to add).
Did you experience any behavior like this ?