Hi everyone,
I’m currently working on a custom plugin for Shopware, and I’ve run into an issue regarding promotions in the cart. Here’s the situation:
When I add a product to the cart programmatically (using custom logic in my plugin: ), the product does not trigger any active promotions. However, if I then add a product to the cart using the standard Shopware process, the promotion starts to apply — not only to the newly added product but also to the product that was initially added via my custom method.
This suggests that my custom-added product is missing something essential for the promotion to work right away.
It’s worth mentioning that there are no errors during the process — neither when adding the product to the cart via my custom logic nor when setting up or applying the promotions themselves.
Has anyone encountered a similar issue? Are there any specific services, events, or methods that I might need to call to ensure that promotions are applied properly to custom-added products?
I’d appreciate any insights or suggestions on how to resolve this. Thanks in advance!
Here is code with my custom logic:
$lineItem = $this->factory->create([
'type' => LineItem::PRODUCT_LINE_ITEM_TYPE,
'referencedId' => $variationId,
'quantity' => 1,
'payload' => [
'customPayload' => 'myCustomPayload',
'index' => $index,
],
], $context);
$lineItem->setStackable(false);
$this->cartService->add($cart, $lineItem, $context);
Best regards,