You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a product is added to a cart via API (POST /api/v2/shop/orders/[TOKEN]/items) a new gift card with the value of that product is created, even if the product added is not a gift card.
This also creates follow up issues when an item already existing in a cart is added again. (A new entity was found through the relationship...)
Details
I see that the api platform data persister dispatches a message event with the Message of type Setono\SyliusGiftCardPlugin\Api\Command\AddItemToCart. This message then gets picked up by the plugins AddItemToCartHandler. This handler does not check if the item/product added is a gift card. It only checks if the passed message is of type Setono\SyliusGiftCardPlugin\Api\Command\AddItemToCart, which it always will be, since that is the "input" that is has to be changed in the Order api resource configuration during plugin installation.
API resource config deviation
I find it important to add that, in the installation instructions for the API, the "shop_add_item" operation of the Order has the method "PATCH", while in the Sylius api bundle it's actually configured with method "POST".
I will be working on these issues in the upcoming weeks. The first PR I did today where I dropped support for PHP 7.4 and PHP 8.0 to make it easier for me.
Plugin version
0.12.0-alpha.5
Sylius version
1.12.10
What happened?
When a product is added to a cart via API (POST /api/v2/shop/orders/[TOKEN]/items) a new gift card with the value of that product is created, even if the product added is not a gift card.
This also creates follow up issues when an item already existing in a cart is added again. (A new entity was found through the relationship...)
Details
I see that the api platform data persister dispatches a message event with the Message of type
Setono\SyliusGiftCardPlugin\Api\Command\AddItemToCart
. This message then gets picked up by the pluginsAddItemToCartHandler
. This handler does not check if the item/product added is a gift card. It only checks if the passed message is of typeSetono\SyliusGiftCardPlugin\Api\Command\AddItemToCart
, which it always will be, since that is the "input" that is has to be changed in the Order api resource configuration during plugin installation.API resource config deviation
I find it important to add that, in the installation instructions for the API, the "shop_add_item" operation of the Order has the method "PATCH", while in the Sylius api bundle it's actually configured with method "POST".
Relevant log output
The text was updated successfully, but these errors were encountered: