I've just tested with a new installation of commerce on simplytest.me and have found an issue that I can't find in the issue queue and wondered if anyone else has a) come up against it and b) figured out how to get it working...
If you remove all product variation types, product types, order item types and order types and replace them with new entries, the following error occurs when you try and view your cart having added a product to it:
Exception: No entity type for field purchased_entity on view commerce_cart_form in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 711 of core/modules/views/src/Plugin/views/HandlerBase.php).
The success message does show successfully when adding the item to the cart.
With the commerce given defaults, there's no issue, but as soon as they're replaced with user added elements, it breaks.
Alongside this, the order does show in the admin area (admin/commerce/orders/carts), but is unable to be edited due to another error:
LogicException: Getting the base fields is not supported for entity type Order type. in Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() (line 199 of core/lib/Drupal/Core/Entity/EntityFieldManager.php).
I'm hoping that it's something straightforward that I've missed, but so far I've been unable to find it.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | commerce-2923656-custom_order_type-9.patch | 2.17 KB | czigor |
| #9 | commerce-2923656-custom_order_type-9-FAIL.patch | 1.53 KB | czigor |
Comments
Comment #2
drugan commentedI've tried your demo on the simplytest.me and wonder what was the reason to remove everything and start from the scratch?
Comment #3
kiwimind commentedThere's no reason per se, but it was done on a build that we're working on, which is now causing it to fail hard in places.
If the functionality is there to be able to do so, then it should be supported, hence a bug.
We are likely to need to add another product type too, so don't know which part of this alteration are causing things to fail.
Comment #4
drugan commentedOK, please let us to know when and with which method you'd fix your issue.
Comment #5
kiwimind commented@drugan, this is a request for help as I don't know which way to go with this next. Seems like a commerce core bug to me...
Comment #6
drugan commented@kiwimind
Could you please give a step by step verbose instruction to reproduce the issue.
Comment #7
czigor commentedThe issue is that new order types are incorrectly created with an order items reference field referencing "Order types", not "Order items".
Patch attached.
Comment #8
czigor commentedComment #9
czigor commentedA patch with a failing test + a patch with the fix and the test.
Note that you need to remove all order types first to reproduce the problem, otherwise the order_items field's target_type will be correctly commerce_order_item.
Comment #11
kiwimind commentedThanks @czigor,
I've now tested this by setting up a new instance on simplytest.me and applying your patch, then running through the steps detailed in the original ticket.
I'm very happy to say that the issues that were apparent have now gone and the cart is able to be accessed by a user, as well as by an administrator via the Orders > Cart page.
Code looks good and functionally I'm happy to RTBC. Don't know if this needs anything further from anyone else...
Comment #12
opdaviesI've reviewed the patch, and I'm happy to RTBC +1.
Comment #13
utement commentedTested, work as expected after patch is applied.
Comment #15
bojanz commentedThanks, everyone!