Returns an array of resulting data after a product has been deleted from a cart
@param array $cart
@return array
978471
protected function getResultDelete(array $cart)
    {
        $options = array(
            'user_id' => $cart['user_id'],
            'store_id' => $cart['store_id'],
        );

        $content = $this->cart->getContent($options);

        return array(
            'redirect' => '',
            'severity' => 'success',
            'quantity' => empty($content['quantity']) ? 0 : $content['quantity'],
            'message' => $this->translation->text('Product has been deleted from cart')
        );
    }
1011761
public function getLineItemsByDiscount(PromotionDiscountEntity $discount, Cart $cart, SalesChannelContext $context): array
    {
        /** @var array $nonPromotionLineItemsKeys */
        $nonPromotionLineItemsKeys = $this->getNonPromotionLineItemsKeys($cart);

        if (count($nonPromotionLineItemsKeys) === 0) {
            return [];
        }

        if (!$discount->isConsiderAdvancedRules()) {
            return $nonPromotionLineItemsKeys;
        }

        /** @var RuleCollection|null $discountRuleCollection */
        $discountRuleCollection = $discount->getDiscountRules();

        // discount has no rules, therefore all lineItems match discount
        if (!$discountRuleCollection instanceof RuleCollection) {
            return $nonPromotionLineItemsKeys;
        }

        /** @var array $lineItems */
        $lineItems = $this->getNonPromotionLineItems($cart);

        $matchingLineItems = [];

        // get all lineItems where rule is matching without respecting any advanced rule
        /** @var LineItem $lineItem */
        foreach ($lineItems as $lineItem) {
            $itemScope = new LineItemScope($lineItem, $context);
            if ($this->doesRuleCollectionMatchsLineItem($discountRuleCollection, $itemScope)) {
                $matchingLineItems[$lineItem->getKey()] = $lineItem;
            }
        }

        return $matchingLineItems;
    }
741878
protected function addToWishlist(array $cart)
    {
        $data = array(
            'user_id' => $cart['user_id'],
            'store_id' => $cart['store_id'],
            'product_id' => $cart['product_id']
        );

        return $this->wishlist_action->add($data);
    }
63994
private function isTransactionUpdated(Cart $cart)
    {
        if (false === $this->session->has('transaction-id')) {
            return false;
        }

        /** @var TransactionRepository $transactionRepository */
        $transactionRepository = $this->manager->getRepository('EcommerceBundle:Transaction');

        /** @var Order $order */
        $transaction = $transactionRepository->find($this->session->get('transaction-id'));

        /** @var ArrayCollection $cartItems */
        $cartItems = $cart->getItems();
        /** @var ArrayCollection $orderItems */
        $productPurchases = $transaction->getItems();

        if ($cartItems->count() !== $productPurchases->count()) {
            return false;
        }

        for ($i=0; $i<$cartItems->count(); $i++) {
            /** @var CartItem $cartItem */
            $cartItem = $cartItems[$i];
            /** @var OrderItem $orderItem */
            $productPurchase = $productPurchases[$i];

            if ($cartItem->getProduct()->getId() !== $productPurchase->getProduct()->getId() ||
                $cartItem->getQuantity() !== $productPurchase->getQuantity()) {
                return false;
            }
        }

        return true;
    }
1368882
public function getItemData($name): array
    {
        if (func_num_args() > 1)
            $name = func_get_args();

        if (!$this->hasItemData($name))
            return $this->getItemDataNotFound($name);

        return $this->getData()[$this->getItemKey($name)];
    }
1364380
protected function getDefaultData()
    {
        $data = array();

        $data['_uid'] = $this->uid;
        $data['_uri'] = $this->uri;
        $data['_path'] = $this->path;
        $data['_base'] = $this->base;
        $data['_host'] = $this->host;
        $data['_token'] = $this->token;
        $data['_query'] = $this->query;
        $data['_scheme'] = $this->scheme;
        $data['_cart_uid'] = $this->cart_uid;
        $data['_is_front'] = $this->isFront();
        $data['_is_logged_in'] = !empty($this->uid);
        $data['_is_admin'] = $this->access('admin');
        $data['_is_superadmin'] = $this->isSuperadmin();
        $data['_langcode'] = empty($this->langcode) ? 'en' : $this->langcode;
        $data['_url'] = $this->scheme . $this->host . $this->base . $this->path;

        return $data;
    }
