Discussions

commerce_cart_add_to_cart_form_attributes_refresh and drupal_alter

Hi, I am trying to add an additional AJAX command that's fired when users select a product reference (eg. users select a product reference and a value on the page is updated). I have found commerce_cart_add_to_cart_form_attributes_refresh() and I can't figure out how to make it work. I have everything working except that I can't get both AJAX commands (the one from my module and the ones from commerce_cart) to work at the same time.

I'm using hook_form_alter to add a callback to a hook_form with ajax_command_replace to make changes when a product reference is selected. This works but it doesn't include AJAX commands from commerce_cart_add_to_cart_form_attributes_refresh. How do I merge the 2 AJAX command arrays together?

Posted: Dec 30, 2012

Comments

rj on December 30, 2012

In other words I want to do something like the following:

$cart =  commerce_embed_view('commerce_cart_summary', 'default', array($order->order_id));
$commands[] = ajax_command_replace('.view-commerce-cart-summary', $cart);
hook_commerce_cart_attributes_refresh_alter($commands, $form, $form_state);