Model/AbandonedCart/CartInsight/Data.php
private function getPayload($quote, $store)
    {
        $data = [
            'key' => $quote->getId(),
            'contactIdentifier' => $quote->getCustomerEmail(),
            'json' => [
                'cartId' => $quote->getId(),
                'cartUrl' => $this->getBasketUrl($quote->getId(), $store),
                'createdDate' => $this->dateTime->date(\Zend_Date::ISO_8601, $quote->getCreatedAt()),
                'modifiedDate' => $this->dateTime->date(\Zend_Date::ISO_8601, $quote->getUpdatedAt()),
                'currency' => $quote->getQuoteCurrencyCode(),
                'subTotal' => round($quote->getSubtotal(), 2),
                'taxAmount' => round($quote->getShippingAddress()->getTaxAmount(), 2),
                'grandTotal' => round($quote->getGrandTotal(), 2)
            ]
        ];

        $discountTotal = 0;
        $lineItems = [];

        foreach ($quote->getAllVisibleItems() as $item) {

            $discountTotal += $item->getDiscountAmount();
            $product = $this->productRepository->getById($item->getProduct()->getId(), false, $store->getId());

            $lineItems[] = [
                'sku' => $item->getSku(),
                'imageUrl' => $this->getProductImageUrl($item, $store),
                'productUrl' => $this->urlFinder->fetchFor($product),
                'name' => $item->getName(),
                'unitPrice' => round($item->getPrice(), 2),
                'quantity' => $item->getQty()
            ];
        }

        $data['json']['discountAmount'] = (float) $discountTotal;
        $data['json']['lineItems'] = $lineItems;

        return $data;
    }
private function getPayload($quote, $store)
    {
        $data = [
            'key' => $quote->getId(),
            'contactIdentifier' => $quote->getCustomerEmail(),
            'json' => [
                'cartId' => $quote->getId(),
                'cartUrl' => $this->getBasketUrl($quote->getId(), $store),
                'createdDate' => $this->dateTime->date(\Zend_Date::ISO_8601, $quote->getCreatedAt()),
                'modifiedDate' => $this->dateTime->date(\Zend_Date::ISO_8601, $quote->getUpdatedAt()),
                'currency' => $quote->getQuoteCurrencyCode(),
                'subTotal' => round($quote->getSubtotal(), 2),
                'taxAmount' => round($quote->getShippingAddress()->getTaxAmount(), 2),
                'grandTotal' => round($quote->getGrandTotal(), 2)
            ]
        ];

        $discountTotal = 0;
        $lineItems = [];

        foreach ($quote->getAllVisibleItems() as $item) {

            $discountTotal += $item->getDiscountAmount();
            $product = $this->productRepository->getById($item->getProduct()->getId(), false, $store->getId());

            $lineItems[] = [
                'sku' => $item->getSku(),
                'imageUrl' => $this->getProductImageUrl($item, $store),
                'productUrl' => $this->urlFinder->fetchFor($product),
                'name' => $item->getName(),
                'unitPrice' => round($item->getPrice(), 2),
                'quantity' => $item->getQty()
            ];
        }

        $data['json']['discountAmount'] = (float) $discountTotal;
        $data['json']['lineItems'] = $lineItems;

        return $data;
    }
private function getPayload ( $ quote , $ store ) { $ data = [ 'key' => $ quote -> getId ( ) , 'contactIdentifier' => $ quote -> getCustomerEmail ( ) , 'json' => [ 'cartId' => $ quote -> getId ( ) , 'cartUrl' => $ this -> getBasketUrl ( $ quote -> getId ( ) , $ store ) , 'createdDate' => $ this -> dateTime -> date ( \ Zend_Date :: ISO_8601 , $ quote -> getCreatedAt ( ) ) , 'modifiedDate' => $ this -> dateTime -> date ( \ Zend_Date :: ISO_8601 , $ quote -> getUpdatedAt ( ) ) , 'currency' => $ quote -> getQuoteCurrencyCode ( ) , 'subTotal' => round ( $ quote -> getSubtotal ( ) , 2 ) , 'taxAmount' => round ( $ quote -> getShippingAddress ( ) -> getTaxAmount ( ) , 2 ) , 'grandTotal' => round ( $ quote -> getGrandTotal ( ) , 2 ) ] ] ; $ discountTotal = 0 ; $ lineItems = [ ] ; foreach ( $ quote -> getAllVisibleItems ( ) as $ item ) { $ discountTotal += $ item -> getDiscountAmount ( ) ; $ product = $ this -> productRepository -> getById ( $ item -> getProduct ( ) -> getId ( ) , false , $ store -> getId ( ) ) ; $ lineItems [ ] = [ 'sku' => $ item -> getSku ( ) , 'imageUrl' => $ this -> getProductImageUrl ( $ item , $ store ) , 'productUrl' => $ this -> urlFinder -> fetchFor ( $ product ) , 'name' => $ item -> getName ( ) , 'unitPrice' => round ( $ item -> getPrice ( ) , 2 ) , 'quantity' => $ item -> getQty ( ) ] ; } $ data [ 'json' ] [ 'discountAmount' ] = ( float ) $ discountTotal ; $ data [ 'json' ] [ 'lineItems' ] = $ lineItems ; return $ data ; }
Get payload data for API push.

@param \Magento\Quote\Model\Quote $quote
@param \Magento\Store\Api\Data\StoreInterface $store

@return array
@throws \Magento\Framework\Exception\NoSuchEntityException
Get payload data for API push .