Esempio n. 1
0
 /**
  * Delete quote item. If it does not have identifier then it will be only removed from collection
  *
  * @param   \Magento\Sales\Model\Quote\Item $item
  * @return $this
  */
 public function deleteItem(\Magento\Sales\Model\Quote\Item $item)
 {
     if ($item->getId()) {
         $this->removeItem($item->getId());
     } else {
         $quoteItems = $this->getItemsCollection();
         $items = array($item);
         if ($item->getHasChildren()) {
             foreach ($item->getChildren() as $child) {
                 $items[] = $child;
             }
         }
         foreach ($quoteItems as $key => $quoteItem) {
             foreach ($items as $item) {
                 if ($quoteItem->compare($item)) {
                     $quoteItems->removeItemByKey($key);
                 }
             }
         }
     }
     return $this;
 }