Just noticed that if you disable javascript changing attributes on the add to cart form doesn't make a difference as it will only add the default variation to the cart no matter what.

For most people, me included, this isn't much of an issue, but it's still poor functionality to have as core functionality in Commerce in my opinion. Switching attributes should also affect the url in some way so you can link someone to a specific product variation instead of it reverting to default all the time.

What's puzzling to me is that it seems like it should work because the attributes are proper form elements that are part of the add to cart form, but for some reason the values you put in them are not taken into account when you submit the form.

Comments

twiik’s picture

Version: 7.x-1.2 » 7.x-1.3
rszrama’s picture

Title: Attribute switching doesn't work with javascript disabled » Add support for the Add to Cart form to work without JS
Version: 7.x-1.3 » 7.x-1.x-dev
Category: bug » feature

Right, what's happening is the form rebuild process needs to be triggered so the form can rebuild using the currently selected options. Unfortunately, that won't affect the product used to render the fields on the page, as there's no way to communicate the current "default product" of the Add to Cart form to the field renderer on a pageload outside of the AJAX request. Adding support for non-JS users is a pretty large task, and I suppose we'll have to decide if it's even worth trying to render injected product fields to match the current product.

fwiw, this is a known lack of support, but I'll make a feature request out of it and probably take it up in the 2.x sprint next month. I think this may be a duplicate issue, can't recall.

mesch’s picture

Category: feature » bug
Priority: Normal » Major

I think what TwiiK meant is that with javascript disabled, you can only add the default product to the cart. Any selections are ignored by the validation and submit handlers. Updating the fields is a separate issue (one that might be solved via hook_entity_view, whereby you can access the $form to see the current product).

The submit handler is working with $form_state['values']['product_id'], which will be the default product the form was built with. It seems like the product_id form element is only changed if commerce_cart_add_to_cart_form_attributes_refresh() is called via AJAX.

rszrama’s picture

Category: bug » feature
Priority: Major » Normal

Please see my comment above; let's leave this categorized where it is.

Sorry, and just to make it clear, even without the fields being updated, the form itself still has to refresh for the Add to Cart to work properly.

mesch’s picture

Re: #4, yes, that's what I was trying to say in #3. Those without javascript enabled won't be able to add a non-default product to the cart. This will only affect the small subset of users who don't have javascript enabled, but ideally we want all users to be able to add any product variation they wish to the cart.

rszrama’s picture

Agreed, that's what this open feature request is for. : )

Also in need of such support is the checkout form, but I'm pretty sure we have a separate issue for that.

rich.3po’s picture

Hi - i'm also experiencing this issue. We've had a few cases where incorrect sized items are being sent out to paying customers...

Has there been any progress with this?

Thanks

mesch’s picture

Issue summary: View changes

See here for a patch that adds graceful degradation (among other things).