Ejemplo n.º 1
0
 /**
  * Add Check / Money order info to order XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
 {
     $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
     $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
     if ($this->getInfo()->getAdditionalData()) {
         if ($this->getPayableTo()) {
             $orderItemXmlObj->addCustomChild('item', $this->getPayableTo(), array('label' => Mage::helper('sales')->__('Make Check payable to:')));
         }
         if ($this->getMailingAddress()) {
             $orderItemXmlObj->addCustomChild('item', $this->getMailingAddress(), array('label' => Mage::helper('payment')->__('Send Check to:')));
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Add order total rendered to XML object. Api version 23
  *
  * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
  * @return null
  */
 public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     $cards = $this->getGiftCards();
     if ($cards) {
         foreach ($cards as $card) {
             $label = Mage::helper('enterprise_giftcardaccount')->__('Gift Card (%s)', $card->getCode());
             $totalsXml->addCustomChild('item', '-' . $this->_formatPrice($card->getAmount()), array('id' => $this->getTotal()->getCode(), 'label' => $label));
         }
     } else {
         $cardsAmount = $this->getSource()->getGiftCardsAmount();
         if ($cardsAmount > 0) {
             $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($cardsAmount), array('label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card')));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Add last orders info to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastOrders
  */
 public function addLastOrdersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
         return $this;
     }
     /** @var $collection Mage_Reports_Model_Resource_Order_Collection */
     $collection = Mage::getResourceModel('reports/order_collection')->addItemCountExpr()->joinCustomerName('customer')->orderByCreatedAt()->setPageSize(self::LAST_ORDER_COUNT_LIMIT);
     foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
         if ($storeId) {
             $collection->addAttributeToFilter('store_id', $storeId);
             $collection->addRevenueToSelect();
         } else {
             $collection->addRevenueToSelect(true);
         }
         $this->setCollection($collection);
         $orderList = $this->_prepareColumns()->getCollection()->load();
         $valuesXmlObj = $xmlObj->addCustomChild('values', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
         foreach ($orderList as $order) {
             $itemXmlObj = $valuesXmlObj->addCustomChild('item');
             $itemXmlObj->addCustomChild('customer', $order->getCustomer(), array('label' => $this->__('Customer')));
             $itemXmlObj->addCustomChild('items_count', $order->getItemsCount(), array('label' => $this->__('Items')));
             $currency_code = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
             $itemXmlObj->addCustomChild('currency', Mage::app()->getLocale()->currency($currency_code)->toCurrency($order->getRevenue()), array('label' => $this->__('Grand Total')));
         }
         $collection->clear();
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Get values using old standard
  *
  * @deprecated old output standard
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
  */
 protected function _addOldStandardValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $countries = $this->_getCountryOptions();
     if (is_array($countries)) {
         $valuesXmlObj = $xmlObj->addCustomChild('values');
         foreach ($countries as $data) {
             $regions = array();
             if ($data['value']) {
                 $regions = $this->_getRegionOptions($data['value']);
             }
             $relationType = is_array($regions) && !empty($regions) ? 'region_id' : 'region';
             $selectedCountry = array();
             if ($this->getCountryId() == $data['value']) {
                 $selectedCountry = array('selected' => 1);
             }
             $item = $valuesXmlObj->addCustomChild('item', null, array('relation' => $relationType) + $selectedCountry);
             $item->addCustomChild('label', (string) $data['label']);
             $item->addCustomChild('value', $data['value']);
             if ($relationType == 'region_id') {
                 $regionsXmlObj = $item->addCustomChild('regions');
                 foreach ($regions as $regionData) {
                     $selectedRegion = array();
                     if (!empty($selectedCountry) && $this->getRegionId() == $regionData['value']) {
                         $selectedRegion = array('selected' => 1);
                     }
                     $regionItem = $regionsXmlObj->addCustomChild('region_item', null, $selectedRegion);
                     $regionItem->addCustomChild('label', (string) $regionData['label']);
                     $regionItem->addCustomChild('value', (string) $regionData['value']);
                 }
             }
         }
     }
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Add localization data to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xml
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Config
  */
 protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
 {
     /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
     $translateHelper = Mage::helper('xmlconnect/translate');
     $xml->addCustomChild('localization', $this->getUrl('*/*/localization'), array('hash' => sha1(serialize($translateHelper->getLocalizationArray()))));
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * Add order total rendered to XML object
  *
  * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
  * @return null
  */
 public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     $balance = $this->getSource()->getCustomerBalanceTotalRefunded();
     if ($balance) {
         $totalsXml->addCustomChild($this->getTotal()->getCode(), $this->_formatPrice($balance), array('label' => Mage::helper('enterprise_giftcardaccount')->__('Refunded to Store Credit')));
     }
 }
Ejemplo n.º 7
0
 /**
  * Add order total rendered to XML object. Api version 23
  *
  * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
  * @return null
  */
 public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     $balance = $this->getSource()->getCustomerBalanceAmount();
     if ($balance) {
         $totalsXml->addCustomChild('item', '-' . $this->_formatPrice($balance), array('id' => $this->getTotal()->getCode(), 'label' => Mage::helper('enterprise_giftcardaccount')->__('Store Credit')));
     }
 }
