-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
POST /cart with jwt create 2 order records #393
Comments
In my test, I totally missed the checkout process! I forgot to tell I am also a newbie on e-commerce standards! However, is it normal I got 2 order records after a POST request on |
Normally an order only exists without a customer. Only when completing the checkout the cart gets assigned to a customer by their email or if they are logged in by the logged in customer's email. |
See my test on commit TheRealCodeKraft/ShopApiPlugin@7a74f95 and corresponding failing build https://travis-ci.org/TheRealCodeKraft/ShopApiPlugin/jobs/492914339. $this->loadFixturesFromFiles(['shop.yml', 'customer.yml']);
$this->logInUser('oliver@queen.com', '123password');
$this->client->request('POST', '/shop-api/WEB_GB/carts', [], [], static::$acceptAndContentTypeHeader);
$response = $this->client->getResponse();
$orderRepository = $this->get('sylius.repository.order');
$count = $orderRepository->count([]);
$this->assertSame(1, $count, 'Only one cart should be created'); |
Thanks for reporting. You have used the wrong endpoint for orders list, as you should use cart endpoints, instead of order. The order is the cart that has been already placed. Nevertheless, there should be only one cart in the database, but it will require further investigation. |
So after some debugging I found that the |
It just struck me like a lightning. It's the |
This PR was merged into the 1.0-dev branch. Discussion ---------- This fixes #393 In this pull request I introduced a new Request and Command object for picking up a cart of a customer that is logged in. This way I registered a new handler. The `PickupLoggedInCart` Command and Request object inherit from the "non logged in"-version. Commits ------- 433ec63 Fix for the duplicate cart ab94312 Codestyle 42ae068 Refactored it 164b3d2 Reverted to simpler fix
I try to understand how to use API, especially with cart and order process. I am a newbie on Sylius and ShopApiPlugin.
With
"sylius/shop-api-plugin": "dev-master"
and"sylius/sylius": "~1.4.0"
, I got a failing test with following code:Observing what happened in database, I got 2 order records:
Maybe I misused ShopApiPlugin but it is not clear for me how I create a cart and associate it with logged user.
Thank you for your help.
The text was updated successfully, but these errors were encountered: