Describe your bug or feature request.

We have a unique case in which we allow certain orders to be checked out anonymously upon our own validation method. These orders are owned by a certain type of user. Upon our own validation, we simply add the order in question to their session via $cart_session->addCartId($cart_id). This gets the user to the next step in checkout, but they can't move forward due to the CartProvider invalidating their cart from their session because they're anonymous and aren't the order customer. The CartProvider service class isn't set up to handle service replacements or decorators very well, so I propose adding an isEligibleCart($order, $account) method to handle validating eligible carts during checkout. This allows us to simply replace the service with an extended class and override the isEligibleCart() method without replacing the loadCartData() method completely. This should keep core functionality the same, with new extendable functionality for our use case.

If a bug, provide steps to reproduce it from a clean install.

Create an order with a non-anonymous customer.
Using custom code, Aad the order to an anonymous user's cart session via the CartSession service. This allows the user to checkout regardless their authentication status when verified.

Try to check out. Cart query access fetched cart IDs from cart provider and marks the cart ineligible, causing access denied on next checkout step or AJAX requests

Issue fork commerce-3240728

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

alexandersluiter created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review

Queued 7.4 test, I bet the failure is a linting issue

mglaman’s picture

Issue summary: View changes
jsacksick’s picture

Looks good to me, I have no problem with easing up decorating the cart provider.

jsacksick’s picture

Status: Needs review » Reviewed & tested by the community

jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Updated the comments and committed the patch, thanks!

mglaman’s picture

Woo! Thanks @jsacksick!

alexandersluiter’s picture

Thank you @jsacksick! This helps us a ton with our checkout flows and backoffice application.

Status: Fixed » Closed (fixed)

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