Ejemplo n.º 8
0
 /**
  * Add last orders info to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
  */
 public function addGraphInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     /** @var $graphInfoXmlObj Mage_XmlConnect_Model_Simplexml_Element */
     $graphInfoXmlObj = $xmlObj->addCustomChild('chart');
     $this->_addRangeValues($graphInfoXmlObj)->_addDataSelector($graphInfoXmlObj)->_addTotalsBar($graphInfoXmlObj);
     $graphInfoXmlObj = $graphInfoXmlObj->addCustomChild('chart_data');
     $this->_addChartDataOrders($graphInfoXmlObj)->_addChartDataAmounts($graphInfoXmlObj);
     return $this;
 }
Ejemplo n.º 9
0
 /**
  * Add CC Save Payment info to order XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
 {
     $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
     $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
     if ($_specificInfo = $this->getSpecificInformation()) {
         foreach ($_specificInfo as $label => $value) {
             $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label));
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Add value to element
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
  */
 protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $values = $this->getEscapedValue();
     if (!empty($values)) {
         $valuesXmlObj = $xmlObj->addCustomChild('values');
         foreach ($values as $element => $config) {
             $valuesXmlObj->addCustomChild('item', null, array('id' => $config['id'], 'title' => $config['title'], 'label' => $config['label'], 'type' => $element, 'value' => $config['value']));
         }
     }
     return $this;
 }
