When altering views_form in function _dc_cart_ajax_form_views_form_alter() you attach javascript file like this:

// dc_cart_ajax.module:28
$form['#attached']['js'] = array(
  drupal_get_path('module', 'dc_cart_ajax') . '/misc/js/dc_cart_ajax.js'
);

This causes a problem that if there are other attached JS files (let's say altered by other modules), your code overrides the whole array.

This should be fixed with:

$form['#attached']['js'][] = drupal_get_path('module', 'dc_cart_ajax') . '/misc/js/dc_cart_ajax.js';
CommentFileSizeAuthor
#1 1444018-1.patch816 bytesimiksu

Comments

imiksu’s picture

StatusFileSize
new816 bytes

Here's a patch.

imiksu’s picture

Status: Active » Needs review
thehong’s picture

Pushed. Thanks.

thehong’s picture

Status: Needs review » Fixed
lalit774’s picture

#1 working fine for me. now both(Commerce Cart Ajax, commerce_extra quantity ) modules working together.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mrpauldriver’s picture

confirm that this now works for me

Exploratus’s picture

#1 works for me. Lets get this committed no? I was having issues with commerce_extra_quantity.

fox_01’s picture

Issue summary: View changes

Is that patch commited to latest dev?

fox_01’s picture

Is that patch commited to latest dev?

plazik’s picture

@fox_01, yes, it was commited to dev.

mozh92’s picture

comment in function dc_cart_ajax_form_commerce_cart_add_to_cart_form_alter

function dc_cart_ajax_form_commerce_cart_add_to_cart_form_alter(&$form, $form_state, $form_id) {
  $form['submit']['#ajax'][] = array('callback' => 'dc_cart_ajax_form_commerce_cart_add_to_cart_form_ajax_callback');
  //$form['submit']['#attached']['js'] = drupal_get_path('module', 'dc_cart_ajax') . '/misc/js/dc_cart_ajax.js';
  $form['#submit'][] = 'dc_cart_ajax_form_commerce_cart_add_to_cart_form_submit';
}

for Commerce AJAX Add to Cart
1. $form['submit']['#ajax'] => $form['submit']['#ajax'][]
2. $form['submit']['#attached']['js'] => //$form['submit']['#attached']['js']