예제 #1
0
 /**
  * Add value and options to select
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Select
  */
 protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $value = $this->getEscapedValue();
     if ($value !== null) {
         $xmlObj->addAttribute('value', $xmlObj->xmlAttribute($value));
     }
     $this->_addOptions($xmlObj);
     return $this;
 }
 /**
  * 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));
         }
     }
 }
예제 #3
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:')));
         }
     }
 }
 /**
  * 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));
         }
     }
 }
예제 #5
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()));
 }
예제 #6
0
 /**
  * Add validator message for validator rule
  *
  * @throws Mage_Core_Exception
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Abstract
  */
 protected function _addMessage(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     if ($this->getMessage()) {
         $message = $this->getMessage();
     } elseif (array_key_exists($this->getType(), $this->getValidatorTypeMessages())) {
         $message = $this->_validatorTypeMessages[$this->getType()];
     } else {
         Mage::throwException(Mage::helper('xmlconnect')->__('"message" attribute is required for "%s" validator rule.', $this->getType()));
     }
     $xmlObj->addAttribute('message', $xmlObj->xmlAttribute($message));
     return $this;
 }
 /**
  * Add payment method info to order xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 protected function _addPaymentMethodInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj)
 {
     $order = $this->_getOrder();
     // TODO: it's need to create an info blocks for other payment methods (including Enterprise)
     $method = $this->helper('payment')->getInfoBlock($order->getPayment())->getMethod();
     $methodCode = $method->getCode();
     $paymentNode = $orderXmlObj->addChild('payment_method');
     if (in_array($methodCode, $this->_methodArray, true)) {
         $currentBlockRenderer = 'xmlconnect/checkout_payment_method_info_' . $methodCode;
         $currentBlockName = 'xmlconnect.checkout.payment.method.info.' . $methodCode;
         $this->getLayout()->addBlock($currentBlockRenderer, $currentBlockName);
         $this->setChild($methodCode, $currentBlockName);
         $renderer = $this->getChild($methodCode)->setInfo($order->getPayment());
         $renderer->addPaymentInfoToXmlObj($paymentNode);
     } else {
         $paymentNode->addAttribute('type', $methodCode);
         $paymentNode->addAttribute('title', $orderXmlObj->xmlAttribute($method->getTitle()));
         $this->setInfo($order->getPayment());
         $specificInfo = array_merge((array) $order->getPayment()->getAdditionalInformation(), (array) $this->getSpecificInformation());
         if (!empty($specificInfo)) {
             foreach ($specificInfo as $label => $value) {
                 if ($value) {
                     $paymentNode->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label));
                 }
             }
         }
     }
     return $orderXmlObj;
 }
예제 #8
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)
 {
     if ($this->getEscapedValue()) {
         $xmlObj->addAttribute('value', $xmlObj->xmlAttribute($this->getEscapedValue()));
     }
     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']));
             }
         }
     }
 }
예제 #10
0
 /**
  * Add form name to element
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Form_Abstract
  */
 protected function _addName(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     if ($this->getName()) {
         $name = $this->getName();
     } elseif ($this->getNameRequired()) {
         $name = $this->getXmlId();
     }
     if (isset($name)) {
         $xmlObj->addAttribute('name', $xmlObj->xmlAttribute($name));
     }
     return $this;
 }
예제 #11
0
 /**
  * Add Purchase Order 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()));
     $orderItemXmlObj->addCustomChild('item', $this->getInfo()->getPoNumber(), array('label' => Mage::helper('sales')->__('Purchase Order Number:')));
 }