Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QuotePlugin.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Quote\Model\Quote\ProductOptionFactory;
11 
19 {
23  private $productOptionFactory;
24 
28  public function __construct(
29  ProductOptionFactory $productOptionFactory
30  ) {
31  $this->productOptionFactory = $productOptionFactory;
32  }
33 
43  public function beforeSave(SaveHandler $subject, CartInterface $quote)
44  {
45  if (!$quote->getIsActive()) {
46  $items = $quote->getItems();
47 
48  if ($items) {
49  foreach ($items as $item) {
51  if (!$item->isDeleted()) {
52  $item->setProductOption($this->productOptionFactory->create());
53  }
54  }
55  }
56  }
57 
58  return [$quote];
59  }
60 }
__construct(ProductOptionFactory $productOptionFactory)
Definition: QuotePlugin.php:28
$quote
$items