Ejemplo n.º 11
0
 /**
  * Add options to select
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Select
  */
 protected function _addOptions(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     if ($this->getOptions() && is_array($this->getOptions())) {
         $valuesXmlObj = $xmlObj->addCustomChild('values');
         foreach ($this->getOptions() as $option) {
             if (!isset($option['value']) || $option['value'] == '') {
                 continue;
             }
             $valuesXmlObj->addCustomChild('item', null, array('label' => $option['label'], 'value' => $option['value']));
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * Add item to XML object
  * (get from template: downloadable/sales/order/items/renderer/downloadable.phtml)
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
  * @return null
  */
 public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
 {
     /** @var $item Mage_Sales_Model_Order_Item */
     $item = $this->getItem();
     /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */
     $itemXml = $orderItemXmlObj->addCustomChild('item', null, array('product_id' => $item->getProductId()));
     $itemXml->addCustomChild('name', $item->getName());
     /** @var $weeeHelper Mage_Weee_Helper_Data */
     $weeeHelper = $this->helper('weee');
     /** @var $taxHelper Mage_Tax_Helper_Data */
     $taxHelper = $this->helper('tax');
     Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
     $addtInfoBlock = $this->getProductAdditionalInformationBlock();
     if ($addtInfoBlock) {
         // TODO: find how to set additional info block
         // $addtInfoBlock->setItem($item)->toHtml();
     }
     $links = $this->getLinks();
     if ($links) {
         $linksXml = $itemXml->addCustomChild('links', null, array('label' => $this->getLinksTitle()));
         foreach ($links->getPurchasedItems() as $link) {
             $linksXml->addCustomChild('link', $link->getLinkTitle());
         }
     }
     $itemXml->addCustomChild('entity_type', $item->getProductType());
     $itemXml->addCustomChild('description', $item->getDescription());
     $itemXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($this->getSku()));
     /** @var $priceXml Mage_XmlConnect_Model_Simplexml_Element */
     $priceXml = $itemXml->addChild('price');
     // Quantity: Ordered, Shipped, Cancelled, Refunded
     Mage::helper('xmlconnect/customer_order')->addQuantityToXml($this, $itemXml->addChild('qty'), $item);
     /** @var $subtotalXml Mage_XmlConnect_Model_Simplexml_Element */
     $subtotalXml = $itemXml->addChild('subtotal');
     $this->setWeeeTaxAppliedAmount($item->getWeeeTaxAppliedAmount());
     $this->setWeeeTaxDisposition($item->getWeeeTaxDisposition());
     $typeOfDisplay1 = $weeeHelper->typeOfDisplay($item, 1, 'sales') && $this->getWeeeTaxAppliedAmount();
     $typeOfDisplay2 = $weeeHelper->typeOfDisplay($item, 2, 'sales') && $this->getWeeeTaxAppliedAmount();
     $typeOfDisplay4 = $weeeHelper->typeOfDisplay($item, 4, 'sales') && $this->getWeeeTaxAppliedAmount();
     $typeOfDisplay014 = $weeeHelper->typeOfDisplay($item, array(0, 1, 4), 'sales') && $this->getWeeeTaxAppliedAmount();
     $this->setTypesOfDisplay(array(Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1, Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2, Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4, Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014));
     $this->setWeeeTaxes($weeeHelper->getApplied($item));
     // Price & subtotal - excluding tax
     if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
         Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml($this, $item, $priceXml, $subtotalXml);
     }
     // Price & subtotal - including tax
     if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
         Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml($this, $item, $priceXml, $subtotalXml, true);
     }
 }
 /**
  * Add Authorizenet info to order XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
 {
     $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
     if (!$this->getHideTitle()) {
         $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
     }
     $cards = $this->getCards();
     $showCount = count($cards) > 1;
     foreach ($cards as $key => $card) {
         $creditCard = $orderItemXmlObj->addCustomChild('item', null, array('label' => $showCount ? $this->__('Credit Card %s', $key + 1) : $this->__('Credit Card')));
         foreach ($card as $label => $value) {
             $creditCard->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label));
         }
     }
 }
Ejemplo n.º 14
0
 /**
  * Collect product prices to specified item xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  * @return null
  */
 public function collectProductPrices(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     $this->setProduct($product);
     if ($product->getCanShowPrice() !== false) {
         $priceListXmlObj = $item->addCustomChild('price_list');
         $min = $this->getMinAmount();
         $max = $this->getMaxAmount();
         if ($min && $max && $min == $max) {
             $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
             $pricesXmlObj->addCustomChild('price', $min, array('id' => 'regular', 'label' => $this->__('Regular'), 'formatted_value' => Mage::helper('core')->currency($min, true, false)));
         } elseif ($min && $min != 0) {
             $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
             $pricesXmlObj->addCustomChild('price', $min, array('id' => 'regular', 'label' => $this->__('From'), 'formatted_value' => Mage::helper('core')->currency($min, true, false)));
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Add last search terms info to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
  */
 public function addTopSearchTermsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
         $this->_clearCollection()->_initCollection($storeId);
         $valuesXml = $xmlObj->addCustomChild('values', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
         if (!count($this->getCollection()->getItems()) > 0) {
             continue;
         }
         foreach ($this->getCollection()->getItems() as $item) {
             $itemListXml = $valuesXml->addCustomChild('item');
             $itemListXml->addCustomChild('name', $item->getName(), array('label' => $this->__('Search Term')));
             $itemListXml->addCustomChild('num_results', $item->getNumResults(), array('label' => $this->__('Results')));
             $itemListXml->addCustomChild('popularity', $item->getPopularity(), array('label' => $this->__('Number of Uses')));
         }
     }
     return $this;
 }
Ejemplo n.º 16
0
 /**
  * Add cart totals data to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
  */
 public function addTotalsDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $dataValuesXml = $xmlObj->addCustomChild('chart_totals');
     foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeFilter) {
         $storeId = $storeFilter ? $storeFilter : null;
         $totalsXml = $dataValuesXml->addCustomChild('totals', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
         foreach ($this->getRangeOptions() as $rangeFilter) {
             $this->_initCollection($storeId, $rangeFilter['value']);
             $valuesXml = $totalsXml->addCustomChild('values', null, array('range_id' => $rangeFilter['value']));
             foreach ($this->getTotals() as $total) {
                 $totalValue = $valuesXml->escapeXml($total['value'] . $total['decimals']);
                 $valuesXml->addCustomChild('item', $totalValue, array('label' => $total['label']));
             }
             $this->_clearTotals();
         }
     }
     return $this;
 }
Ejemplo n.º 17
0
 /**
  * Add most viewed products to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_MostViewedProducts
  */
 public function addMostViewedProductsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
         $this->_clearCollection()->_initCollection($storeId);
         $valuesXml = $xmlObj->addCustomChild('values', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
         if (!count($this->getCollection()->getItems()) > 0) {
             continue;
         }
         /** @var $orderHelper Mage_XmlConnect_Helper_Adminhtml_Dashboard_Order */
         $orderHelper = Mage::helper('xmlconnect/adminhtml_dashboard_order');
         foreach ($this->getCollection()->getItems() as $item) {
             $itemListXml = $valuesXml->addCustomChild('item');
             $itemListXml->addCustomChild('name', $item->getName(), array('label' => Mage::helper('reports')->__('Product Name')));
             $itemListXml->addCustomChild('price', $orderHelper->preparePrice($item->getPrice(), $storeId), array('label' => Mage::helper('reports')->__('Price')));
             $itemListXml->addCustomChild('views', $item->getViews(), array('label' => Mage::helper('reports')->__('Number of Views')));
         }
     }
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Add value to element
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Multiselect
  */
 protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $values = array();
     if (is_array($this->getEscapedValue())) {
         $values = $this->getEscapedValue();
     }
     $valuesXmlObj = $xmlObj->addCustomChild('values');
     foreach ($this->getOptions() as $option) {
         if (empty($option['value'])) {
             continue;
         }
         $selected = array();
         if (in_array($option['value'], $values)) {
             $selected = array('selected' => 1);
         }
         $valuesXmlObj->addCustomChild('item', $option['value'], array('label' => $option['label']) + $selected);
     }
     return $this;
 }
