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.

Comments

kiwimind created an issue. See original summary.

drugan’s picture

I've tried your demo on the simplytest.me and wonder what was the reason to remove everything and start from the scratch?

kiwimind’s picture

There'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.

drugan’s picture

OK, please let us to know when and with which method you'd fix your issue.

kiwimind’s picture

@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...

drugan’s picture

@kiwimind

Could you please give a step by step verbose instruction to reproduce the issue.

czigor’s picture

Status: Active » Needs review
StatusFileSize
new659 bytes

The issue is that new order types are incorrectly created with an order items reference field referencing "Order types", not "Order items".

Patch attached.

czigor’s picture

Priority: Normal » Major
czigor’s picture

StatusFileSize
new1.53 KB
new2.17 KB

A 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.

The last submitted patch, 9: commerce-2923656-custom_order_type-9-FAIL.patch, failed testing. View results

kiwimind’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @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...

opdavies’s picture

I've reviewed the patch, and I'm happy to RTBC +1.

utement’s picture

Tested, work as expected after patch is applied.

  • bojanz committed 5be879d on 8.x-2.x authored by czigor
    Issue #2923656 by czigor, kiwimind, opdavies, utement: Unable to use...
bojanz’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.