Exemplo n.º 1
0
    /**
     * Call "Create Authorized Return" request by the ProductsReturn model
     *
     * @param \XLite\Module\XC\CanadaPost\Model\ProductsReturn $return Canada Post return model
     *
     * @return \XLite\Core\CommonCell
     */
    public function callCreateAuthorizedReturnByProductsReturn(\XLite\Module\XC\CanadaPost\Model\ProductsReturn $return)
    {
        $xmlHeader = '<' . '?xml version="1.0" encoding="utf-8"?' . '>';
        // Convert weight into KG
        $itemsWeight = \XLite\Core\Converter::convertWeightUnits($return->getItemsTotalWeight(), \XLite\Core\Config::getInstance()->Units->weight_unit, 'kg');
        $itemsWeight = static::adjustFloatValue($itemsWeight, 3, 0.1, 999.999);
        $requestData = <<<XML
{$xmlHeader}
<authorized-return xmlns="http://www.canadapost.ca/ws/authreturn-v2">
    <service-code>{$return->getOrder()->getCapostShippingMethodCode()}</service-code>
{$this->getXmlBlockReturnerAddress($return->getOrder()->getProfile())}
{$this->getXmlBlockReceiverAddress()}
    <parcel-characteristics>
        <weight>{$itemsWeight}</weight>
    </parcel-characteristics>
    <print-preferences>
        <output-format>8.5x11</output-format>
        <encoding>PDF</encoding>
    </print-preferences>
    <settlement-info></settlement-info>
</authorized-return>
XML;
        return $this->callCreateAuthorizedReturn($requestData);
    }
 /**
  * {@inheritDoc}
  */
 public function getItemsTotalWeight()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getItemsTotalWeight', array());
     return parent::getItemsTotalWeight();
 }