In D7, Commerce offered a hook called hook_commerce_cart_attributes_refresh_alter(), offering the following possiblity:
Allows modules to add arbitrary AJAX commands to the array returned from the Add to Cart form attributes refresh.
When a product selection widget's value is changed, whether it is a product select list or a product attribute field widget, the Add to Cart form gets an AJAX refresh. The form will be rebuilt using the new form state and the AJAX callback of the element that was changed will be called. For this form it is commerce_cart_add_to_cart_form_attributes_refresh().
The cart form's particular AJAX refresh function returns an array of AJAX commands that perform HTML replacement on the page. However, other modules may want to interact with the refreshed form. They can use this hook to add additional items to the commands array, which is passed to the hook by reference. Note that the form array and form state cannot be altered, just the array of commands.
Currently, this is not possible in DC2 without altering the form and fully replace the original Ajax callback. I'll post a PR on Github soon and report back here
Comments
Comment #2
agoradesign commentedok, pull request is created: https://github.com/drupalcommerce/commerce/pull/367
Comment #3
bojanz commentedWe need to wait for #2716417: Allow rendering of variation fields on the product entity. to land, then add the event as agreed upon.
Comment #4
bojanz commentedComment #5
agoradesign commentedNow that #2716417: Allow rendering of variation fields on the product entity. is in, I'll assign this task to me. Will care about this today
Comment #6
agoradesign commentedhere we go: https://github.com/drupalcommerce/commerce/pull/383
Comment #8
bojanz commentedCommitted, thanks!