/** * Get "sku-list" XML block (part of the "customs" block) * Common for "Create Non-Contract Shipment" and "Create Shipment" calls * * @param \XLite\Module\XC\CanadaPost\Model\Order\Parcel $parcel Canada Post parcel model * * @return string */ protected function getSkuListCommonXmlBlockByParcel(\XLite\Module\XC\CanadaPost\Model\Order\Parcel $parcel) { $xmlDataItems = ''; foreach ($parcel->getItems() as $item) { $itemDescr = static::adjustStringValue($item->getOrderItem()->getName(), 44); $itemSku = static::adjustStringValue($item->getOrderItem()->getSku(), 44); // Convert item price $itemPrice = static::applyConversionRate($item->getOrderItem()->getItemPrice()); $itemPrice = static::adjustFloatValue($itemPrice, 2, 0.01, 99999.99000000001); $xmlDataItems .= <<<XML <item> <customs-number-of-units>{$item->getAmount()}</customs-number-of-units> <customs-description>{$itemDescr}</customs-description> <sku>{$itemSku}</sku> <unit-weight>{$item->getWeightInKg(true)}</unit-weight> <customs-value-per-unit>{$itemPrice}</customs-value-per-unit> </item> XML; } $xmlData = <<<XML <sku-list> {$xmlDataItems} </sku-list> XML; return $xmlData; }
/** * {@inheritDoc} */ public function getItems() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getItems', array()); return parent::getItems(); }