Ejemplo n.º 19
0
 /**
  * Add switcher item to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @param string $value
  * @param array $config
  * @param bool $isDisabled
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_StoreSwitcher
  */
 protected function _addSwitcherItem($xmlObj, $value, $config, $isDisabled = false)
 {
     if ($isDisabled) {
         $config += array('disabled' => 1);
     }
     $xmlObj->addCustomChild('item', $value, $config);
     return $this;
 }
 /**
  * Get method list object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function getMethodList($methodsXmlObj)
 {
     if (null === $this->_methodList) {
         $this->_methodList = $methodsXmlObj->addCustomChild('method_list');
     }
     return $this->_methodList;
 }
Ejemplo n.º 21
0
 /**
  * Add weee tax product info to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj
  * @param bool $subtotalFlag use true to get subtotal product info
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 protected function _addWeeeToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj, $subtotalFlag = false)
 {
     $_item = $this->getItem();
     $weeeXmlObj = $priceXmlObj->addCustomChild('weee');
     if ($subtotalFlag) {
         $_incl = $this->helper('checkout')->getSubtotalInclTax($_item);
     } else {
         $_incl = $this->helper('checkout')->getPriceInclTax($_item);
     }
     $typeOfDisplay2 = Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales');
     if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()) {
         foreach (Mage::helper('weee')->getApplied($_item) as $tax) {
             if ($subtotalFlag) {
                 $amount = $tax['row_amount'];
             } else {
                 $amount = $tax['amount'];
             }
             $weeeXmlObj->addCustomChild('item', null, array('name' => $tax['title'], 'amount' => $this->_formatPrice($amount)));
         }
     } elseif ($_item->getWeeeTaxAppliedAmount() && ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales'))) {
         foreach (Mage::helper('weee')->getApplied($_item) as $tax) {
             if ($subtotalFlag) {
                 $amount = $tax['row_amount_incl_tax'];
             } else {
                 $amount = $tax['amount_incl_tax'];
             }
             $weeeXmlObj->addCustomChild('item', null, array('name' => $tax['title'], 'amount' => $this->_formatPrice($amount)));
         }
     }
     if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) {
         if ($subtotalFlag) {
             $totalExcl = $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition();
         } else {
             $totalExcl = $_item->getCalculationPrice() + $_item->getWeeeTaxAppliedAmount() + $_item->getWeeeTaxDisposition();
         }
         $totalExcl = $this->_formatPrice($totalExcl);
         $priceXmlObj->addAttribute('total_excluding_tax', $priceXmlObj->escapeXml($totalExcl));
     }
     if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) {
         if ($subtotalFlag) {
             $totalIncl = $_incl + $_item->getWeeeTaxAppliedRowAmount();
         } else {
             $totalIncl = $_incl + $_item->getWeeeTaxAppliedAmount();
         }
         $totalIncl = $this->_formatPrice($totalIncl);
         $priceXmlObj->addAttribute('total_including_tax', $priceXmlObj->escapeXml($totalIncl));
     }
     return $priceXmlObj;
 }
Ejemplo n.º 22
0
 /**
  * Add item quantities to the XML
  *
  * @param Mage_Core_Block_Template $renderer Product renderer
  * @param Mage_XmlConnect_Model_Simplexml_Element $quantityXml
  * @param Mage_Sales_Model_Order_Item $item
  * @return null
  */
 public function addQuantityToXml(Mage_Core_Block_Template $renderer, Mage_XmlConnect_Model_Simplexml_Element $quantityXml, Mage_Sales_Model_Order_Item $item)
 {
     $qty = 1 * $item->getQtyOrdered();
     if ($qty > 0) {
         $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Ordered')));
     }
     $qty = 1 * $item->getQtyShipped();
     if ($qty > 0) {
         $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Shipped')));
     }
     $qty = 1 * $item->getQtyCanceled();
     if ($qty > 0) {
         $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Canceled')));
     }
     $qty = 1 * $item->getQtyRefunded();
     if ($qty > 0) {
         $quantityXml->addCustomChild('value', $qty, array('label' => $this->__('Refunded')));
     }
 }
