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