2

I'm currently building an e-commerce website using Drupal 7 and Drupal Commerce (not kickstart). I've built my product display page, and added an attribute to the product called "size" where the customer can pick the size before they add it to their cart.

I'm looking to recreate the functionality seen on this page: http://demo.commerceguys.com/ck/storage-devices/commerce-guys-usb-key

Where by when you select a different option, an AJAX call is made and the price updates.

Looking at the HTML generated on my page, it looks like it's half-way there as the select has the 'ajax-processed' class on it, but when the select option changes, nothing is called and no errors appear in the browser JS console. Debugging the field shows that the AJAX callback is in place:

array(5) {
  ["#type"]=>
  string(6) "select"
  ["#options"]=>
  array(2) {
    [4]=>
    string(22) "Small Bag (5KG)"
    [3]=>
    string(24) "Big Bag (7.5KG)"
  }
  ["#default_value"]=>
  string(1) "4"
  ["#weight"]=>
  int(0)
  ["#ajax"]=>
  array(1) {
    ["callback"]=>
    string(49) "commerce_cart_add_to_cart_form_attributes_refresh"
  }
}

Any suggestions as to what might be causing this not to be called?

  • Have you loaded all the variations on the backend for the sizes? – Brady Dec 12 '14 at 15:48
  • The sizes field is a product reference field on the product display. – Dave Dec 12 '14 at 15:58
  • Correct, but have you loaded products of the different variations with different SKUs and referenced all the variation SKUs in the Node display for the products? Is this site public? – Brady Dec 14 '14 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.