Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am currently working on an order form which allows editing order items like a SaaS landing page. There are created order items which can be customized using the purchased entity widgets. The problem, however, is that our widgets do not respect if the order item already has an existing field value.
Comment | File | Size | Author |
---|---|---|---|
#8 | attribute_widget_should-2888231-8.patch | 2.42 KB | mglaman |
| |||
#2 | attribute_widget_should-2888231-2.patch | 1.36 KB | mglaman |
Comments
Comment #2
mglamanThis allows me to embed the order item content entity form, re-use our widgets and allow customization on our custom cart form page.
Comment #3
agoradesign CreditAttribution: agoradesign commentedI'm lacking the context, only read the patch file, but: why is there an order item inside commerce_product module? Is this safe to use without commerce_order?
Comment #4
mglamanBecause this widget only works for the commerce_order_item purchased_entity field. It's the product specific add to cart form widget. Since the add to cart form is supposed to be usable with any purchased entity type.
See
The intent is we know this widget will only be on the create/edit form of an order item. Right now we just assume it's always "create" and never "edit".
Comment #5
agoradesign CreditAttribution: agoradesign commentedok, that makes sense :)
Comment #6
mglamanOpened a PR https://github.com/drupalcommerce/commerce/pull/750
Comment #7
bojanz CreditAttribution: bojanz at Centarro commentedApproach makes sense. Build didn't pass. Asked Matt for a rebase, to check against latest tests.
Comment #8
mglamanFixed patch. It was due to the fact the order item always has a value for the purchased entity. Now the widget checks if the entity is new or not. If it is a new entity, load from context. Otherwise from value.
Comment #10
mglamanCommitted!