- ๐บ๐ธUnited States Dave Kopecek
Dave Kopecek โ made their first commit to this issueโs fork.
- ๐ฎ๐ฑIsrael jsacksick
This is necessary when selling custom product with a refresh price
Can you elaborate? "selected_variation" isn't set in this case because that is used by the ajax refresh callback, but there are no attributes elements in case of a single variation?
- ๐บ๐ธUnited States Dave Kopecek
>> Can you elaborate? "selected_variation" isn't set in this case
In my use case we have a custom my_module_form_commerce_order_item_add_to_cart_form(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id that has:
$vid = $form_state->get('selected_variation'); $variation = \Drupal\commerce_product\Entity\ProductVariation::load($vid);
This broke when a new product with only a single variation was created. Is there a better way to get the current variation from the passed parameters?
- ๐ฎ๐ฑIsrael jsacksick
I guess we can consider your fix but in the meantime you could just have a condition that checks if
$form_state->has('selected_variation');
otherwise you can fallback to the first variation referenced from the product. - Status changed to Needs review
6 months ago 8:44am 18 June 2024 - last update
6 months ago 795 pass -
jsacksick โ
committed 94d3a20f on 8.x-2.x
Issue #3282644 by Dave Kopecek, jsacksick: selected_variation also need...
-
jsacksick โ
committed 94d3a20f on 8.x-2.x
-
jsacksick โ
committed cdf4b0b0 on 3.0.x
Issue #3282644 by Dave Kopecek, jsacksick: selected_variation also need...
-
jsacksick โ
committed cdf4b0b0 on 3.0.x
- Status changed to Fixed
5 months ago 2:09pm 11 July 2024 Automatically closed - issue fixed for 2 weeks with no activity.