Instead of calling \Drupal\uc_cart\Controller\Cart::create(\Drupal::getContainer()); we should be able to use something like \Drupal::service('uc_cart.manager')->getCart() to return an object that represents the cart for the current user. We are part way there with the Cart controller object but none of the methods should take a cart ID as a parameter. Unsure whether these can be a true entity object/manager because of the special way we handle cart IDs for anonymous and registered users, but that would be a good end goal.

Comments

longwave created an issue. See original summary.

tr’s picture

Yes, that was my intent, just never finished that. Hence the awkward construction. The API for the cart service deserves a bit of thought - the set of functions we have now is incomplete and inadequate.

longwave’s picture

Status: Active » Needs review
StatusFileSize
new49.85 KB

First pass at this. Some tests will probably fail and there is more cleanup that can be done, such as removing the $msg parameter from Cart::addItem(). Also unsure if CartManager::completeSale() really belongs there, or if this should be moved to the Order system.

Status: Needs review » Needs work

The last submitted patch, 3: cart-manager.patch, failed testing.

The last submitted patch, 3: cart-manager.patch, failed testing.

The last submitted patch, 3: cart-manager.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new52.75 KB

Status: Needs review » Needs work

The last submitted patch, 7: cart-manager.patch, failed testing.

The last submitted patch, 7: cart-manager.patch, failed testing.

The last submitted patch, 7: cart-manager.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new52.79 KB

Status: Needs review » Needs work

The last submitted patch, 11: cart-manager.patch, failed testing.

The last submitted patch, 11: cart-manager.patch, failed testing.

The last submitted patch, 11: cart-manager.patch, failed testing.

longwave’s picture

Component: Code » Cart/checkout
Status: Needs work » Needs review
StatusFileSize
new54.43 KB

Status: Needs review » Needs work

The last submitted patch, 15: cart-manager-15.patch, failed testing.

The last submitted patch, 15: cart-manager-15.patch, failed testing.

The last submitted patch, 15: cart-manager-15.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review

@TR: any comments on this would be appreciated!

Status: Needs review » Needs work

The last submitted patch, 15: cart-manager-15.patch, failed testing.

The last submitted patch, 15: cart-manager-15.patch, failed testing.

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new54.47 KB
longwave’s picture

Status: Needs review » Fixed

  • longwave committed 9e76320 on 8.x-4.x
    Issue #2573109 by longwave: Split Cart controller into CartManager...

Status: Fixed » Closed (fixed)

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