- ๐บ๐ธ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
10 days ago 8:44am 18 June 2024 - last update
10 days ago 795 pass