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
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
Comment #3
mglamanQueued 7.4 test, I bet the failure is a linting issue
Comment #4
mglamanComment #5
jsacksick commentedLooks good to me, I have no problem with easing up decorating the cart provider.
Comment #6
jsacksick commentedComment #8
jsacksick commentedUpdated the comments and committed the patch, thanks!
Comment #9
mglamanWoo! Thanks @jsacksick!
Comment #10
alexandersluiter commentedThank you @jsacksick! This helps us a ton with our checkout flows and backoffice application.