What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi guys, first: Happy new year to everybody! I have an issue with quest carts in my development en

UKHUU3NE9
UKHUU3NE9 Posts: 17 🧑🏻‍🚀 - Cadet

Hi guys,

first: Happy new year to everybody!

I have an issue with quest carts in my development environment (202108.0) and I am not sure if it is a B2B related issue. In the beginning I can not get a cart / a cart id by the "GET /guest-carts" request in both environments. After that I can only add a product to the B2C guest cart, the corresponding B2B request returns a "Missing access token" error. I looked into the obvious ResourceRoutePlugin, but the guest-carts and the guest-cart-items resources are included as not protected in both environments (B2C and B2B).

Does anyone have a clue where Spryker (intentionally?) "disables" the guest cart in B2B ? I think it is a "feature" of the B2B environment (no add to cart in YVES either), but normally the guest cart should be re-activateable ( I hope :)

Example:

B2C - OK:

$ curl -X GET "http://glue.de.spryker.local/guest-carts/?include=guest-cart-items" -H "accept: application/json" -H "X-Anonymous-Customer-Unique-Id: 164b-5708-8531"

{"data":[],"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts?include=guest-cart-items"}}

$ curl -X POST "http://glue.de.spryker.local/guest-cart-items" -H "accept: application/json" -H "X-Anonymous-Customer-Unique-Id: 164b-5708-8531" -H "Content-Type: application/json" -d "{\"data\":{\"type\":\"guest-cart-items\",\"attributes\":{\"sku\":\"055_29406184\",\"quantity\":1}}}"

{"data":{"type":"guest-carts","id":"c70df0e4-78e7-5b0a-a390-1a94e5752923","attributes":{"priceMode":"GROSS_MODE","currency":"EUR","store":"DE","totals":{"expenseTotal":0,"discountTotal":1914,"taxTotal":2750,"subtotal":19137,"grandTotal":17223,"priceToPay":17223},"discounts":[{"displayName":"10% Discount for all orders above","amount":1914,"code":null}]},"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts\/c70df0e4-78e7-5b0a-a390-1a94e5752923"}}}

$ curl -X GET "http://glue.de.spryker.local/guest-carts/?include=guest-cart-items" -H "accept: application/json" -H "X-Anonymous-Customer-Unique-Id: 164b-5708-8531"

{"data":[{"type":"guest-carts","id":"c70df0e4-78e7-5b0a-a390-1a94e5752923","attributes":{"priceMode":"GROSS_MODE","currency":"EUR","store":"DE","totals":{"expenseTotal":0,"discountTotal":1914,"taxTotal":2750,"subtotal":19137,"grandTotal":17223,"priceToPay":17223},"discounts":[{"displayName":"10% Discount for all orders above","amount":1914,"code":null}]},"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts\/c70df0e4-78e7-5b0a-a390-1a94e5752923?include=guest-cart-items"},"relationships":{"guest-cart-items":{"data":[{"type":"guest-cart-items","id":"055_29406184"}]}}}],"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts?include=guest-cart-items"},"included":[{"type":"guest-cart-items","id":"055_29406184","attributes":{"sku":"055_29406184","quantity":1,"groupKey":"055_29406184","abstractSku":"055","amount":null,"calculations":{"unitPrice":19137,"sumPrice":19137,"taxRate":19,"unitNetPrice":0,"sumNetPrice":0,"unitGrossPrice":19137,"sumGrossPrice":19137,"unitTaxAmountFullAggregation":2750,"sumTaxAmountFullAggregation":2750,"sumSubtotalAggregation":19137,"unitSubtotalAggregation":19137,"unitProductOptionPriceAggregation":0,"sumProductOptionPriceAggregation":0,"unitDiscountAmountAggregation":1914,"sumDiscountAmountAggregation":1914,"unitDiscountAmountFullAggregation":1914,"sumDiscountAmountFullAggregation":1914,"unitPriceToPayAggregation":17223,"sumPriceToPayAggregation":17223},"selectedProductOptions":[]},"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts\/c70df0e4-78e7-5b0a-a390-1a94e5752923\/guest-cart-items\/055_29406184"}}]}

B2B - NOT OK:

$ curl -X GET "http://glue.de.spryker.local/guest-carts/" -H "accept: application/json" -H "X-Anonymous-Customer-Unique-Id: 164b-5708-8531"

{"data":[],"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts"}}

$ curl -X POST "http://glue.de.spryker.local/guest-cart-items" -H "accept: application/json" -H "X-Anonymous-Customer-Unique-Id: 164b-5708-8531" -H "Content-Type: application/json" -d "{\"data\":{\"type\":\"guest-cart-items\",\"attributes\":{\"sku\":\"M24637\",\"quantity\":1}}}"

{"errors":[{"detail":"Missing access token.","status":403,"code":"002"}]}

$ curl -X GET "http://glue.de.spryker.local/guest-carts/" -H "accept: application/json" -H "X-Anonymous-Customer-Unique-Id: 164b-5708-8531"

{"data":[],"links":{"self":"http:\/\/glue.de.spryker.local\/guest-carts"}}

Comments

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    B2B demo shop doesn't have guest checkout in general.

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice
    edited January 2022

    And it's kind of problematic to turn it back on. At least I tried once myself and wasn't able. There is no documentation about this as it's disabled intentionally.

  • UKHUU3NE9
    UKHUU3NE9 Posts: 17 🧑🏻‍🚀 - Cadet

    Ok, but then it would be better if the resource route plugins for the guest cart endpoints weren't included in the Pyz GlueApplicationDependencyProvider (b2b and b2c have different repos). Furthermore this should be noted in the documentation, I think. I have collegues which implement a client app connecting to Spryker and they ran into this issue using the documentation: https://docs.spryker.com/docs/scos/dev/glue-api-guides/202108.0/managing-carts/guest-carts/managing-guest-carts.html

  • UKHUU3NE9
    UKHUU3NE9 Posts: 17 🧑🏻‍🚀 - Cadet

    Additionally this raises the question in me: Is it possible to handle the B2C use-case together with B2B in a single Spryker installation / environment or is this not recommended?

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    It's possible using spryker-shop/suite which has all the features without splitting them to b2b\b2c.

    The feedback regarding endpoints and the documentation is fully valid, thank you, I'll forward it internally to respective product owners so they will take care about both topics in future.