- Issue created by @eiriksm
- 🇮🇱Israel jsacksick
I think it is
form_commerce_order_item_add_to_cart_form_commerce_product_VARIATION_2_alter
no? ("commerce_product_variation" and not "commerce_product").Judging by this code:
if ($purchased_entity = $order_item->getPurchasedEntity()) { $this->formId .= '_' . $purchased_entity->getEntityTypeId() . '_' . $purchased_entity->id(); }
In any case, I think the way to opt out for this should probably be via a setting (e.g: Settings::get('commerce_cart_extended_form_id', TRUE)).
This isn't really a setting that belong to a UI IMO as this setting would be primarily used by developers... Ofc the alternative approach is to just swap the add to cart form class and override the gerFormId() class. - 🇳🇴Norway eiriksm Norway
Those IDs are probably correct, yes. The actual changes I had locally were changed for the core issue, so I winged it ;p
Yes, such a setting was exactly what I had in mind actually. I will post a MR once the queuing of Drupals gitlab catches up, there are some slowness happening today apparently.
- 🇳🇴Norway eiriksm Norway
Actually it's this piece of code, so not actually variations:
// The default form ID is based on the variation ID, but in this case the // product ID is more reliable (the default variation might change between // requests due to an availability change, for example). $form_object->setFormId($form_object->getBaseFormId() . '_commerce_product_' . $product_id);
In product ProductLazyBuilders
- Status changed to Needs review
2 months ago 11:59am 15 April 2024 - 🇳🇴Norway eiriksm Norway
drupal gitlab is slow today, but I did create a MR and I expect it to show here at some point, so the status is now needs review
- last update
2 months ago 793 pass - last update
2 months ago 793 pass - 🇮🇱Israel jsacksick
Wondering if we shouldn't use a name for the setting that is a little bit more specific? What if other forms are defined in the future? Just not sure how to make it too wordy....
commerce_cart_add_to_cart_extended_form_id is a bit too longh...
Maybe commerce_add_to_cart_extended_form_id? Though here we'd drop the commerce_cart prefix.