protected function getItemData()
    {
        $result = '';
        $items = $this->getItems();

        // If there are no items, then do not construct any of the basket.
        if (empty($items) || $items->all() === array()) {
            return $result;
        }

        $xml = new \SimpleXMLElement('<basket/>');
        $cartHasDiscounts = false;

        foreach ($items as $basketItem) {
            if ($basketItem->getPrice() < 0) {
                $cartHasDiscounts = true;
            } else {
                $vat = '0.00';
                if ($basketItem instanceof ExtendItem) {
                    $vat = $basketItem->getVat();
                }

                $total = ($basketItem->getQuantity() * ($basketItem->getPrice() + $vat));
                $item = $xml->addChild('item');
                $item->description = $this->filterItemName($basketItem->getName());
                $item->addChild('quantity', $basketItem->getQuantity());
                $item->addChild('unitNetAmount', $basketItem->getPrice());
                $item->addChild('unitTaxAmount', $vat);
                $item->addChild('unitGrossAmount', $basketItem->getPrice() + $vat);
                $item->addChild('totalGrossAmount', $total);
            }
        }

        if ($cartHasDiscounts) {
            $discounts = $xml->addChild('discounts');
            foreach ($items as $discountItem) {
                if ($discountItem->getPrice() < 0) {
                    $discount = $discounts->addChild('discount');
                    $discount->addChild('fixed', ($discountItem->getPrice() * $discountItem->getQuantity()) * -1);
                    $discount->description = $this->filterDiscountName($discountItem->getName());
                }
            }
        }

        $xmlString = $xml->asXML();

        if ($xmlString) {
            $result = $xmlString;
        }

        return $result;
    }
protected function getItemData()
    {
        $result = '';
        $items = $this->getItems();

        // If there are no items, then do not construct any of the basket.
        if (empty($items) || $items->all() === array()) {
            return $result;
        }

        $xml = new \SimpleXMLElement('<basket/>');
        $cartHasDiscounts = false;

        foreach ($items as $basketItem) {
            if ($basketItem->getPrice() < 0) {
                $cartHasDiscounts = true;
            } else {
                $vat = '0.00';
                if ($basketItem instanceof ExtendItem) {
                    $vat = $basketItem->getVat();
                }

                $total = ($basketItem->getQuantity() * ($basketItem->getPrice() + $vat));
                $item = $xml->addChild('item');
                $item->description = $this->filterItemName($basketItem->getName());
                $item->addChild('quantity', $basketItem->getQuantity());
                $item->addChild('unitNetAmount', $basketItem->getPrice());
                $item->addChild('unitTaxAmount', $vat);
                $item->addChild('unitGrossAmount', $basketItem->getPrice() + $vat);
                $item->addChild('totalGrossAmount', $total);
            }
        }

        if ($cartHasDiscounts) {
            $discounts = $xml->addChild('discounts');
            foreach ($items as $discountItem) {
                if ($discountItem->getPrice() < 0) {
                    $discount = $discounts->addChild('discount');
                    $discount->addChild('fixed', ($discountItem->getPrice() * $discountItem->getQuantity()) * -1);
                    $discount->description = $this->filterDiscountName($discountItem->getName());
                }
            }
        }

        $xmlString = $xml->asXML();

        if ($xmlString) {
            $result = $xmlString;
        }

        return $result;
    }
protected function getItemData ( ) { $ result = '' ; $ items = $ this -> getItems ( ) ; // If there are no items, then do not construct any of the basket. if ( empty ( $ items ) || $ items -> all ( ) === array ( ) ) { return $ result ; } $ xml = new \ SimpleXMLElement ( '<basket/>' ) ; $ cartHasDiscounts = false ; foreach ( $ items as $ basketItem ) { if ( $ basketItem -> getPrice ( ) < 0 ) { $ cartHasDiscounts = true ; } else { $ vat = '0.00' ; if ( $ basketItem instanceof ExtendItem ) { $ vat = $ basketItem -> getVat ( ) ; } $ total = ( $ basketItem -> getQuantity ( ) * ( $ basketItem -> getPrice ( ) + $ vat ) ) ; $ item = $ xml -> addChild ( 'item' ) ; $ item -> description = $ this -> filterItemName ( $ basketItem -> getName ( ) ) ; $ item -> addChild ( 'quantity' , $ basketItem -> getQuantity ( ) ) ; $ item -> addChild ( 'unitNetAmount' , $ basketItem -> getPrice ( ) ) ; $ item -> addChild ( 'unitTaxAmount' , $ vat ) ; $ item -> addChild ( 'unitGrossAmount' , $ basketItem -> getPrice ( ) + $ vat ) ; $ item -> addChild ( 'totalGrossAmount' , $ total ) ; } } if ( $ cartHasDiscounts ) { $ discounts = $ xml -> addChild ( 'discounts' ) ; foreach ( $ items as $ discountItem ) { if ( $ discountItem -> getPrice ( ) < 0 ) { $ discount = $ discounts -> addChild ( 'discount' ) ; $ discount -> addChild ( 'fixed' , ( $ discountItem -> getPrice ( ) * $ discountItem -> getQuantity ( ) ) * - 1 ) ; $ discount -> description = $ this -> filterDiscountName ( $ discountItem -> getName ( ) ) ; } } } $ xmlString = $ xml -> asXML ( ) ; if ( $ xmlString ) { $ result = $ xmlString ; } return $ result ; }
Get an XML representation of the current cart items

@return string The XML string; an empty string if no basket items are present
Get an XML representation of the current cart items