public function initTotals() { $parent = $this->getParentBlock(); $paymentMethod = $parent->getOrder()->getPayment()->getMethodInstance()->getCode(); if (!in_array($paymentMethod, self::$_allowed_methods)) { return $this; } if ($parent->getOrder()->getBasePayexPaymentFeeTax()) { $total = new Varien_Object(); $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)')); $total->setValue($parent->getOrder()->getPayexPaymentFee() + $parent->getOrder()->getPayexPaymentFeeTax()); $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee() + $parent->getOrder()->getPayexBasePaymentFeeTax()); $total->setCode('payex_payment_fee_with_tax'); $parent->addTotalBefore($total, 'tax'); } if ($parent->getOrder()->getBasePayexPaymentFee()) { $total = new Varien_Object(); $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)')); $total->setValue($parent->getOrder()->getPayexPaymentFee()); $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee()); $total->setCode('payex_payment_fee'); $parent->addTotalBefore($total, 'payex_payment_fee_with_tax'); } return $this; }
/** * @return mixed */ protected function _getParams() { if (!Mage::registry(self::REGISTRY_KEY_PARAMS)) { $request = Mage::app()->getRequest(); $params = array('host' => $request->getServer('HTTP_HOST'), 'port' => $request->getServer('SERVER_PORT'), 'full_action_name' => $this->getFullActionName()); $uriParams = $this->_getUriParams(); foreach ($request->getParams() as $requestParam => $requestParamValue) { if (!$requestParamValue) { continue; } foreach ($uriParams as $uriParam) { if ($this->_matchUriParam($uriParam, $requestParam)) { $params['uri_' . $requestParam] = $requestParamValue; break; } } } if (Mage::getStoreConfig(self::XML_PATH_CUSTOMER_GROUPS)) { $customerSession = Mage::getSingleton('customer/session'); $params['customer_group_id'] = $customerSession->getCustomerGroupId(); } // edit parameters via event $parameters = new Varien_Object(); $parameters->setValue($params); Mage::dispatchEvent('fpc_helper_collect_params', array('parameters' => $parameters)); $params = $parameters->getValue(); Mage::register(self::REGISTRY_KEY_PARAMS, serialize($params)); } return Mage::registry(self::REGISTRY_KEY_PARAMS); }
public function initTotals() { $parent = $this->getParentBlock(); $this->_invoice = $parent->getInvoice(); if ($this->_invoice->getCodFee()) { $cod = new Varien_Object(); $cod->setLabel($this->__('Cash on Delivery fee')); $cod->setValue($this->_invoice->getCodFee()); $cod->setBaseValue($this->_invoice->getBaseCodFee()); $cod->setCode('cod_fee'); if (Mage::helper('cashondelivery')->displayCodBothPrices()) { $cod->setLabel($this->__('Cash on Delivery fee (Excl.Tax)')); $codIncl = new Varien_Object(); $codIncl->setLabel($this->__('Cash on Delivery fee (Incl.Tax)')); $codIncl->setValue($this->_invoice->getCodFee() + $this->_invoice->getCodTaxAmount()); $codIncl->setBaseValue($this->_invoice->getBaseCodFee() + $this->_invoice->getBaseCodTaxAmount()); $codIncl->setCode('cod_fee_incl'); $parent->addTotalBefore($cod, 'tax'); $parent->addTotalBefore($codIncl, 'tax'); } elseif (Mage::helper('cashondelivery')->displayCodFeeIncludingTax()) { $cod->setValue($this->_invoice->getCodFee() + $this->_invoice->getCodTaxAmount()); $cod->setBaseValue($this->_invoice->getBaseCodFee() + $this->_invoice->getBaseCodTaxAmount()); $parent->addTotalBefore($cod, 'tax'); } else { $parent->addTotalBefore($cod, 'tax'); } } return $this; }
public function initTotals() { if ($this->giftwrapAmount() > 0) { $total = new Varien_Object(); $total->setCode('giftwrap'); $total->setValue($this->giftwrapAmount()); $total->setBaseValue(0); $total->setLabel('Gift wrap'); $parent = $this->getParentBlock(); $parent->addTotal($total, 'subtotal'); } }
public function addToBlock($block) { $order = $block->getOrder(); $label = Mage::getStoreConfig('payment/' . $order->getPayment()->getMethod() . '/surcharge_label'); $fee = new Varien_Object(); $fee->setCode('surcharge_incl'); $fee->setLabel($label); $fee->setBaseValue(10); $fee->setValue(11); $block->addTotalBefore($fee, 'shipping'); return $block; }
public function initTotals() { if ($this->discountAmount() != 0) { $total = new Varien_Object(); $total->setCode('webposdiscount'); $total->setValue(-$this->discountAmount()); $total->setBaseValue(0); $total->setLabel('Discount(Admin)'); $parent = $this->getParentBlock(); $parent->addTotal($total, 'subtotal'); } }
/** * @param $group Webguys_Easytemplate_Model_Group * @return $this */ public function setChildsBasedOnGroup($group, $parent = null) { if (!$this->countChildren()) { Varien_Profiler::start('easytemplate_template_rendering'); /** @var $configModel Webguys_Easytemplate_Model_Input_Parser */ $configModel = Mage::getSingleton('easytemplate/input_parser'); $position = 1; $time = Mage::app()->getLocale()->storeTimeStamp(Mage::app()->getStore()->getId()); /** @var $template Webguys_Easytemplate_Model_Template */ foreach ($group->getTemplateCollection($parent) as $template) { $templateCode = $template->getCode(); if ($model = $configModel->getTemplate($templateCode)) { $active = $template->getActive(); $validFrom = $template->getValidFrom() ? strtotime($template->getValidFrom()) : false; $validTo = $template->getValidTo() ? strtotime($template->getValidTo()) : false; if ($validFrom !== false || $validTo !== false) { $this->_cachingAllowed = false; } Varien_Profiler::start('easytemplate_template_rendering_' . $templateCode); if ($active && (!$validFrom || $validFrom <= $time) && (!$validTo || $validTo >= $time)) { /** @var $childBlock Webguys_Easytemplate_Block_Template */ $childBlock = $this->getLayout()->createBlock($model->getType()); $childBlock->setTemplate($model->getTemplate()); $childBlock->setTemplateModel($template); $childBlock->setTemplateCode($templateCode); $childBlock->setGroup($group); /** @var $field Webguys_Easytemplate_Model_Input_Parser_Field */ foreach ($model->getFields() as $field) { $fieldCode = $field->getCode(); Varien_Profiler::start('easytemplate_template_rendering_' . $templateCode . '_field_' . $fieldCode); /** @var $inputValidator Webguys_Easytemplate_Model_Input_Renderer_Validator_Base */ $inputValidator = $field->getInputRendererValidator(); $inputValidator->setTemplate($template); $inputValidator->setField($field); $frontendValue = $inputValidator->prepareForFrontend($template->getFieldData($fieldCode)); if ($frontendValue) { $valueTransport = new Varien_Object(); $valueTransport->setValue($frontendValue); Mage::dispatchEvent('easytemplate_frontend_prepared_var', array('template' => $template, 'template_model' => $model, 'field' => $field, 'block' => $childBlock, 'validator' => $inputValidator, 'value' => $valueTransport)); $childBlock->setData($fieldCode, $valueTransport->getValue()); } Varien_Profiler::stop('easytemplate_template_rendering_' . $templateCode . '_field_' . $fieldCode); } $this->setChild('block_' . $position . '_' . $templateCode, $childBlock); $position++; } Varien_Profiler::stop('easytemplate_template_rendering_' . $templateCode); } } Varien_Profiler::stop('easytemplate_template_rendering'); } return $this; }
public function initTotals() { $parent = $this->getParentBlock(); if ($this->_invoice->getCodFee()) { $cod = new Varien_Object(); $cod->setLabel($this->__('Refund Cash on Delivery fee')); $cod->setValue($parent->getSource()->getCodFee()); $cod->setBaseValue($parent->getSource()->getBaseCodFee()); $cod->setCode('cod_fee'); $parent->addTotalBefore($cod, 'adjustment_positive'); } return $this; }
public function initTotals() { $amount = $this->getAffiliateplusDiscount(); if (floatval($amount)) { $total = new Varien_Object(); $total->setCode('affiliateplus_discount'); $total->setValue($amount); $total->setBaseValue($this->getBaseAffiliateplusDiscount()); $total->setLabel('Affiliate Discount' . $this->getAffiliateCouponLabel()); $parent = $this->getParentBlock(); $parent->addTotal($total, 'subtotal'); } }
public function initTotals() { // var_dump($this->discountAmount()); if ($this->discountAmount() != 0) { $total = new Varien_Object(); $total->setCode('onestepcheckoutdiscount'); $total->setValue(-$this->discountAmount()); $total->setBaseValue(-$this->baseDiscountAmout()); $total->setLabel('Discount(Admin)'); $parent = $this->getParentBlock(); $parent->addTotal($total, 'subtotal'); } }
public function initTotals() { $amount = $this->getLuckydrawDiscount(); if (floatval($amount)) { $total = new Varien_Object(); $total->setCode('luckydraw_discount'); $total->setValue($amount); $total->setBaseValue($this->getBaseLuckydrawDiscount()); $total->setLabel('Lucky Draw Discount'); $parent = $this->getParentBlock(); $parent->addTotal($total, 'subtotal'); } }
/** * add fee to order detail view * * @return $this */ public function initTotals() { $parent = $this->getParentBlock(); $this->_order = $parent->getOrder(); if ($this->_order->getShopgatePaymentFee()) { $fee = new Varien_Object(); $fee->setLabel($this->__('Payment Fee')); $fee->setValue($this->_order->getShopgatePaymentFee()); $fee->setBaseValue($this->_order->getBaseShopgatePaymentFee()); $fee->setCode($this->getCode()); $parent->addTotalBefore($fee, 'tax'); } return $this; }
public function initTotals() { $parent = $this->getParentBlock(); if ($parent->getSource()) { $fee = new Varien_Object(); $fee->setLabel($this->__('Refund Payment fee')); $fee->setValue($parent->getSource()->getCapayableFee()); $fee->setBaseValue($parent->getSource()->getBaseCapayableFee()); $fee->setCode('payment_fee'); $fee->setBlockName('capayable_fee'); $parent->addTotalBefore($fee, 'adjustment_positive'); } return $this; }
/** * @test * @loadFixture fpc_helper_collect_params.yaml */ public function testFpcHelperCollectParams() { Mage::app()->getRequest()->setRouteName('catalog'); Mage::app()->getRequest()->setControllerName('category'); Mage::app()->getRequest()->setActionName('view'); /** @var Mage_Catalog_Model_Session $catalogSession */ $catalogSession = Mage::getSingleton('catalog/session'); $catalogSession->setData('fpc', 'cool'); $expectedResult = array('fpc' => 'cool', 'store' => Mage::app()->getStore(true)->getCode(), 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), 'design' => Mage::getDesign()->getPackageName() . '_' . Mage::getDesign()->getTheme('template'), 'session_fpc' => 'cool'); $params = array('fpc' => 'cool'); $object = new Varien_Object(); $object->setValue($params); Mage::dispatchEvent('fpc_helper_collect_params', array('parameters' => $object)); $this->assertEquals($expectedResult, $object->getValue()); }
public function initTotals() { $parent = $this->getParentBlock(); if ($parent->getOrder()->getPayment()->getMethodInstance()->getCode() !== 'factoring') { return $this; } if ($parent->getOrder()->getBaseFactoringPaymentFee()) { $total = new Varien_Object(); $total->setLabel($this->__('Payment fee')); $total->setValue($parent->getOrder()->getFactoringPaymentFee()); $total->setBaseValue($parent->getOrder()->getFactoringBasePaymentFee()); $total->setCode('factoring_payment_fee'); $parent->addTotalBefore($total, 'tax'); } return $this; }
public function addToBlock($block) { $order = $block->getOrder(); $info = $order->getPayment()->getMethodInstance()->getInfoInstance(); $storeId = Mage::app()->getStore()->getId(); $vatOption = Mage::getStoreConfig("tax/sales_display/price", $storeId); $invoiceFee = $info->getAdditionalInformation('billmateinvoice_fee'); $invoiceTax = $info->getAdditionalInformation('billmateinvoice_fee_tax'); $origInvFee = Mage::getStoreConfig('payment/billmateinvoice/billmate_fee'); if ($invoiceTax != 0 && $invoiceFee == $origInvFee) { $invoiceFee += $invoiceTax; } $extra = ''; $fee = new Varien_Object(); $fee->setCode('billmateinvoice_fee'); $label = Mage::helper('billmateinvoice')->__('Billmate Invoice Fee (Incl. Vat)'); $fee->setLabel($label); $fee->setBaseValue($invoiceFee); $fee->setValue($invoiceFee); $block->addTotalBefore($fee, 'shipping'); return $block; }
protected function _createCollection($storeId) { $configOptions = $config = Mage::getConfig()->loadModulesConfiguration('system.xml')->getNode()->asArray(); $collection = new Varien_Data_Collection(); $requiredSections = array('weltpixel_selector', 'weltpixel_colorsettings', 'weltpixel_fontsettings', 'weltpixel_layerednavigation'); foreach ($configOptions['sections'] as $section => $sectionOptions) { if (in_array($section, $requiredSections)) { $sectionName = $sectionOptions['label']; foreach ($sectionOptions['groups'] as $group => $groupOptions) { $groupName = $groupOptions['label']; foreach ($groupOptions['fields'] as $field => $fieldOptions) { $fieldName = $fieldOptions['label']; $item = new Varien_Object(); $item->setTitle($sectionName . '/' . $groupName . '/' . $fieldName); $item->setPath(implode('/', array($section, $group, $field))); $item->setValue(Mage::getStoreConfig(implode('/', array($section, $group, $field)), $storeId)); $collection->addItem($item); unset($item); } } } } $this->setItems($collection); }
public function initTotals() { // $parent = Mage_Adminhtml_Block_Sales_Order_Invoice_Totals // $this->_invoice = Mage_Sales_Model_Order_Invoice $parent = $this->getParentBlock(); $this->_invoice = $parent->getInvoice(); if (!$this->_invoice) { return $this; } $payment = $this->_invoice->getOrder()->getPayment(); $methodTitle = Mage::helper('capayable')->getMethodTitle($payment->getMethod()); if ($this->_invoice->getCapayableFee()) { $fee = new Varien_Object(); $fee->setLabel($this->__($methodTitle)); $fee->setValue($this->_invoice->getCapayableFee()); $fee->setBaseValue($this->_invoice->getBaseCapayableFee()); $fee->setCode('payment_fee'); if (Mage::helper('capayable')->displayBothPrices()) { $fee->setLabel($this->__('Payment fee (Excl.Tax)')); $feeIncl = new Varien_Object(); $feeIncl->setLabel($this->__('Payment fee (Incl.Tax)')); $feeIncl->setValue($this->_invoice->getCapayableFee() + $this->_invoice->getCapayableFeeTaxAmount()); $feeIncl->setBaseValue($this->_invoice->getBaseCapayableFee() + $this->_invoice->getBaseCapayableFeeTaxAmount()); $feeIncl->setCode('payment_fee_incl'); $parent->addTotalBefore($fee, 'tax'); $parent->addTotalBefore($feeIncl, 'tax'); } elseif (Mage::helper('capayable')->displayFeeIncludingTax()) { $fee->setValue($this->_invoice->getCapayableFee() + $this->_invoice->getCapayableFeeTaxAmount()); $fee->setBaseValue($this->_invoice->getBaseCapayableFee() + $this->_invoice->getBaseCapayableFeeTaxAmount()); $parent->addTotalBefore($fee, 'tax'); } else { $parent->addTotalBefore($fee, 'tax'); } } return $this; }
/** * Prepare and set request to this instance * * @param Mage_Shipping_Model_Rate_Request $request * @return Mage_Usa_Model_Shipping_Carrier_Fedex */ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } if ($request->getFedexAccount()) { $account = $request->getFedexAccount(); } else { $account = $this->getConfigData('account'); } $r->setAccount($account); if ($request->getFedexDropoff()) { $dropoff = $request->getFedexDropoff(); } else { $dropoff = $this->getConfigData('dropoff'); } $r->setDropoffType($dropoff); if ($request->getFedexPackaging()) { $packaging = $request->getFedexPackaging(); } else { $packaging = $this->getConfigData('packaging'); } $r->setPackaging($packaging); if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()); } $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code()); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId())); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code()); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } else { } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $r->setWeight($weight); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackagePhysicalValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $r->setMeterNumber($this->getConfigData('meter_number')); $r->setKey($this->getConfigData('key')); $r->setPassword($this->getConfigData('password')); $r->setIsReturn($request->getIsReturn()); $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); $this->_rawRequest = $r; return $this; }
/** * Prepare and set request in property of current instance * * @param Varien_Object $request * @return Mage_Usa_Model_Shipping_Carrier_Dhl */ public function setRequest(Varien_Object $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getAction() == 'GenerateLabel') { $r->setAction('GenerateLabel'); } else { $r->setAction('RateEstimate'); } $r->setIsGenerateLabelReturn($request->getIsGenerateLabelReturn()); $r->setStoreId($request->getStoreId()); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } if ($request->getDhlId()) { $id = $request->getDhlId(); } else { $id = $this->getConfigData('id'); } $r->setId($id); if ($request->getDhlPassword()) { $password = $request->getDhlPassword(); } else { $password = $this->getConfigData('password'); } $r->setPassword($password); if ($request->getDhlAccount()) { $accountNbr = $request->getDhlAccount(); } else { $accountNbr = $this->getConfigData('account'); } $r->setAccountNbr($accountNbr); if ($request->getDhlShippingKey()) { $shippingKey = $request->getDhlShippingKey(); } else { $shippingKey = $this->getConfigData('shipping_key'); } $r->setShippingKey($shippingKey); if ($request->getDhlShippingIntlKey()) { $shippingKey = $request->getDhlShippingIntlKey(); } else { $shippingKey = $this->getConfigData('shipping_intlkey'); } $r->setShippingIntlKey($shippingKey); if ($request->getDhlShipmentType()) { $shipmentType = $request->getDhlShipmentType(); } else { $shipmentType = $this->getConfigData('shipment_type'); } $r->setShipmentType($shipmentType); if ($request->getDhlDutiable()) { $shipmentDutible = $request->getDhlDutiable(); } else { $shipmentDutible = $this->getConfigData('dutiable'); } $r->setDutiable($shipmentDutible); if ($request->getDhlDutyPaymentType()) { $dutypaytype = $request->getDhlDutyPaymentType(); } else { $dutypaytype = $this->getConfigData('dutypaymenttype'); } $r->setDutyPaymentType($dutypaytype); if ($request->getDhlContentDesc()) { $contentdesc = $request->getDhlContentDesc(); } else { $contentdesc = $this->getConfigData('contentdesc'); } $r->setContentDesc($contentdesc); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $r->getStoreId()); } $r->setOrigCountry($origCountry); if ($request->getOrigCountryId()) { $origCountryId = $request->getOrigCountryId(); } else { $origCountryId = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $r->getStoreId()); } $r->setOrigCountryId($origCountryId); if ($request->getAction() == 'GenerateLabel') { $packageParams = $request->getPackageParams(); $shippingWeight = $request->getPackageWeight(); if ($packageParams->getWeightUnits() != Zend_Measure_Weight::POUND) { $shippingWeight = round(Mage::helper('usa')->convertMeasureWeight($request->getPackageWeight(), $packageParams->getWeightUnits(), Zend_Measure_Weight::POUND)); } if ($packageParams->getDimensionUnits() != Zend_Measure_Length::INCH) { $packageParams->setLength(round(Mage::helper('usa')->convertMeasureDimension($packageParams->getLength(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH))); $packageParams->setWidth(round(Mage::helper('usa')->convertMeasureDimension($packageParams->getWidth(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH))); $packageParams->setHeight(round(Mage::helper('usa')->convertMeasureDimension($packageParams->getHeight(), $packageParams->getDimensionUnits(), Zend_Measure_Length::INCH))); } $r->setPackageParams($packageParams); } else { /* * DHL only accepts weight as a whole number. Maximum length is 3 digits. */ $shippingWeight = $request->getPackageWeight(); if ($shipmentType != 'L') { $weight = $this->getTotalNumOfBoxes($shippingWeight); $shippingWeight = round(max(1, $weight), 0); } } $r->setValue(round($request->getPackageValue(), 2)); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $r->setCustomsValue($request->getPackageCustomsValue()); $r->setDestStreet(Mage::helper('core/string')->substr(str_replace("\n", '', $request->getDestStreet()), 0, 35)); $r->setDestStreetLine2($request->getDestStreetLine2()); $r->setDestCity($request->getDestCity()); $r->setOrigCompanyName($request->getOrigCompanyName()); $r->setOrigCity($request->getOrigCity()); $r->setOrigPhoneNumber($request->getOrigPhoneNumber()); $r->setOrigPersonName($request->getOrigPersonName()); $r->setOrigEmail(Mage::getStoreConfig('trans_email/ident_general/email', $r->getStoreId())); $r->setOrigCity($request->getOrigCity()); $r->setOrigPostal($request->getOrigPostal()); $originStreet1 = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS1, $r->getStoreId()); $originStreet2 = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ADDRESS2, $r->getStoreId()); $r->setOrigStreet($request->getOrigStreet() ? $request->getOrigStreet() : $originStreet2); $r->setOrigStreetLine2($request->getOrigStreetLine2()); $r->setDestPhoneNumber($request->getDestPhoneNumber()); $r->setDestPersonName($request->getDestPersonName()); $r->setDestCompanyName($request->getDestCompanyName()); if (is_numeric($request->getOrigState())) { $r->setOrigState(Mage::getModel('directory/region')->load($request->getOrigState())->getCode()); } else { $r->setOrigState($request->getOrigState()); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } //for DHL, puero rico state for US will assume as puerto rico country //for puerto rico, dhl will ship as international if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) { $destCountry = self::PUERTORICO_COUNTRY_ID; } $r->setDestCountryId($destCountry); $r->setDestState($request->getDestRegionCode()); $r->setWeight($shippingWeight); $r->setFreeMethodWeight($request->getFreeMethodWeight()); $r->setOrderShipment($request->getOrderShipment()); if ($request->getPackageId()) { $r->setPackageId($request->getPackageId()); } $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); $this->_rawRequest = $r; return $this; }
public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setAction($this->getCode('action', 'single')); $r->setProduct($request->getLimitMethod()); } else { $r->setAction($this->getCode('action', 'all')); $r->setProduct('GNDRES'); } if ($request->getUpsPickup()) { $pickup = $request->getUpsPickup(); } else { $pickup = $this->getConfigData('pickup'); } $r->setPickup($this->getCode('pickup', $pickup)); if ($request->getUpsContainer()) { $container = $request->getUpsContainer(); } else { $container = $this->getConfigData('container'); } $r->setContainer($this->getCode('container', $container)); if ($request->getUpsDestType()) { $destType = $request->getUpsDestType(); } else { $destType = $this->getConfigData('dest_type'); } $r->setDestType($this->getCode('dest_type', $destType)); if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore()); } $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code()); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore())); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code()); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } else { } $r->setWeight($request->getPackageWeight()); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackageValue()); if ($request->getUpsUnitMeasure()) { $unit = $request->getUpsUnitMeasure(); } else { $unit = $this->getConfigData('unit_of_measure'); } $r->setUnitMeasure($unit); $this->_rawRequest = $r; return $this; }
/** * Prepare and set request to this instance * * @param Mage_Shipping_Model_Rate_Request $request * @return Mage_Usa_Model_Shipping_Carrier_Usps */ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } else { $r->setService('ALL'); } if ($request->getUspsUserid()) { $userId = $request->getUspsUserid(); } else { $userId = $this->getConfigData('userid'); } $r->setUserId($userId); if ($request->getUspsContainer()) { $container = $request->getUspsContainer(); } else { $container = $this->getConfigData('container'); } $r->setContainer($container); if ($request->getUspsSize()) { $size = $request->getUspsSize(); } else { $size = $this->getConfigData('size'); } $r->setSize($size); if ($request->getGirth()) { $girth = $request->getGirth(); } else { $girth = $this->getConfigData('girth'); } $r->setGirth($girth); if ($request->getHeight()) { $height = $request->getHeight(); } else { $height = $this->getConfigData('height'); } $r->setHeight($height); if ($request->getLength()) { $length = $request->getLength(); } else { $length = $this->getConfigData('length'); } $r->setLength($length); if ($request->getWidth()) { $width = $request->getWidth(); } else { $width = $this->getConfigData('width'); } $r->setWidth($width); if ($request->getUspsMachinable()) { $machinable = $request->getUspsMachinable(); } else { $machinable = $this->getConfigData('machinable'); } $r->setMachinable($machinable); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId())); } if ($request->getOrigCountryId()) { $r->setOrigCountryId($request->getOrigCountryId()); } else { $r->setOrigCountryId(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId())); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } $r->setDestCountryId($destCountry); if (!$this->_isUSCountry($destCountry)) { $r->setDestCountryName($this->_getCountryName($destCountry)); } if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $r->setWeightPounds(floor($weight)); $r->setWeightOunces(round(($weight - floor($weight)) * self::OUNCES_POUND, 1)); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackageValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $r->setBaseSubtotalInclTax($request->getBaseSubtotalInclTax()); $this->_rawRequest = $r; return $this; }
/** * Prepare and set request to this instance * * @param Mage_Shipping_Model_Rate_Request $request * @return Mage_Usa_Model_Shipping_Carrier_Ups */ public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setAction($this->getCode('action', 'single')); $r->setProduct($request->getLimitMethod()); } else { $r->setAction($this->getCode('action', 'all')); $r->setProduct('GND' . $this->getConfigData('dest_type')); } if ($request->getUpsPickup()) { $pickup = $request->getUpsPickup(); } else { $pickup = $this->getConfigData('pickup'); } $r->setPickup($this->getCode('pickup', $pickup)); if ($request->getUpsContainer()) { $container = $request->getUpsContainer(); } else { $container = $this->getConfigData('container'); } $r->setContainer($this->getCode('container', $container)); if ($request->getUpsDestType()) { $destType = $request->getUpsDestType(); } else { $destType = $this->getConfigData('dest_type'); } $r->setDestType($this->getCode('dest_type', $destType)); if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()); } $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code()); if ($request->getOrigRegionCode()) { $origRegionCode = $request->getOrigRegionCode(); } else { $origRegionCode = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_REGION_ID, $request->getStoreId()); } if (is_numeric($origRegionCode)) { $origRegionCode = Mage::getModel('directory/region')->load($origRegionCode)->getCode(); } $r->setOrigRegionCode($origRegionCode); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_ZIP, $request->getStoreId())); } if ($request->getOrigCity()) { $r->setOrigCity($request->getOrigCity()); } else { $r->setOrigCity(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_CITY, $request->getStoreId())); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } //for UPS, puero rico state for US will assume as puerto rico country if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) { $destCountry = self::PUERTORICO_COUNTRY_ID; } // For UPS, Guam state of the USA will be represented by Guam country if ($destCountry == self::USA_COUNTRY_ID && $request->getDestRegionCode() == self::GUAM_REGION_CODE) { $destCountry = self::GUAM_COUNTRY_ID; } $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code()); $r->setDestRegionCode($request->getDestRegionCode()); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } else { } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $weight = $this->_getCorrectWeight($weight); $r->setWeight($weight); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackageValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); if ($request->getUpsUnitMeasure()) { $unit = $request->getUpsUnitMeasure(); } else { $unit = $this->getConfigData('unit_of_measure'); } $r->setUnitMeasure($unit); $r->setIsReturn($request->getIsReturn()); $this->_rawRequest = $r; return $this; }
public function process(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } if ($request->getDhlId()) { $id = $request->getDhlId(); } else { $id = $this->getConfigData('id'); } $r->setId($id); if ($request->getDhlPassword()) { $password = $request->getDhlPassword(); } else { $password = $this->getConfigData('password'); } $r->setPassword($password); if ($request->getDhlAccount()) { $accountNbr = $request->getDhlAccount(); } else { $accountNbr = $this->getConfigData('account'); } $r->setAccountNbr($accountNbr); if ($request->getDhlShippingKey()) { $shippingKey = $request->getDhlShippingKey(); } else { $shippingKey = $this->getConfigData('shipping_key'); } $r->setShippingKey($shippingKey); if ($request->getDhlShippingIntlKey()) { $shippingKey = $request->getDhlShippingIntlKey(); } else { $shippingKey = $this->getConfigData('shipping_intlkey'); } $r->setShippingIntlKey($shippingKey); if ($request->getDhlShipmentType()) { $shipmentType = $request->getDhlShipmentType(); } else { $shipmentType = $this->getConfigData('shipment_type'); } $r->setShipmentType($shipmentType); if ($request->getDhlDutiable()) { $shipmentDutible = $request->getDhlDutiable(); } else { $shipmentDutible = $this->getConfigData('dutiable'); } $r->setDutiable($shipmentDutible); if ($request->getDhlDutyPaymentType()) { $dutypaytype = $request->getDhlDutyPaymentType(); } else { $dutypaytype = $this->getConfigData('dutypaymenttype'); } $r->setDutyPaymentType($dutypaytype); if ($request->getDhlContentDesc()) { $contentdesc = $request->getDhlContentDesc(); } else { $contentdesc = $this->getConfigData('contentdesc'); } $r->setContentDesc($contentdesc); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore()); } $r->setOrigCountry($origCountry); /* * DHL only accepts weight as a whole number. Maximum length is 3 digits. */ $shippingWeight = round(min(1, $request->getPackageWeight()), 0); $freeMethodWeight = round(min(1, $request->getFreeMethodWeight()), 0); $r->setValue(round($request->getPackageValue(), 2)); $r->setDestStreet(substr($request->getDestStreet(), 0, 35)); $r->setDestCity($request->getDestCity()); $r->setDestCountryId($request->getDestCountryId()); $r->setDestState($request->getDestRegionCode()); $this->_rawRequest = $r; $methods = explode(',', $this->getConfigData('allowed_methods')); $freeMethod = $this->getConfigData('free_method'); $internationcode = $this->getCode('international_searvice'); foreach ($methods as $method) { if ($method == $internationcode && $r->getDestCountryId() != self::USA_COUNTRY_ID || $method != $internationcode && $r->getDestCountryId() == self::USA_COUNTRY_ID) { $weight = $freeMethod == $method ? $freeMethodWeight : $shippingWeight; if ($weight > 0) { $this->_rawRequest->setWeight($weight); $this->_rawRequest->setService($method); $this->_getQuotes(); } else { $this->_dhlRates[$method] = array('term' => $this->getCode('service', $method), 'price_total' => 0); } } } return $this; }
public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); $r->setStoreId($request->getStoreId()); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } if ($request->getDhlId()) { $id = $request->getDhlId(); } else { $id = $this->getConfigData('id'); } $r->setId($id); if ($request->getDhlPassword()) { $password = $request->getDhlPassword(); } else { $password = $this->getConfigData('password'); } $r->setPassword($password); if ($request->getDhlAccount()) { $accountNbr = $request->getDhlAccount(); } else { $accountNbr = $this->getConfigData('account'); } $r->setAccountNbr($accountNbr); if ($request->getDhlShippingKey()) { $shippingKey = $request->getDhlShippingKey(); } else { $shippingKey = $this->getConfigData('shipping_key'); } $r->setShippingKey($shippingKey); if ($request->getDhlShippingIntlKey()) { $shippingKey = $request->getDhlShippingIntlKey(); } else { $shippingKey = $this->getConfigData('shipping_intlkey'); } $r->setShippingIntlKey($shippingKey); if ($request->getDhlShipmentType()) { $shipmentType = $request->getDhlShipmentType(); } else { $shipmentType = $this->getConfigData('shipment_type'); } $r->setShipmentType($shipmentType); if ($request->getDhlDutiable()) { $shipmentDutible = $request->getDhlDutiable(); } else { $shipmentDutible = $this->getConfigData('dutiable'); } $r->setDutiable($shipmentDutible); if ($request->getDhlDutyPaymentType()) { $dutypaytype = $request->getDhlDutyPaymentType(); } else { $dutypaytype = $this->getConfigData('dutypaymenttype'); } $r->setDutyPaymentType($dutypaytype); if ($request->getDhlContentDesc()) { $contentdesc = $request->getDhlContentDesc(); } else { $contentdesc = $this->getConfigData('contentdesc'); } $r->setContentDesc($contentdesc); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore()); } $r->setOrigCountry($origCountry); /* * DHL only accepts weight as a whole number. Maximum length is 3 digits. */ $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $shippingWeight = round(max(1, $weight), 0); $r->setValue(round($request->getPackageValue(), 2)); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $r->setDestStreet(Mage::helper('core/string')->substr($request->getDestStreet(), 0, 35)); $r->setDestCity($request->getDestCity()); if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } //for DHL, puero rico state for US will assume as puerto rico country //for puerto rico, dhl will ship as international if ($destCountry == self::USA_COUNTRY_ID && ($request->getDestPostcode() == '00912' || $request->getDestRegionCode() == self::PUERTORICO_COUNTRY_ID)) { $destCountry = self::PUERTORICO_COUNTRY_ID; } $r->setDestCountryId($destCountry); $r->setDestState($request->getDestRegionCode()); $r->setWeight($shippingWeight); $r->setFreeMethodWeight($request->getFreeMethodWeight()); $this->_rawRequest = $r; // $methods = explode(',', $this->getConfigData('allowed_methods')); // // $freeMethod = $this->getConfigData('free_method'); // // $internationcode = $this->getCode('international_searvice'); // $minOrderAmount = $this->getConfigData('cutoff_cost') ? $this->getConfigData('cutoff_cost') : 0; // if ($shippingWeight>0) { // $this->_rawRequest->setWeight($shippingWeight); // $this->_getQuotes(); // foreach ($methods as $method) { // if(($method==$internationcode && ($r->getDestCountryId() != self::USA_COUNTRY_ID)) || // ($method!=$internationcode && ($r->getDestCountryId() == self::USA_COUNTRY_ID))) // { // $weight = $freeMethod==$method && $this->getConfigData('cutoff_cost') <= $r->getValue() ? 0 : $shippingWeight; // if ($weight>0) { // $this->_rawRequest->setWeight($weight); // $this->_rawRequest->setService($method); // $this->_getQuotes(); // } else { // $this->_dhlRates[$method] = array( // 'term' => $this->getCode('service', $method), // 'price_total' => 0, // ); // } // } // } // } else { // $this->_errors[] = Mage::helper('usa')->__('Please enter the package weight'); // } return $this; }
/** * Method is needed for specific actions to change given quote options values * according current product type logic * Example: the cataloginventory validation of decimal qty can change qty to int, * so need to change quote item qty option value too. * * @param array $options * @param Varien_Object $option * @param mixed $value * @param Mage_Catalog_Model_Product $product * @return Mage_Bundle_Model_Product_Type */ public function updateQtyOption($options, Varien_Object $option, $value, $product = null) { $optionProduct = $option->getProduct($product); $optionUpdateFlag = $option->getHasQtyOptionUpdate(); $optionCollection = $this->getOptionsCollection($product); $selections = $this->getSelectionsCollection($optionCollection->getAllIds(), $product); foreach ($selections as $selection) { if ($selection->getProductId() == $optionProduct->getId()) { foreach ($options as &$option) { if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) { if ($optionUpdateFlag) { $option->setValue(intval($option->getValue())); } else { $option->setValue($value); } } } } } return $this; }
public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } else { $r->setService('ALL'); } if ($request->getUspsUserid()) { $userId = $request->getUspsUserid(); } else { $userId = $this->getConfigData('userid'); } $r->setUserId($userId); if ($request->getUspsContainer()) { $container = $request->getUspsContainer(); } else { $container = $this->getConfigData('container'); } $r->setContainer($container); if ($request->getUspsSize()) { $size = $request->getUspsSize(); } else { $size = $this->getConfigData('size'); } $r->setSize($size); if ($request->getUspsMachinable()) { $machinable = $request->getUspsMachinable(); } else { $machinable = $this->getConfigData('machinable'); } $r->setMachinable($machinable); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode')); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } $r->setDestCountryId($destCountry); /* for GB, we cannot use United Kingdom */ if ($destCountry == 'GB') { $countryName = 'Great Britain and Northern Ireland'; } else { $countries = Mage::getResourceModel('directory/country_collection')->addCountryIdFilter($destCountry)->load()->getItems(); $country = array_shift($countries); $countryName = $country->getName(); } $r->setDestCountryName($countryName); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $r->setWeightPounds(floor($weight)); $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1)); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackageValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $this->_rawRequest = $r; return $this; }
public function addToBlock($block) { $order = $block->getOrder(); $info = $order->getPayment()->getMethodInstance()->getInfoInstance(); $storeId = Mage::app()->getStore()->getId(); $taxOption = Mage::getStoreConfig("tax/sales_display/shipping", $storeId); $country = $order->getShippingAddress()->getCountry(); //$lang = Mage::helper('klarnaPaymentModule/lang'); $label = Mage::getStoreConfig('payment/' . $order->getPayment()->getMethod() . '/payment_fee_label'); $paymentFee = $info->getAdditionalInformation('invoice_fee'); $basePaymentFee = $info->getAdditionalInformation('base_invoice_fee'); $paymentFeeExcludingVat = $info->getAdditionalInformation('invoice_fee_exluding_vat'); $basePaymentFeeExcludingVat = $info->getAdditionalInformation('base_invoice_fee_exluding_vat'); /** * 1 : Show exluding tax * 2 : Show including tax * 3 : Show both */ if ($taxOption === '1' || $taxOption === '3') { $label = Mage::getStoreConfig('payment/' . $order->getPayment()->getMethod() . '/payment_fee_label'); $fee = new Varien_Object(); $fee->setCode('invoice_fee_excl'); if ($taxOption == '3') { $label .= ' (Excl.Tax)'; } $fee->setLabel($label); $fee->setBaseValue($basePaymentFeeExcludingVat); $fee->setValue($paymentFeeExcludingVat); $block->addTotalBefore($fee, 'shipping'); } if ($taxOption === '2' || $taxOption === '3') { $label = Mage::getStoreConfig('payment/' . $order->getPayment()->getMethod() . '/payment_fee_label'); $fee = new Varien_Object(); $fee->setCode('invoice_fee_incl'); if ($taxOption == '3') { $label .= ' (Incl.Tax)'; } $fee->setLabel($label); $fee->setBaseValue($basePaymentFee); $fee->setValue($paymentFee); $block->addTotalBefore($fee, 'shipping'); } return $block; }
public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } else { $r->setService('ALL'); } if ($request->getUspsUserid()) { $userId = $request->getUspsUserid(); } else { $userId = $this->getConfigData('userid'); } $r->setUserId($userId); if ($request->getUspsContainer()) { $container = $request->getUspsContainer(); } else { $container = $this->getConfigData('container'); } $r->setContainer($container); if ($request->getUspsSize()) { $size = $request->getUspsSize(); } else { $size = $this->getConfigData('size'); } $r->setSize($size); if ($request->getUspsMachinable()) { $machinable = $request->getUspsMachinable(); } else { $machinable = $this->getConfigData('machinable'); } $r->setMachinable($machinable); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig(Mage_Shipping_Model_Config::XML_PATH_ORIGIN_POSTCODE, $this->getStore())); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } $r->setDestCountryId($destCountry); if (!$this->_isUSCountry($destCountry)) { $r->setDestCountryName($this->_getCountryName($destCountry)); } if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $r->setWeightPounds(floor($weight)); $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1)); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackageValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $this->_rawRequest = $r; return $this; }
public function setRequest(Mage_Shipping_Model_Rate_Request $request) { $this->_request = $request; $r = new Varien_Object(); if ($request->getLimitMethod()) { $r->setService($request->getLimitMethod()); } if ($request->getFedexAccount()) { $account = $request->getFedexAccount(); } else { $account = $this->getConfigData('account'); } $r->setAccount($account); if ($request->getFedexDropoff()) { $dropoff = $request->getFedexDropoff(); } else { $dropoff = $this->getConfigData('dropoff'); } $r->setDropoffType($dropoff); if ($request->getFedexPackaging()) { $packaging = $request->getFedexPackaging(); } else { $packaging = $this->getConfigData('packaging'); } $r->setPackaging($packaging); if ($request->getOrigCountry()) { $origCountry = $request->getOrigCountry(); } else { $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $this->getStore()); } $r->setOrigCountry(Mage::getModel('directory/country')->load($origCountry)->getIso2Code()); if ($request->getOrigPostcode()) { $r->setOrigPostal($request->getOrigPostcode()); } else { $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode', $this->getStore())); } if ($request->getDestCountryId()) { $destCountry = $request->getDestCountryId(); } else { $destCountry = self::USA_COUNTRY_ID; } $r->setDestCountry(Mage::getModel('directory/country')->load($destCountry)->getIso2Code()); if ($request->getDestPostcode()) { $r->setDestPostal($request->getDestPostcode()); } else { } $weight = $this->getTotalNumOfBoxes($request->getPackageWeight()); $r->setWeight($weight); if ($request->getFreeMethodWeight() != $request->getPackageWeight()) { $r->setFreeMethodWeight($request->getFreeMethodWeight()); } $r->setValue($request->getPackageValue()); $r->setValueWithDiscount($request->getPackageValueWithDiscount()); $this->_rawRequest = $r; return $this; }