Ejemplo n.º 23
0
 /**
  * Collect address data to xml node
  * Remove objects from data array and escape data values
  *
  * @param Mage_Customer_Model_Address $address
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  * @return Mage_XmlConnect_Block_Checkout_Onepage_Address_List
  */
 protected function _prepareAddressData(Mage_Customer_Model_Address $address, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     $attributes = Mage::helper('customer/address')->getAttributes();
     $data = array('entity_id' => $address->getId());
     foreach ($attributes as $attribute) {
         /* @var $attribute Mage_Customer_Model_Attribute */
         if (!$attribute->getIsVisible()) {
             continue;
         }
         if ($attribute->getAttributeCode() == 'country_id') {
             $data['country'] = $address->getCountryModel()->getName();
             $data['country_id'] = $address->getCountryId();
         } else {
             if ($attribute->getAttributeCode() == 'region') {
                 $data['region'] = $address->getRegion();
             } else {
                 $dataModel = Mage_Customer_Model_Attribute_Data::factory($attribute, $address);
                 $attributeValue = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ONELINE);
                 if ($attribute->getFrontendInput() == 'multiline') {
                     $values = $dataModel->outputValue(Mage_Customer_Model_Attribute_Data::OUTPUT_FORMAT_ARRAY);
                     // explode lines
                     foreach ($values as $attributeIndex => $attributeVal) {
                         $key = sprintf('%s%d', $attribute->getAttributeCode(), $attributeIndex + 1);
                         $data[$key] = $attributeVal;
                     }
                 }
                 $data[$attribute->getAttributeCode()] = $attributeValue;
             }
         }
     }
     foreach ($data as $key => $value) {
         if (empty($value)) {
             continue;
         }
         $item->addCustomChild($key, $value);
     }
     return $this;
 }
Ejemplo n.º 24
0
 /**
  * Add cart details to XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $methodListXmlObj
  * @param string $code
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 protected function _addRatesToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $methodListXmlObj, $code = '')
 {
     $attributes = $code ? array('label' => $this->getCarrierName($code)) : array();
     return $methodListXmlObj->addCustomChild('method', null, $attributes)->addCustomChild('rates');
 }
Ejemplo n.º 25
0
 /**
  * Add total to totals XML
  *
  * @param Varien_Object $total
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
  * @return null
  */
 private function _addTotalToXml($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
         $totalsXml->addCustomChild(preg_replace('@[\\W]+@', '_', trim($total->getCode())), $this->_formatPrice($total), array('label' => strip_tags($total->getLabel())));
     }
 }
Ejemplo n.º 26
0
 /**
  * Add order chart data to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphOrderData
  */
 public function addOrderChartDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $this->_xmlObj = $xmlObj->addCustomChild('chart_data_details', null, array('id' => 'orders'));
     $this->_addAllStoreData();
     return $this;
 }