445064
public function emptycart()
    {
        $this->extend("onBeforeEmpty");
        $this->removeAll();
        $this->save();
                
        $this->setSessionMessage(
            "bad",
            _t("Checkout.EmptiedCart", "Shopping cart emptied")
        );

        return $this->redirectBack();
    }
1168613
private function getCodesFromPlaceholdersIds(Cart $cart, array $lineItemIDs): array
    {
        $codes = [];

        /** @var array $promotionLineItems */
        $promotionLineItems = $this->getPromotionLineItems($cart);

        /** @var LineItem $lineItem */
        foreach ($promotionLineItems as $lineItem) {
            // if our line item is in our list of Ids and
            // if it is a placeholder item, then collect that code.
            if (!in_array($lineItem->getKey(), $lineItemIDs, true)) {
                continue;
            }

            // grab our code from the payload
            // just verify if it really exists to avoid exceptions
            if (array_key_exists('code', $lineItem->getPayload())) {
                $codes[] = $lineItem->getPayload()['code'];
            }
        }

        return $codes;
    }
482299
protected function getCart()
    {
        if (null === $this->cart) {
            $this->cart = $this->getSession() ? $this->getSession()->getSessionCart($this->dispatcher) : null;
        }

        return $this->cart;
    }
108514
private function cleanupCartsArray(&$cartsArray)
    {
        if ($cartsArray && count($cartsArray) > 0) {
            // handle cartsArray count is > 1
            foreach ($cartsArray as $index => $cart) {
                // delete expired carts
                if ($cart->getChanged()->getTimestamp() < strtotime(static::EXPIRY_MONTHS . ' months ago')) {
//                    $this->em->remove($cart);
                    continue;
                }

                // dont delete first element, since this is the current cart
                if ($index === 0) {
                    continue;
                }
                // remove duplicated carts
//                $this->em->remove($cart);
            }
        }
    }
882550
public function getData($order = self::SORT_DESC)
    {
        return array(
            'items' => array_map(
                function (Item $item) {
                    /*
                     * @var Item $item
                     */
                    return $item->toArray();
                },
                array_values($this->getItems($order))
            ),
        );
    }
1175196
public function allWithRemoved(): array
    {
        $items = $this->all();

        foreach ($this->removedItems as $deleted) {
            Arr::set($items, $deleted, null);
        }

        return $items;
    }
577380
function getExtraFields (cartoError) {
  var errorlist = _getErrorList(cartoError);
  var listedError = _getListedError(cartoError, errorlist);

  return {
    friendlyMessage: listedError.friendlyMessage,
    errorCode: listedError.errorCode
  };
}
838371
function getDeletedEmbedIDArray( $includeTrash = false )
    {
        $arr = array();
        if ( $this->deletedEmbeddedNodeIDArray )
            $arr['nodes'] = $this->deletedEmbeddedNodeIDArray;
        if ( $this->deletedEmbeddedObjectIDArray )
            $arr['objects'] = $this->deletedEmbeddedObjectIDArray;
        if ( $includeTrash && $this->thrashedEmbeddedObjectIDArray )
            $arr['trash'] = $this->thrashedEmbeddedObjectIDArray;
        return $arr;
    }
1352047
public function getItems()
    {
        $items = [];
        if (isset($this->cart->items) === true) {
            foreach ($this->cart->items as $item) {
                $items[$item->getHash()] = $item;
            }
        }

        return $items;
    }
264175
public function delete(array $data)
    {
        $result = array();
        $this->hook->attach('wishlist.delete.product.before', $data, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        if (!$this->wishlist->delete($data)) {
            return $this->getResultError();
        }

        $result = $this->getResultDelete($data);
        $this->hook->attach('wishlist.delete.product.after', $data, $result, $this);
        return (array) $result;
    }
58587
protected function isValidCart(Cart $cart)
    {
        $customer = $this->getCustomerUser();

        return (null !== $customer && $cart->getCustomerId() == $customer->getId())
            ||
        (null === $customer && $cart->getCustomerId() === null);
    }