Issue when editing order in Shopware admin panel when adding custom discount
P粉811349112
P粉811349112 2023-09-01 17:30:17
0
1
704
<p>I wrote a custom shopping cart discount according to the documentation https://developer.shopware.com/docs/guides/plugins/plugins/checkout/cart/add-cart-discounts Everything works fine, when the customer adds or removes a product from the cart, the discount is recalculated, but when I want to edit this order in the admin panel, I get the error: </p> <blockquote> <p> Uncaught PHP exception Shopware\Core\Checkout\Cart\Exception\LineItemNotStackableException: "The line item with identifier 'CHEAPEST_ITEM_CART_DISCOUNT' is not stackable and the quantity cannot be changed." in /var/www/shop/vendor/ shopware/core/Checkout/Cart/LineItem/LineItem.php line 233 {"Exception": "[Object](Shopware\Core\Checkout\Cart\Exception LineItemNotStackableException (Code: 0): The line item with identifier "CHEAPEST_ITEM_CART_DISCOUNT" is not stackable and the quantity cannot be changed. at /var/www/shop/vendor/shopware/core/Checkout/Cart/LineItem/LineItem.php:233)"} []</p> </blockquote> <p>I "solved" this problem by adding this check to my code: </p> <pre class="brush:php;toolbar:false;">if($behavior->hasPermission(self::SKIP_PROMOTION)){ $items = $original->getLineItems()->filterType(self::LINE_ITEM_TYPE); foreach ($items as $item) { $toCalculate->add($item); } return; }</pre> <p>Now, if I edit the order in the admin panel, the error does not show up, but the discount is not calculated again, and toggling "Disable automatic promotions" does not work. </p> <p>Is there any solution to recalculate custom discounts sequentially on edit operations? When I add a new order in the admin panel everything works fine, the problem is only with editing. The documentation doesn't say anything about this. </p>
P粉811349112
P粉811349112

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!