admin管理员组文章数量:1313782
I want to code a module that if Items get deleted from the cart they still stay in there, and you have the option to bring them back. I decorated the delete rout to the following:
public function remove(Request $request, Cart $cart, SalesChannelContext $context): CartResponse
{
$newids = [];
$ids = $request->get('ids');
foreach ($ids as $id) {
$lineItem = $cart->get($id);
if ($lineItem->getType() !== 'product') {
$newids[] = $id;
} else {
$lineItem->setType('offCart');
$cart->markModified();
}
}
$request->attributes->set('ids', $newids);
$response = $this->decorated->remove($request, $cart, $context);
return $response;
}
So basically my code checks the type of the item is 'Product', then it changes the type to 'offCart'. If it is already 'offCart', it passes the id forward to the Default delete rout.
I know the cart doesn't accept the custom type of the product, because if I keep the type and append a custom variable to the payload the Item doesn't get kicked from the cart and even keeps the payload.
So now I want to add a custom type which is just like an Product but with a different name. I have tried looking at the documentation but couldn't find anything even with their "AI" helper.
Can someone tell me how to add custom types?
本文标签: phpShopware accept custom types in cartStack Overflow
版权声明:本文标题:php - Shopware accept custom types in cart - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741955562a2406969.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论