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; }
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; }
/** * Initialize the block data * * @param string $format template used to format the address * @return self */ public function initType($format) { $type = new Varien_Object(); $type->setCode('address_verification')->setTitle('Address Verification Suggestion')->setDefaultFormat($format)->setHtmlEscape(true); $this->setType($type); return $this; }
/** * @param Mage_Customer_Model_Address_Abstract $address * @param null $format * @param string $template * @param string $helper * * @return string */ public function render(Mage_Customer_Model_Address_Abstract $address, $format = null, $template = '', $helper = '') { $type = new Varien_Object(); $type->setCode('html'); $this->setType($type); $format = Mage::app()->getLayout()->createBlock('pdfcustomiser/pdf_block')->setPdfHelper($helper)->setTemplate($template)->toHtml(); return parent::render($address, $format); }
public function testGetQuoteCurrency() { $quote = Mage::getModel('sales/quote'); $this->assertEquals(Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode(), Mage::helper('ops/quote')->getQuoteCurrency($quote)); $forcedCurrency = new Varien_Object(); $forcedCurrency->setCode('USD'); $quote->setForcedCurrency($forcedCurrency); $this->assertEquals('USD', Mage::helper('ops/quote')->getQuoteCurrency($quote)); }
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 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'); } }
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() { $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; }
/** * Load actions config * * @return void * @throws Mage_Core_Exception */ protected function _loadActionsConfig() { foreach ($this->getActionsConfigNode()->children() as $code => $node) { $config = new Varien_Object(); $config->setCode($code); $model = Mage::getModel($node); if (!$model instanceof Smile_MageCache_Model_Action) { Mage::throwException(Mage::helper('smile_magecache')->__('Class of "%s" action is not valid', $code)); } $config->setModel($model); self::$_actionsConfig[$code] = $config; } }
/** * Additionally check for session messages in several domains case * * @param string $url * @param int $code * @return Mage_Core_Controller_Response_Http */ public function setRedirect($url, $code = 302) { /** * Use single transport object instance */ if (self::$_transportObject === null) { self::$_transportObject = new Varien_Object(); } self::$_transportObject->setUrl($url); self::$_transportObject->setCode($code); Mage::dispatchEvent('controller_response_redirect', array('response' => $this, 'transport' => self::$_transportObject)); return parent::setRedirect(self::$_transportObject->getUrl(), self::$_transportObject->getCode()); }
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'); } }
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() { $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; }
/** * 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; }
/** * Retrieve actions collection * * @return array * @throws Exception */ protected function _getActions() { $config = Mage::getSingleton('smile_magecache/config'); $actionsConfig = $config->getActionConfig(); $items = array(); $i = 0; foreach ($actionsConfig as $code => $actionConfig) { $action = new Varien_Object(); $action->setPosition($i++); $action->setCode($actionConfig->getCode()); $action->setName($actionConfig->getModel()->getLabel()); $action->setDescription($actionConfig->getModel()->getDescription()); $items[] = $action; } return $items; }
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 getFormats() { if (is_null($this->_types)) { $this->_types = array(); foreach ($this->getNode('formats')->children() as $typeCode => $typeConfig) { $type = new Varien_Object(); $type->setCode($typeCode)->setTitle((string) $typeConfig->title)->setDefaultFormat((string) $typeConfig->defaultFormat)->setHtmlEscape((bool) $typeConfig->htmlEscape); $renderer = (string) $typeConfig->renderer; if (!$renderer) { $renderer = self::DEFAULT_ADDRESS_RENDERER; } $type->setRenderer(AO::helper('customer/address')->getRenderer($renderer)->setType($type)); $this->_types[] = $type; } } return $this->_types; }
public function getShippingRates($order) { $request = $this->prepareShippingRequest($order); $shipping = Mage::getModel('shipping/shipping'); $result = $shipping->collectRates($request)->getResult(); if ($result) { $rates = array(); foreach ($result->getAllRates() as $_rate) { $rate = new Varien_Object(); $rate->setData($_rate->getData()); $carrier = $rate->getCarrier(); if (!isset($rates[$carrier])) { $rates[$carrier] = array(); } $rate->setCode($carrier . '_' . $rate->getMethod()); $rates[$carrier][$rate->getCode()] = $rate; } return $rates; } return null; }
public function getActiveMethodRate() { if ($this->getCustomMethodCode() == $this->getOrder()->getShippingMethod()) { $rate = new Varien_Object(); $rate->setCode($this->getCustomMethodCode()); $rate->setPrice($this->getOrder()->getShippingAmount()); $rate->setMethodTitle(Mage::helper('iwd_ordermanager')->__("Custom")); $rate->setMethodDescription($this->getOrder()->getShippingDescription()); return $rate; } if (is_array($this->shipping_rates)) { foreach ($this->shipping_rates as $group) { foreach ($group as $code => $rate) { if ($rate->getCode() == $this->getOrder()->getShippingMethod()) { return $rate; } } } } return false; }
/** * Prepare collection of errors * * @return Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Grid */ protected function _prepareCollection() { $collection = new Varien_Data_Collection(); $removeButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button', '', array('class' => 'delete', 'label' => '', 'onclick' => 'addBySku.removeFailedItem(this)', 'type' => 'button'))->toHtml(); /* @var $parentBlock Enterprise_Checkout_Block_Adminhtml_Sku_Errors_Abstract */ $parentBlock = $this->getParentBlock(); foreach ($parentBlock->getFailedItems() as $affectedItem) { // Escape user-submitted input if (isset($affectedItem['item']['qty'])) { $affectedItem['item']['qty'] = empty($affectedItem['item']['qty']) ? '' : (double) $affectedItem['item']['qty']; } $item = new Varien_Object(); $item->setCode($affectedItem['code']); if (isset($affectedItem['error'])) { $item->setError($affectedItem['error']); } $item->addData($affectedItem['item']); $item->setId($item->getSku()); /* @var $product Mage_Catalog_Model_Product */ $product = Mage::getModel('catalog/product'); if (isset($affectedItem['item']['id'])) { $productId = $affectedItem['item']['id']; $item->setProductId($productId); $product->load($productId); /* @var $stockStatus Mage_CatalogInventory_Model_Stock_Status */ $stockStatus = Mage::getModel('cataloginventory/stock_status'); $status = $stockStatus->getProductStatus($productId, $this->getWebsiteId()); if (!empty($status[$productId])) { $product->setIsSalable($status[$productId]); } $item->setPrice(Mage::helper('core')->formatPrice($product->getPrice())); } $descriptionBlock = $this->getLayout()->createBlock('enterprise_checkout/adminhtml_sku_errors_grid_description', '', array('product' => $product, 'item' => $item)); $item->setDescription($descriptionBlock->toHtml()); $item->setRemoveButton($removeButtonHtml); $collection->addItem($item); } $this->setCollection($collection); 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; }
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; }
/** * Retrieve address formats * * @return array */ public function getFormats() { $store = $this->getStore(); $storeId = $store->getId(); if (!isset($this->_types[$storeId])) { $this->_types[$storeId] = array(); foreach ($this->getNode('formats')->children() as $typeCode => $typeConfig) { $path = sprintf('%s%s', self::XML_PATH_ADDRESS_TEMPLATE, $typeCode); $type = new Varien_Object(); $htmlEscape = strtolower($typeConfig->htmlEscape); $htmlEscape = $htmlEscape == 'false' || $htmlEscape == '0' || $htmlEscape == 'no' || !strlen($typeConfig->htmlEscape) ? false : true; $type->setCode($typeCode)->setTitle((string) $typeConfig->title)->setDefaultFormat(Mage::getStoreConfig($path, $store))->setHtmlEscape($htmlEscape); $renderer = (string) $typeConfig->renderer; if (!$renderer) { $renderer = self::DEFAULT_ADDRESS_RENDERER; } $type->setRenderer(Mage::helper('customer/address')->getRenderer($renderer)->setType($type)); $this->_types[$storeId][] = $type; } } return $this->_types[$storeId]; }
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; }
/** * Load data * * @param bool $printQuery * @param bool $logQuery * @return Mage_XmlConnect_Model_Resource_Filter_Collection */ public function load($printQuery = false, $logQuery = false) { if (empty($this->_items)) { $layer = Mage::getSingleton('catalog/layer'); foreach ($this->_filters as $filter) { if ('category_id' == $filter['field']) { $layer->setCurrentCategory((int) $filter['value']); } } if ($layer->getCurrentCategory()->getIsAnchor()) { foreach ($layer->getFilterableAttributes() as $attributeItem) { $filterModelName = 'catalog/layer_filter_attribute'; switch ($attributeItem->getAttributeCode()) { case 'price': $filterModelName = 'catalog/layer_filter_price'; break; case 'decimal': $filterModelName = 'catalog/layer_filter_decimal'; break; default: $filterModelName = 'catalog/layer_filter_attribute'; break; } $filterModel = Mage::getModel($filterModelName); $filterModel->setLayer($layer)->setAttributeModel($attributeItem); $filterValues = new Varien_Data_Collection(); foreach ($filterModel->getItems() as $valueItem) { $valueObject = new Varien_Object(); $valueObject->setLabel($valueItem->getLabel()); $valueObject->setValueString($valueItem->getValueString()); $valueObject->setProductsCount($valueItem->getCount()); $filterValues->addItem($valueObject); } $item = new Varien_Object(); $item->setCode($attributeItem->getAttributeCode()); $item->setName($filterModel->getName()); $item->setValues($filterValues); $this->addItem($item); } } } return $this; }
public function convertOrderToQuote($observer) { $order = $observer->getEvent()->getOrder(); $quote = $observer->getEvent()->getQuote(); $documentIds = array(); foreach ($order->getItemsCollection() as $orderItem) { $documentIds[$orderItem->getProductId()][] = $orderItem->getProductOptionByCode('chili_document_id'); } foreach ($quote->getAllItems() as $quoteItem) { $documentId = $documentIds[$quoteItem->getProduct()->getId()][0]; if ($documentId) { $option = new Varien_Object(); $option->setProduct($quoteItem->getProduct()); $option->setCode('chili_document_id'); $option->setValue($documentId); $quoteItem->addOption($option); } } }
public function getConfigAsObject($code) { $xml = $this->getConfigAsXml($code); $object = new Varien_Object(); if ($xml === null) { return $object; } // Save all nodes to object data $object->setCode($code); $object->setData($xml->asCanonicalArray()); // Set module for translations etc.. $module = $object->getData('@/module'); $object->setModule($module ? $module : 'customgrid'); // Set type $type = $object->getData('@/type'); $object->setType($type); // Translate name, description and help $helper = Mage::helper($object->getModule()); if ($object->hasName()) { $object->setName($helper->__((string) $object->getName())); } if ($object->hasDescription()) { $object->setDescription($helper->__((string) $object->getDescription())); } if ($object->hasHelp()) { $object->setHelp($helper->__((string) $object->getHelp())); } if ($this->_acceptParameters) { // Correct element parameters and convert its data to objects if needed $params = $object->getData('parameters'); $newParams = array(); if (is_array($params)) { $sortOrder = 0; foreach ($params as $key => $data) { if (is_array($data)) { $data['key'] = $key; $data['sort_order'] = isset($data['sort_order']) ? (int) $data['sort_order'] : $sortOrder; // Prepare values (for dropdowns) specified directly in configuration $values = array(); if (isset($data['values']) && is_array($data['values'])) { foreach ($data['values'] as $value) { if (isset($value['label']) && isset($value['value'])) { $values[] = $value; } } } $data['values'] = $values; // Prepare helper block object if (isset($data['helper_block'])) { $helper = new Varien_Object(); if (isset($data['helper_block']['data']) && is_array($data['helper_block']['data'])) { $helper->addData($data['helper_block']['data']); } if (isset($data['helper_block']['type'])) { $helper->setType($data['helper_block']['type']); } $data['helper_block'] = $helper; } $newParams[$key] = new Varien_Object($data); $sortOrder++; } } } uasort($newParams, array($this, '_sortParameters')); $object->setData('parameters', $newParams); } return $object; }
public function testAddCCForZeroAmountCheckout() { $block = new Mage_Payment_Block_Form_Container(); $method = new Varien_Object(); $method->setCode('ops_ideal'); $block->setData('methods', array($method)); $quote = Mage::getModel('sales/quote'); $block->setQuote($quote); $featureModelMock = $this->getModelMock('ops/payment_features_zeroAmountAuth', array('isCCAndZeroAmountAuthAllowed')); $featureModelMock->expects($this->any())->method('isCCAndZeroAmountAuthAllowed')->will($this->returnValue(true)); $this->replaceByMock('model', 'ops/payment_features_zeroAmountAuth', $featureModelMock); $this->_helper->addCCForZeroAmountCheckout($block); $methods = $block->getMethods(); $this->assertTrue($methods[1] instanceof Netresearch_OPS_Model_Payment_Cc); $this->assertFalse($methods[0] instanceof Netresearch_OPS_Model_Payment_Cc); }