Ejemplo n.º 27
0
 /**
  * Add localization data to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xml
  * @return Mage_XmlConnect_Block_Configuration
  */
 protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
 {
     /** @var $translateHelper Mage_XmlConnect_Helper_Translate */
     $translateHelper = Mage::helper('xmlconnect/translate');
     $xml->addCustomChild('localization', Mage::helper('xmlconnect')->getActionUrl('xmlconnect/localization'), array('hash' => $translateHelper->getHash()));
     return $this;
 }
Ejemplo n.º 28
0
 /**
  * Add total to totals XML. Api version 23.
  *
  * @param Varien_Object $total
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXml
  * @return null
  */
 protected function _addTotalToXmlApi23($total, Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     if ($total instanceof Varien_Object && $total->getCode() && $total->getLabel() && $total->hasData('value')) {
         $totalsXml->addCustomChild('item', $this->_formatPrice($total), array('id' => preg_replace('@[\\W]+@', '_', trim($total->getCode())), 'label' => $totalsXml->escapeXml($total->getLabel())));
     }
 }
Ejemplo n.º 29
0
 /**
  * Add payment methods info to xml object
  *
  * @throw Mage_Core_Exception
  * @param Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj
  * @return Mage_XmlConnect_Block_Checkout_Payment_Method_List
  */
 protected function _buildPaymentMethods(Mage_XmlConnect_Model_Simplexml_Element $methodsXmlObj)
 {
     $methodArray = $this->_getPaymentMethodArray();
     $usedMethods = $sortedAvailableMethodCodes = $usedCodes = array();
     /**
      * Receive available methods for checkout
      */
     $allAvailableMethods = Mage::helper('payment')->getStoreMethods(Mage::app()->getStore(), $this->getQuote());
     $total = $this->getQuote()->getGrandTotal();
     foreach ($allAvailableMethods as $key => $method) {
         if ($this->_canUseMethod($method) && ($total != 0 || $method->getCode() == 'free' || $this->getQuote()->hasRecurringItems() && $method->canManageRecurringProfiles())) {
             $this->_assignMethod($method);
         } else {
             unset($allAvailableMethods[$key]);
         }
     }
     /**
      * Get sorted codes of available methods
      */
     foreach ($allAvailableMethods as $method) {
         $sortedAvailableMethodCodes[] = $method->getCode();
     }
     /**
      * Get blocks for layout to check available renderers
      */
     $methodBlocks = $this->getChild();
     /**
      * Collect directly supported by xmlconnect methods
      */
     if (!empty($methodBlocks) && is_array($methodBlocks)) {
         foreach ($methodBlocks as $block) {
             if (!$block) {
                 continue;
             }
             $method = $block->getMethod();
             if (!$this->_canUseMethod($method) || in_array($method->getCode(), $usedCodes)) {
                 continue;
             }
             $this->_assignMethod($method);
             $usedCodes[] = $method->getCode();
             $usedMethods[$method->getCode()] = array('renderer' => $block, 'method' => $method);
         }
     }
     /**
      * Collect all "Credit Card" / "CheckMo" / "Purchaseorder" method compatible methods
      */
     foreach ($methodArray as $methodName => $methodModelClassName) {
         $methodRenderer = $this->getChild($methodName);
         if (!empty($methodRenderer)) {
             foreach ($sortedAvailableMethodCodes as $methodCode) {
                 /**
                  * Skip used methods
                  */
                 if (in_array($methodCode, $usedCodes)) {
                     continue;
                 }
                 try {
                     $method = Mage::helper('payment')->getMethodInstance($methodCode);
                     if (!is_subclass_of($method, $methodModelClassName)) {
                         continue;
                     }
                     if (!$this->_canUseMethod($method)) {
                         continue;
                     }
                     $this->_assignMethod($method);
                     $usedCodes[] = $method->getCode();
                     $usedMethods[$method->getCode()] = array('renderer' => $methodRenderer, 'method' => $method);
                 } catch (Exception $e) {
                     Mage::logException($e);
                 }
             }
         }
     }
     /**
      * Generate methods XML according to sort order
      */
     foreach ($sortedAvailableMethodCodes as $code) {
         if (!in_array($code, $usedCodes)) {
             continue;
         }
         $method = $usedMethods[$code]['method'];
         $renderer = $usedMethods[$code]['renderer'];
         /**
          * Render all Credit Card method compatible methods
          */
         if ($renderer instanceof Mage_XmlConnect_Block_Checkout_Payment_Method_Ccsave) {
             $renderer->setData('method', $method);
         }
         $options = array('id' => $method->getCode(), 'code' => $method->getCode(), 'post_name' => 'payment[method]', 'label' => $methodsXmlObj->escapeXml($method->getTitle()));
         if ($this->getQuote()->getPayment()->getMethod() == $method->getCode()) {
             $options['selected'] = 1;
         }
         $methodItemXmlObj = $methodsXmlObj->addCustomChild('method', null, $options);
         $renderer->addPaymentFormToXmlObj($methodItemXmlObj);
     }
     if (count($allAvailableMethods) == 1 && isset($sortedAvailableMethodCodes[0]) && $sortedAvailableMethodCodes[0] == 'free') {
         if ($this->_isPaymentRequired()) {
             $this->_addFreePaymentToXmlObj($methodsXmlObj);
         }
     }
     if (!count($allAvailableMethods)) {
         Mage::throwException($this->__('Your order cannot be completed at this time as there is no payment methods available for it.'));
     }
     return $this;
 }
 /**
  * Add product block to cart
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObject
  * @param Mage_Sales_Model_Quote $quote
  * @return null
  */
 public function addCartProductsToXmlObj($xmlObject, $quote)
 {
     $productSmallImageSize = Mage::getModel('xmlconnect/images')->getImageLimitParam('content/product_small');
     $products = $xmlObject->addCustomChild('products');
     /* @var $item Mage_Sales_Model_Quote_Item */
     foreach ($this->getItems() as $item) {
         $type = $item->getProductType();
         $renderer = $this->getItemRenderer($type)->setItem($item);
         /**
          * General information
          */
         $itemXml = $products->addCustomChild('item', null, array('entity_id' => $item->getProduct()->getId()));
         $itemXml->addCustomChild('entity_type', $type);
         $itemXml->addCustomChild('item_id', $item->getId());
         $itemXml->addCustomChild('name', $xmlObject->escapeXml($renderer->getProductName()));
         $itemXml->addCustomChild('code', 'cart[' . $item->getId() . '][qty]');
         $itemXml->addCustomChild('qty', $renderer->getQty());
         $icon = $renderer->getProductThumbnail()->resize($productSmallImageSize);
         $iconXml = $itemXml->addChild('icon', $icon);
         $iconXml->addAttribute('modification_time', filemtime($icon->getNewFile()));
         /**
          * Price
          */
         $pricesXmlObj = $itemXml->addCustomChild('price_list');
         $exclPrice = $inclPrice = 0;
         if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
             if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) {
                 $exclPrice = $item->getCalculationPrice() + $item->getWeeeTaxAppliedAmount() + $item->getWeeeTaxDisposition();
             } else {
                 $exclPrice = $item->getCalculationPrice();
             }
         }
         if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
             $incl = $this->helper('checkout')->getPriceInclTax($item);
             if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) {
                 $inclPrice = $incl + $item->getWeeeTaxAppliedAmount();
             } else {
                 $inclPrice = $incl - $item->getWeeeTaxDisposition();
             }
         }
         $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
         $paypalPrice = Mage::helper('xmlconnect')->formatPriceForXml($item->getCalculationPrice());
         $formattedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
         $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
         $formattedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
         $priceXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'price'));
         if ($this->helper('tax')->displayCartBothPrices()) {
             $priceXmlObj->addCustomChild('price', $exclPrice, array('id' => 'excluding_tax', 'label' => $this->__('Excl. Tax'), 'formatted_value' => $formattedExclPrice));
             $priceXmlObj->addCustomChild('price', $inclPrice, array('id' => 'including_tax', 'label' => $this->__('Incl. Tax'), 'formatted_value' => $formattedInclPrice));
         } else {
             if ($this->helper('tax')->displayCartPriceExclTax()) {
                 $priceXmlObj->addCustomChild('price', $exclPrice, array('id' => 'regular', 'label' => $this->__('Unit Price'), 'formatted_value' => $formattedExclPrice));
             }
             if ($this->helper('tax')->displayCartPriceInclTax()) {
                 $priceXmlObj->addCustomChild('price', $inclPrice, array('id' => 'regular', 'label' => $this->__('Unit Price'), 'formatted_value' => $formattedInclPrice));
             }
         }
         /**
          * Info for paypal MEP if it's enabled
          */
         $appConfig = Mage::helper('xmlconnect')->getApplication()->loadConfiguration()->getRenderConf();
         $isMepActive = $appConfig['paypal']['isActive'];
         $paypalMepIsAvailable = Mage::getModel('xmlconnect/payment_method_paypal_mep')->isAvailable(null);
         if ($paypalMepIsAvailable && $isMepActive) {
             $paypalPriceXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'paypal'));
             $paypalPriceXmlObj->addCustomChild('price', $paypalPrice, array('id' => 'regular', 'label' => $this->__('Unit Price'), 'formatted_value' => $quote->getStore()->formatPrice($paypalPrice, false)));
             $paypalSubtotalPrice = Mage::helper('xmlconnect')->formatPriceForXml($item->getRowTotal());
             $paypalPriceXmlObj->addCustomChild('price', $paypalSubtotalPrice, array('id' => 'subtotal', 'label' => $this->__('Subtotal'), 'formatted_value' => $quote->getStore()->formatPrice($paypalSubtotalPrice, false)));
         }
         /**
          * Subtotal
          */
         $subtotalExclTax = $subtotalInclTax = 0;
         if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
             if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) {
                 $subtotalExclTax = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition();
             } else {
                 $subtotalExclTax = $item->getRowTotal();
             }
         }
         if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
             $incl = $this->helper('checkout')->getSubtotalInclTax($item);
             if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) {
                 $subtotalInclTax = $incl + $item->getWeeeTaxAppliedRowAmount();
             } else {
                 $subtotalInclTax = $incl - $item->getWeeeTaxRowDisposition();
             }
         }
         $subtotalExclTax = Mage::helper('xmlconnect')->formatPriceForXml($subtotalExclTax);
         $formattedSubtotalExcl = $quote->getStore()->formatPrice($subtotalExclTax, false);
         $subtotalInclTax = Mage::helper('xmlconnect')->formatPriceForXml($subtotalInclTax);
         $formattedSubtotalIncl = $quote->getStore()->formatPrice($subtotalInclTax, false);
         $priceXmlObj = $pricesXmlObj->addCustomChild('prices', null, array('id' => 'subtotal'));
         if ($this->helper('tax')->displayCartBothPrices()) {
             $priceXmlObj->addCustomChild('price', $subtotalExclTax, array('id' => 'excluding_tax', 'label' => $this->__('Subtotal Excl. Tax'), 'formatted_value' => $formattedSubtotalExcl));
             $priceXmlObj->addCustomChild('price', $subtotalInclTax, array('id' => 'including_tax', 'label' => $this->__('Subtotal Incl. Tax'), 'formatted_value' => $formattedSubtotalIncl));
         } else {
             if ($this->helper('tax')->displayCartPriceExclTax()) {
                 $priceXmlObj->addCustomChild('price', $subtotalExclTax, array('id' => 'regular', 'label' => $this->__('Subtotal'), 'formatted_value' => $formattedSubtotalExcl));
             }
             if ($this->helper('tax')->displayCartPriceInclTax()) {
                 $priceXmlObj->addCustomChild('price', $subtotalInclTax, array('id' => 'regular', 'label' => $this->__('Subtotal'), 'formatted_value' => $formattedSubtotalIncl));
             }
         }
         /**
          * Options list
          */
         $options = $renderer->getOptionList();
         if ($options) {
             $itemOptionsXml = $itemXml->addCustomChild('options');
             foreach ($options as $_option) {
                 $formattedOptionValue = $renderer->getFormatedOptionValue($_option);
                 $itemOptionsXml->addCustomChild('option', null, array('label' => $xmlObject->xmlAttribute($_option['label']), 'text' => $xmlObject->xmlAttribute($formattedOptionValue['value'])));
             }
         }
         /**
          * Downloadable products
          */
         $links = $renderer->getLinks();
         if ($links) {
             $itemOptionsXml = $itemXml->addCustomChild('options', null, array('label' => $renderer->getLinksTitle()));
             foreach ($links as $link) {
                 $itemOptionsXml->addCustomChild('option', null, array('label' => $link->getTitle()));
             }
         }
         /**
          * Item messages
          */
         $messages = $renderer->getMessages();
         if ($messages) {
             $itemMessagesXml = $itemXml->addCustomChild('messages');
             foreach ($messages as $message) {
                 $messageXml = $itemMessagesXml->addCustomChild('option');
                 $messageXml->addCustomChild('type', $message['type']);
                 $messageXml->addCustomChild('text', $xmlObject->escapeXml($message['text']));
             }
         }
     }
 }