예제 #1
0
 /**
  * Render shipping methods xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $methodsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<shipping_methods></shipping_methods>');
     $_shippingRateGroups = $this->getShippingRates();
     if ($_shippingRateGroups) {
         $store = $this->getQuote()->getStore();
         $_sole = count($_shippingRateGroups) == 1;
         foreach ($_shippingRateGroups as $code => $_rates) {
             $methodXmlObj = $methodsXmlObj->addChild('method');
             $methodXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($this->getCarrierName($code))));
             $ratesXmlObj = $methodXmlObj->addChild('rates');
             $_sole = $_sole && count($_rates) == 1;
             foreach ($_rates as $_rate) {
                 $rateXmlObj = $ratesXmlObj->addChild('rate');
                 $rateXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($_rate->getMethodTitle())));
                 $rateXmlObj->addAttribute('code', $_rate->getCode());
                 if ($_rate->getErrorMessage()) {
                     $rateXmlObj->addChild('error_message', $methodsXmlObj->xmlentities(strip_tags($_rate->getErrorMessage())));
                 } else {
                     $price = Mage::helper('tax')->getShippingPrice($_rate->getPrice(), Mage::helper('tax')->displayShippingPriceIncludingTax(), $this->getAddress());
                     $formattedPrice = $store->convertPrice($price, true, false);
                     $rateXmlObj->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml($store->convertPrice($price, false, false)));
                     $rateXmlObj->addAttribute('formated_price', $formattedPrice);
                 }
             }
         }
     } else {
         Mage::throwException($this->__('Sorry, no quotes are available for this order at this time.'));
     }
     return $methodsXmlObj->asNiceXml();
 }
예제 #2
0
 /**
  * Add order totals rendered to XML object
  * (get from template: sales/order/totals.phtml)
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj
  * @return null
  */
 public function addTotalsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj)
 {
     // all Enterprise renderers from layout update into array an realize checking of their using
     $enterpriseBlocks = array('reward.sales.order.total' => array('module' => 'Enterprise_Reward', 'block' => 'enterprise_reward/sales_order_total'), 'customerbalance' => array('module' => 'Enterprise_CustomerBalance', 'block' => 'xmlconnect/customer_order_totals_customerbalance', 'template' => 'customerbalance/order/customerbalance.phtml'), 'customerbalance_total_refunded' => array('module' => 'Enterprise_CustomerBalance', 'block' => 'xmlconnect/customer_order_totals_customerbalance_refunded', 'template' => 'customerbalance/order/customerbalance_refunded.phtml', 'after' => '-', 'action' => array('method' => 'setAfterTotal', 'value' => 'grand_total')), 'giftwrapping' => array('module' => 'Enterprise_GiftWrapping', 'block' => 'enterprise_giftwrapping/sales_totals'), 'giftcards' => array('module' => 'Enterprise_GiftCardAccount', 'block' => 'xmlconnect/customer_order_totals_giftcards', 'template' => 'giftcardaccount/order/giftcards.phtml'));
     foreach ($enterpriseBlocks as $name => $block) {
         // create blocks only for Enterprise/Pro modules which is in system
         if (is_object(Mage::getConfig()->getNode('modules/' . $block['module']))) {
             $blockInstance = $this->getLayout()->createBlock($block['block'], $name);
             $this->setChild($name, $blockInstance);
             if (isset($block['action']['method']) && isset($block['action']['value'])) {
                 $method = $block['action']['method'];
                 $blockInstance->{$method}($block['action']['value']);
             }
         }
     }
     $this->_beforeToHtml();
     $totalsXml = $orderXmlObj->addChild('totals');
     foreach ($this->getTotals() as $total) {
         if ($total->getValue()) {
             $total->setValue(strip_tags($total->getValue()));
         }
         if ($total->getBlockName()) {
             $block = $this->getLayout()->getBlock($total->getBlockName());
             if (is_object($block)) {
                 if (method_exists($block, 'addToXmlObject')) {
                     $block->setTotal($total)->addToXmlObject($totalsXml);
                 } else {
                     $this->_addTotalToXml($total, $totalsXml);
                 }
             }
         } else {
             $this->_addTotalToXml($total, $totalsXml);
         }
     }
 }
예제 #3
0
 /**
  * Generate images gallery xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $productId = $this->getRequest()->getParam('id', null);
     $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($productId);
     $collection = $product->getMediaGalleryImages();
     $imagesNode = new Mage_XmlConnect_Model_Simplexml_Element('<images></images>');
     $helper = $this->helper('catalog/image');
     foreach ($collection as $item) {
         $imageNode = $imagesNode->addChild('image');
         /**
          * Big image
          */
         $bigImage = $helper->init($product, 'image', $item->getFile())->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_gallery_big'));
         $fileNode = $imageNode->addChild('file');
         $fileNode->addAttribute('type', 'big');
         $fileNode->addAttribute('url', $bigImage);
         $file = Mage::helper('xmlconnect')->urlToPath($bigImage);
         $fileNode->addAttribute('id', ($id = $item->getId()) ? (int) $id : 0);
         $fileNode->addAttribute('modification_time', filemtime($file));
         /**
          * Small image
          */
         $smallImage = $helper->init($product, 'thumbnail', $item->getFile())->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_gallery_small'));
         $fileNode = $imageNode->addChild('file');
         $fileNode->addAttribute('type', 'small');
         $fileNode->addAttribute('url', $smallImage);
         $file = Mage::helper('xmlconnect')->urlToPath($smallImage);
         $fileNode->addAttribute('modification_time', filemtime($file));
     }
     return $imagesNode->asNiceXml();
 }
예제 #4
0
 /**
  * Render cross sell items xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $crossSellXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<crosssell></crosssell>');
     if (!$this->getItemCount()) {
         return $crossSellXmlObj->asNiceXml();
     }
     foreach ($this->getItems() as $_item) {
         $itemXmlObj = $crossSellXmlObj->addChild('item');
         $itemXmlObj->addChild('name', $crossSellXmlObj->xmlentities(strip_tags($_item->getName())));
         $icon = $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
         $iconXml = $itemXmlObj->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
         $itemXmlObj->addChild('entity_id', $_item->getId());
         $itemXmlObj->addChild('entity_type', $_item->getTypeId());
         $itemXmlObj->addChild('has_options', (int) $_item->getHasOptions());
         if ($this->getChild('product_price')) {
             $this->getChild('product_price')->setProduct($_item)->setProductXmlObj($itemXmlObj)->collectProductPrices();
         }
         if (!$_item->getRatingSummary()) {
             Mage::getModel('review/review')->getEntitySummary($_item, Mage::app()->getStore()->getId());
         }
         $itemXmlObj->addChild('rating_summary', round((int) $_item->getRatingSummary()->getRatingSummary() / 10));
         $itemXmlObj->addChild('reviews_count', $_item->getRatingSummary()->getReviewsCount());
     }
     return $crossSellXmlObj->asNiceXml();
 }
예제 #5
0
    /**
     * Add cc save payment method form to payment XML object
     *
     * @param Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj
     * @return Mage_XmlConnect_Model_Simplexml_Element
     */
    public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj)
    {
        $helper = Mage::helper('xmlconnect');
        $method = $this->getMethod();
        if (!$method) {
            return $paymentItemXmlObj;
        }
        $formXmlObj = $paymentItemXmlObj->addChild('form');
        $formXmlObj->addAttribute('name', 'payment_form_' . $method->getCode());
        $formXmlObj->addAttribute('method', 'post');
        $owner = $this->getInfoData('cc_owner');
        $ccTypes = $helper->getArrayAsXmlItemValues($this->getCcAvailableTypes(), $this->getInfoData('cc_type'));
        $ccMonthArray = $this->getCcMonths();
        $ccMonths = $helper->getArrayAsXmlItemValues($ccMonthArray, $this->getInfoData('cc_exp_month'));
        $ccYears = $helper->getArrayAsXmlItemValues($this->getCcYears(), $this->getInfoData('cc_exp_year'));
        $verification = '';
        if ($this->hasVerification()) {
            $verification = '<field name="payment[cc_cid]" type="text" label="' . $this->__('Card Verification Number') . '" required="true">
                <validators>
                    <validator relation="payment[cc_type]" type="credit_card_svn" message="' . $this->__('Card verification number is wrong') . '"/>
                </validators>
            </field>';
        }
        $solo = '';
        if ($this->hasSsCardType()) {
            $ssCcMonths = $helper->getArrayAsXmlItemValues($ccMonthArray, $this->getInfoData('cc_ss_start_month'));
            $ssCcYears = $helper->getArrayAsXmlItemValues($this->getSsStartYears(), $this->getInfoData('cc_ss_start_year'));
            $solo = $helper->getSoloXml($ssCcMonths, $ssCcYears);
        }
        $xml = <<<EOT
    <fieldset>
        <field name="payment[cc_owner]" type="text" label="{$this->__('Name on Card')}" value="{$owner}" required="true" />
        <field name="payment[cc_type]" type="select" label="{$this->__('Credit Card Type')}" required="true">
            <values>
                {$ccTypes}
            </values>
            {$solo}
        </field>
        <field name="payment[cc_number]" type="text" label="{$this->__('Credit Card Number')}" required="true">
            <validators>
                <validator relation="payment[cc_type]" type="credit_card" message="{$this->__('Credit card number does not match credit card type.')}"/>
            </validators>
        </field>
        <field name="payment[cc_exp_month]" type="select" label="{$this->__('Expiration Date - Month')}" required="true">
            <values>
                {$ccMonths}
            </values>
        </field>
        <field name="payment[cc_exp_year]" type="select" label="{$this->__('Expiration Date - Year')}" required="true">
            <values>
                {$ccYears}
            </values>
        </field>
        {$verification}
    </fieldset>
EOT;
        $fieldsetXmlObj = Mage::getModel('xmlconnect/simplexml_element', $xml);
        $formXmlObj->appendChild($fieldsetXmlObj);
    }
예제 #6
0
 /**
  * Render cart summary xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $quote = $this->getQuote();
     $xmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<cart></cart>');
     $xmlObject->addChild('is_virtual', (int) $this->helper('checkout/cart')->getIsVirtualQuote());
     $xmlObject->addChild('summary_qty', (int) $this->helper('checkout/cart')->getSummaryCount());
     $xmlObject->addChild('virtual_qty', (int) $quote->getItemVirtualQty());
     if (strlen($quote->getCouponCode())) {
         $xmlObject->addChild('has_coupon_code', 1);
     }
     $totalsXml = $this->getChildHtml('totals');
     if ($totalsXml) {
         $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($totalsXml);
         $xmlObject->appendChild($totalsXmlObj);
     }
     return $xmlObject->asNiceXml();
 }
예제 #7
0
 /**
  * Render customer wishlist xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $wishlistXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<wishlist></wishlist>');
     $hasMoreItems = 0;
     /**
      * Apply offset and count
      */
     $request = $this->getRequest();
     $offset = (int) $request->getParam('offset', 0);
     $count = (int) $request->getParam('count', 0);
     $count = $count <= 0 ? 1 : $count;
     if ($offset + $count < $this->getWishlistItems()->getSize()) {
         $hasMoreItems = 1;
     }
     $this->getWishlistItems()->getSelect()->limit($count, $offset);
     $wishlistXmlObj->addAttribute('items_count', $this->getWishlistItemsCount());
     $wishlistXmlObj->addAttribute('has_more_items', $hasMoreItems);
     if ($this->hasWishlistItems()) {
         /**
          * @var Mage_Wishlist_Model_Mysql4_Product_Collection
          */
         foreach ($this->getWishlistItems() as $item) {
             $itemXmlObj = $wishlistXmlObj->addChild('item');
             $itemXmlObj->addChild('item_id', $item->getWishlistItemId());
             $itemXmlObj->addChild('entity_id', $item->getProductId());
             $itemXmlObj->addChild('entity_type_id', $item->getProduct()->getTypeId());
             $itemXmlObj->addChild('name', $wishlistXmlObj->xmlentities(strip_tags($item->getName())));
             $itemXmlObj->addChild('in_stock', (int) $item->getProduct()->isInStock());
             $itemXmlObj->addChild('is_salable', (int) $item->getProduct()->getIsSalable());
             /**
              * If product type is grouped than it has options as its grouped items
              */
             if ($item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE) {
                 $item->setHasOptions(true);
             }
             $itemXmlObj->addChild('has_options', (int) $item->getHasOptions());
             $icon = $this->helper('catalog/image')->init($item->getProduct(), 'small_image')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
             $iconXml = $itemXmlObj->addChild('icon', $icon);
             $file = Mage::helper('xmlconnect')->urlToPath($icon);
             $iconXml->addAttribute('modification_time', filemtime($file));
             $description = $wishlistXmlObj->xmlentities(strip_tags($item->getDescription()));
             $itemXmlObj->addChild('description', $description);
             $addedDate = $wishlistXmlObj->xmlentities($this->getFormatedDate($item->getAddedAt()));
             $itemXmlObj->addChild('added_date', $addedDate);
             if ($this->getChild('product_price')) {
                 $this->getChild('product_price')->setProduct($item->getProduct())->setProductXmlObj($itemXmlObj)->collectProductPrices();
             }
             if (!$item->getProduct()->getRatingSummary()) {
                 Mage::getModel('review/review')->getEntitySummary($item->getProduct(), Mage::app()->getStore()->getId());
             }
             $ratingSummary = (int) $item->getProduct()->getRatingSummary()->getRatingSummary();
             $itemXmlObj->addChild('rating_summary', round($ratingSummary / 10));
             $itemXmlObj->addChild('reviews_count', $item->getProduct()->getRatingSummary()->getReviewsCount());
         }
     }
     return $wishlistXmlObj->asNiceXml();
 }
 /**
  * Add cart details to XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function addDetailsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
 {
     $itemsXmlObj = $reviewXmlObj->addChild('ordered_items');
     foreach ($this->getItems() as $item) {
         $this->getItemXml($item, $itemsXmlObj);
     }
     $reviewXmlObj->appendChild($this->getChild('totals')->setReturnObjectFlag(true)->_toHtml());
     return $reviewXmlObj;
 }
예제 #9
0
 /**
  * Render cart totals xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $paypalCart = Mage::getModel('paypal/cart', array($this->getQuote()));
     $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<cart_totals></cart_totals>');
     foreach ($paypalCart->getTotals(true) as $code => $amount) {
         $currencyAmount = $this->helper('core')->currency($amount, false, false);
         $totalsXmlObj->addChild($code, sprintf('%01.2F', $currencyAmount));
     }
     return $totalsXmlObj->asNiceXml();
 }
예제 #10
0
 /**
  * Render home category list xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $homeXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<home></home>');
     $categoryCollection = Mage::getResourceModel('xmlconnect/category_collection');
     $categoryCollection->setStoreId(Mage::app()->getStore()->getId())->addParentIdFilter(Mage::app()->getStore()->getRootCategoryId())->setOrder('position', 'ASC')->setLimit(0, self::HOME_PAGE_CATEGORIES_COUNT);
     if (sizeof($categoryCollection)) {
         $itemsXmlObj = $homeXmlObj->addChild('categories');
     }
     foreach ($categoryCollection->getItems() as $item) {
         $itemXmlObj = $itemsXmlObj->addChild('item');
         $itemXmlObj->addChild('label', $homeXmlObj->xmlentities(strip_tags($item->getName())));
         $itemXmlObj->addChild('entity_id', $item->getEntityId());
         $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
         $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category'));
         $iconXml = $itemXmlObj->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
     }
     $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png');
     return $homeXmlObj->asNiceXml();
 }
예제 #11
0
 /**
  * Collect product prices to specified item xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  */
 public function collectProductPrices(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     $this->setProduct($product);
     if ($product->getCanShowPrice() !== false) {
         $priceXmlObj = $item->addChild('price');
         if (($_min = $this->getMinAmount()) && ($_max = $this->getMaxAmount()) && $_min == $_max) {
             $priceXmlObj->addAttribute('regular', Mage::helper('core')->currency($_min, true, false));
         } elseif (($_min = $this->getMinAmount()) && $_min != 0) {
             $priceXmlObj->addAttribute('regular', Mage::helper('enterprise_giftcard')->__('From') . ': ' . Mage::helper('core')->currency($_min, true, false));
         }
     }
 }
예제 #12
0
 /**
  * Recursively build XML configuration tree
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $section
  * @param array $subTree
  * @return Mage_XmlConnect_Block_Configuration
  */
 protected function _buildRecursive($section, $subTree)
 {
     Mage::helper('xmlconnect')->getDeviceHelper()->checkRequiredConfigFields($subTree);
     foreach ($subTree as $key => $value) {
         if (is_array($value)) {
             if ($key == 'fonts') {
                 $subSection = $section->addChild('fonts');
                 foreach ($value as $label => $val) {
                     if (empty($val['name']) || empty($val['size']) || empty($val['color'])) {
                         continue;
                     }
                     $font = $subSection->addChild('font');
                     $font->addAttribute('label', $label);
                     $font->addAttribute('name', $val['name']);
                     $font->addAttribute('size', $val['size']);
                     $font->addAttribute('color', $val['color']);
                 }
             } elseif ($key == 'pages') {
                 $subSection = $section->addChild('content');
                 foreach ($value as $page) {
                     $this->_buildRecursive($subSection->addChild('page'), $page);
                 }
             } else {
                 $subSection = $section->addChild($key);
                 $this->_buildRecursive($subSection, $value);
             }
         } elseif ($value instanceof Mage_XmlConnect_Model_Tabs) {
             foreach ($value->getRenderTabs() as $tab) {
                 $subSection = $section->addChild('tab');
                 $this->_buildRecursive($subSection, $tab);
             }
         } else {
             $value = (string) $value;
             if ($value != '') {
                 $section->addChild($key, Mage::helper('core')->escapeHtml($value));
             }
         }
     }
     return $this;
 }
예제 #13
0
 /**
  * Retrieve review data as xml object
  *
  * @param Mage_Review_Model_Review $review
  * @param string $itemNodeName
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function reviewToXmlObject(Mage_Review_Model_Review $review, $itemNodeName = 'item')
 {
     $rating = 0;
     $item = new Mage_XmlConnect_Model_Simplexml_Element('<' . $itemNodeName . '></' . $itemNodeName . '>');
     if ($review->getId()) {
         $item->addChild('review_id', $review->getId());
         $item->addChild('created_at', $this->formatDate($review->getCreatedAt()));
         $item->addChild('title', $item->xmlentities(strip_tags($review->getTitle())));
         $item->addChild('nickname', $item->xmlentities(strip_tags($review->getNickname())));
         $detail = $item->xmlentities($review->getDetail());
         if ($itemNodeName == 'item') {
             $remainder = '';
             $deviceType = Mage::helper('xmlconnect')->getDeviceType();
             if ($deviceType != Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD) {
                 $detail = Mage::helper('core/string')->truncate($detail, self::REVIEW_DETAIL_TRUNCATE_LEN, '', $remainder, false);
             }
         }
         $item->addChild('detail', $detail);
         $summary = Mage::getModel('rating/rating')->getReviewSummary($review->getId());
         if ($summary->getCount() > 0) {
             $rating = round($summary->getSum() / $summary->getCount() / 10);
         }
         if ($rating) {
             $item->addChild('rating_votes', $rating);
         }
     }
     return $item;
 }
예제 #14
0
 /**
  * Recursively build XML configuration tree
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $section
  * @param array $subtree
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 protected function _buildRecursive($section, $subtree)
 {
     foreach ($subtree as $key => $value) {
         if (is_array($value)) {
             if ($key == 'fonts') {
                 $subsection = $section->addChild('fonts');
                 foreach ($value as $label => $v) {
                     if (empty($v['name']) || empty($v['size']) || empty($v['color'])) {
                         continue;
                     }
                     $font = $subsection->addChild('font');
                     $font->addAttribute('label', $label);
                     $font->addAttribute('name', $v['name']);
                     $font->addAttribute('size', $v['size']);
                     $font->addAttribute('color', $v['color']);
                 }
             } elseif ($key == 'pages') {
                 $subsection = $section->addChild('content');
                 foreach ($value as $page) {
                     $this->_buildRecursive($subsection->addChild('page'), $page);
                 }
             } else {
                 $subsection = $section->addChild($key);
                 $this->_buildRecursive($subsection, $value);
             }
         } elseif ($value instanceof Mage_XmlConnect_Model_Tabs) {
             foreach ($value->getRenderTabs() as $tab) {
                 $subsection = $section->addChild('tab');
                 $this->_buildRecursive($subsection, $tab);
             }
         } else {
             $value = (string) $value;
             if ($value != '') {
                 $section->addChild($key, Mage::helper('core')->htmlEscape($value));
             }
         }
     }
 }
예제 #15
0
 /**
  * Produce category info xml object
  *
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function getCategoryInfoXmlObject()
 {
     $infoXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<category_info></category_info>');
     $category = $this->getCategory();
     if ($category && is_object($category) && $category->getId()) {
         /**
          * @var string $title
          *
          * Copied data from "getDefaultApplicationDesignTabs()" method in "Mage_XmlConnect_Helper_Data"
          */
         $title = $this->__('Shop');
         if ($category->getParentCategory()->getLevel() > 1) {
             $title = $infoXmlObj->xmlentities(strip_tags($category->getParentCategory()->getName()));
         }
         $infoXmlObj->addChild('parent_title', $title);
         $pId = 0;
         if ($category->getLevel() > 1) {
             $pId = $category->getParentId();
         }
         $infoXmlObj->addChild('parent_id', $pId);
     }
     return $infoXmlObj;
 }
예제 #16
0
 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     $categoryXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<category></category>');
     $categoryId = $this->getRequest()->getParam('id', null);
     if ($categoryId === null) {
         $categoryId = Mage::app()->getStore()->getRootCategoryId();
     }
     $productsXmlObj = $productListBlock = false;
     $categoryModel = Mage::getModel('catalog/category')->load($categoryId);
     if ($categoryModel->getId()) {
         $hasMoreProductItems = 0;
         $productListBlock = $this->getChild('product_list');
         if ($productListBlock && $categoryModel->getLevel() > 1) {
             $layer = Mage::getSingleton('catalog/layer');
             $productsXmlObj = $productListBlock->setCategory($categoryModel)->setLayer($layer)->getProductsXmlObject();
             $hasMoreProductItems = (int) $productListBlock->getHasProductItems();
         }
         $infoBlock = $this->getChild('category_info');
         if ($infoBlock) {
             $categoryInfoXmlObj = $infoBlock->setCategory($categoryModel)->getCategoryInfoXmlObject();
             $categoryInfoXmlObj->addChild('has_more_items', $hasMoreProductItems);
             $categoryXmlObj->appendChild($categoryInfoXmlObj);
         }
     }
     /** @var $categoryCollection Mage_XmlConnect_Model_Mysql4_Category_Collection */
     $categoryCollection = Mage::getResourceModel('xmlconnect/category_collection');
     $categoryCollection->setStoreId(Mage::app()->getStore()->getId())->setOrder('position', 'ASC')->addParentIdFilter($categoryId);
     // subcategories are exists
     if (sizeof($categoryCollection)) {
         $itemsXmlObj = $categoryXmlObj->addChild('items');
         foreach ($categoryCollection->getItems() as $item) {
             $itemXmlObj = $itemsXmlObj->addChild('item');
             $itemXmlObj->addChild('label', $categoryXmlObj->xmlentities(strip_tags($item->getName())));
             $itemXmlObj->addChild('entity_id', $item->getEntityId());
             $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
             if (!is_null($categoryId)) {
                 $itemXmlObj->addChild('parent_id', $item->getParentId());
             }
             $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category'));
             $iconXml = $itemXmlObj->addChild('icon', $icon);
             $file = Mage::helper('xmlconnect')->urlToPath($icon);
             $iconXml->addAttribute('modification_time', filemtime($file));
         }
     }
     if ($productListBlock && $productsXmlObj) {
         $categoryXmlObj->appendChild($productsXmlObj);
     }
     return $categoryXmlObj->asNiceXml();
 }
예제 #17
0
 /**
  * Create produc custom options Mage_XmlConnect_Model_Simplexml_Element object
  *
  * @param Mage_Catalog_Model_Product $product
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function getProductCustomOptionsXmlObject(Mage_Catalog_Model_Product $product)
 {
     $xmlModel = new Mage_XmlConnect_Model_Simplexml_Element('<product></product>');
     $optionsNode = $xmlModel->addChild('options');
     if (!$product->getId()) {
         return $xmlModel;
     }
     $xmlModel->addAttribute('id', $product->getId());
     if (!$product->isSaleable() || !sizeof($product->getOptions())) {
         return $xmlModel;
     }
     foreach ($product->getOptions() as $option) {
         $optionNode = $optionsNode->addChild('option');
         $type = $this->_getOptionTypeForXmlByRealType($option->getType());
         $code = 'options[' . $option->getId() . ']';
         if ($type == self::OPTION_TYPE_CHECKBOX) {
             $code .= '[]';
         }
         $optionNode->addAttribute('code', $code);
         $optionNode->addAttribute('type', $type);
         $optionNode->addAttribute('label', $xmlModel->xmlentities(strip_tags($option->getTitle())));
         if ($option->getIsRequire()) {
             $optionNode->addAttribute('is_required', 1);
         }
         /**
          * Process option price
          */
         $price = Mage::helper('xmlconnect')->formatPriceForXml($option->getPrice());
         if ($price > 0.0) {
             $optionNode->addAttribute('price', $price);
             $formatedPrice = Mage::app()->getStore($product->getStoreId())->formatPrice($price, false);
             $optionNode->addAttribute('formated_price', $formatedPrice);
         }
         if ($type == self::OPTION_TYPE_CHECKBOX || $type == self::OPTION_TYPE_SELECT) {
             foreach ($option->getValues() as $value) {
                 $valueNode = $optionNode->addChild('value');
                 $valueNode->addAttribute('code', $value->getId());
                 $valueNode->addAttribute('label', $xmlModel->xmlentities(strip_tags($value->getTitle())));
                 $price = Mage::helper('xmlconnect')->formatPriceForXml($value->getPrice());
                 if ($price > 0.0) {
                     $valueNode->addAttribute('price', $price);
                     $formatedPrice = $this->_formatPriceString($price, $product);
                     $valueNode->addAttribute('formated_price', $formatedPrice);
                 }
             }
         }
     }
     return $xmlModel;
 }
예제 #18
0
 /**
  * Add additional information (attributes) to current product xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_XmlConnect_Model_Simplexml_Element $productXmlObject
  *  
  */
 public function addAdditionalData(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $productXmlObject)
 {
     if ($product && $productXmlObject && $product->getId()) {
         $this->_product = $product;
         $additionalData = $this->getAdditionalData();
         if (!empty($additionalData)) {
             $attributesXmlObj = $productXmlObject->addChild('additional_attributes');
             foreach ($additionalData as $data) {
                 $_attrXmlObject = $attributesXmlObj->addChild('item');
                 $_attrXmlObject->addChild('label', $this->htmlEscape($data['label']));
                 $_attrXmlObject->addChild('value', Mage::helper('catalog/output')->productAttribute($product, $data['value'], $data['code']));
             }
         }
     }
 }
예제 #19
0
 /**
  * Render cart totals xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $quote = $this->getQuote();
     $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<cart_totals></cart_totals>');
     list($items, $totals) = Mage::helper('paypal')->prepareLineItems($quote);
     if (Mage::helper('paypal')->areCartLineItemsValid($items, $totals, $quote->getBaseGrandTotal())) {
         foreach ($totals as $code => $amount) {
             $currencyAmount = $this->helper('core')->currency($amount, false, false);
             $totalsXmlObj->addChild($code, Mage::helper('xmlconnect')->formatPriceForXml($currencyAmount));
         }
     } else {
         Mage::throwException($this->__('Cart line items are not eligible for exporting to PayPal API'));
     }
     return $totalsXmlObj->asNiceXml();
 }
예제 #20
0
 /**
  * Render agreements xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $agreementsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<agreements></agreements>');
     if ($this->getAgreements()) {
         foreach ($this->getAgreements() as $agreement) {
             $itemXmlObj = $agreementsXmlObj->addChild('item');
             $content = $agreementsXmlObj->xmlentities($agreement->getContent());
             if (!$agreement->getIsHtml()) {
                 $content = nl2br(strip_tags($content));
             }
             $itemXmlObj->addChild('label', $agreementsXmlObj->xmlentities(strip_tags($agreement->getCheckboxText())));
             $itemXmlObj->addChild('content', $content);
             $itemXmlObj->addChild('code', 'agreement[' . $agreement->getId() . ']');
             $itemXmlObj->addChild('agreement_id', $agreement->getId());
         }
     }
     return $agreementsXmlObj->asNiceXml();
 }
예제 #21
0
 /**
  * Render billing shipping xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $shippingXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<shipping></shipping>');
     $addressId = $this->getAddress()->getId();
     $address = $this->getCustomer()->getPrimaryShippingAddress();
     if ($address) {
         $addressId = $address->getId();
     }
     foreach ($this->getCustomer()->getAddresses() as $address) {
         $item = $shippingXmlObj->addChild('item');
         if ($addressId == $address->getId()) {
             $item->addAttribute('selected', 1);
         }
         $this->getChild('address_list')->prepareAddressData($address, $item);
         $item->addChild('address_line', $shippingXmlObj->xmlentities($address->format('oneline')));
     }
     return $shippingXmlObj->asNiceXml();
 }
예제 #22
0
 /**
  * Retrieve product sort fields as xml object
  *
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function getProductSortFeildsXmlObject()
 {
     $ordersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<orders></orders>');
     /* @var $category Mage_Catalog_Model_Category */
     $category = Mage::getModel('catalog/category');
     $sortOptions = $category->getAvailableSortByOptions();
     $sortOptions = array_slice($sortOptions, 0, self::PRODUCT_SORT_FIELDS_NUMBER);
     $defaultSort = $category->getDefaultSortBy();
     foreach ($sortOptions as $code => $name) {
         $item = $ordersXmlObject->addChild('item');
         if ($code == $defaultSort) {
             $item->addAttribute('isDefault', 1);
         }
         $item->addChild('code', $code);
         $item->addChild('name', $ordersXmlObject->xmlentities(strip_tags($name)));
     }
     return $ordersXmlObject;
 }
예제 #23
0
 /**
  * Generate bundle product options xml
  *
  * @param Mage_Catalog_Model_Product $product
  * @param bool $isObject
  * @return string | Mage_XmlConnect_Model_Simplexml_Element
  */
 public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
 {
     $xmlModel = new Mage_XmlConnect_Model_Simplexml_Element('<product></product>');
     $optionsNode = $xmlModel->addChild('options');
     if (!$product->getId()) {
         return $isObject ? $xmlModel : $xmlModel->asNiceXml();
     }
     $xmlModel->addAttribute('id', $product->getId());
     if (!$product->isSaleable()) {
         return $isObject ? $xmlModel : $xmlModel->asNiceXml();
     }
     /**
      * Grouped (associated) products
      */
     $_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
     if (!sizeof($_associatedProducts)) {
         return $isObject ? $xmlModel : $xmlModel->asNiceXml();
     }
     foreach ($_associatedProducts as $_item) {
         if (!$_item->isSaleable()) {
             continue;
         }
         $optionNode = $optionsNode->addChild('option');
         $optionNode->addAttribute('code', 'super_group[' . $_item->getId() . ']');
         $optionNode->addAttribute('type', 'product');
         $optionNode->addAttribute('label', $xmlModel->xmlentities(strip_tags($_item->getName())));
         $optionNode->addAttribute('is_qty_editable', 1);
         $optionNode->addAttribute('qty', $_item->getQty() * 1);
         /**
          * Process product price
          */
         if ($_item->getPrice() != $_item->getFinalPrice()) {
             $productPrice = $_item->getFinalPrice();
         } else {
             $productPrice = $_item->getPrice();
         }
         $productPrice = Mage::helper('xmlconnect')->formatPriceForXml($productPrice);
         if ($productPrice != 0.0) {
             $optionNode->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(Mage::helper('core')->currency($productPrice, false, false)));
             $optionNode->addAttribute('formated_price', $this->_formatPriceString($productPrice, $product));
         }
     }
     return $isObject ? $xmlModel : $xmlModel->asNiceXml();
 }
예제 #24
0
    /**
     * Add payment method form to payment XML object
     *
     * @param Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj
     * @return Mage_XmlConnect_Model_Simplexml_Element
     */
    public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj)
    {
        $method = $this->getMethod();
        if (!$method) {
            return $paymentItemXmlObj;
        }
        $formXmlObj = $paymentItemXmlObj->addChild('form');
        $formXmlObj->addAttribute('name', 'payment_form_' . $method->getCode());
        $formXmlObj->addAttribute('method', 'post');
        $poNumber = $this->getInfoData('po_number');
        $xml = <<<EOT
    <fieldset>
        <field name="payment[po_number]" type="text" label="{$this->helper('xmlconnect')->__('Purchase Order Number')}" value="{$poNumber}" required="true" />
    </fieldset>
EOT;
        $fieldsetXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($xml);
        $formXmlObj->appendChild($fieldsetXmlObj);
        return $paymentItemXmlObj;
    }
예제 #25
0
 /**
  * Render XML for items
  * (get from template: sales/order/items.phtml)
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj
  * @return null
  */
 public function addItemsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj)
 {
     $itemsXml = $orderXmlObj->addChild('ordered_items');
     foreach ($this->getItems() as $item) {
         if ($item->getParentItem()) {
             // if Item is option of grouped product - do not render it
             continue;
         }
         $type = $this->_getItemType($item);
         // TODO: take out all Enterprise renderers from layout update into array an realize checking of their using
         // Check if the Enterprise_GiftCard module is available for rendering
         if ($type == 'giftcard' && !is_object(Mage::getConfig()->getNode('modules/Enterprise_GiftCard'))) {
             continue;
         }
         $renderer = $this->getItemRenderer($type)->setNewApi($this->getNewApi())->setItem($item);
         if (method_exists($renderer, 'addItemToXmlObject')) {
             $renderer->addItemToXmlObject($itemsXml);
         }
     }
 }
예제 #26
0
 /**
  * Render customer orders list xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $ordersXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<orders></orders>');
     $orders = Mage::getResourceModel('sales/order_collection')->addFieldToSelect('*')->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))->setOrder('created_at', 'desc');
     $orders->getSelect()->limit(self::ORDERS_LIST_LIMIT, 0);
     $orders->load();
     if (sizeof($orders->getItems())) {
         foreach ($orders as $_order) {
             $item = $ordersXmlObj->addChild('item');
             $item->addChild('entity_id', $_order->getId());
             $item->addChild('number', $_order->getRealOrderId());
             $item->addChild('date', $this->formatDate($_order->getCreatedAtStoreDate()));
             if ($_order->getShippingAddress()) {
                 $item->addChild('ship_to', $ordersXmlObj->xmlentities(strip_tags($_order->getShippingAddress()->getName())));
             }
             $item->addChild('total', $_order->getOrderCurrency()->formatPrecision($_order->getGrandTotal(), 2, array(), false, false));
             $item->addChild('status', $_order->getStatusLabel());
         }
     }
     return $ordersXmlObj->asNiceXml();
 }
예제 #27
0
파일: Tax.php 프로젝트: Airmal/Magento-Em
 /**
  * Add order taxes rendered to XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj
  * @return null
  */
 public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXmlObj)
 {
     /** @var $taxesXmlObj Mage_XmlConnect_Model_Simplexml_Element */
     $taxesXmlObj = $totalsXmlObj->addChild('tax');
     $fullInfo = $this->getOrder()->getFullTaxInfo();
     if ($this->displayFullSummary() && !empty($fullInfo)) {
         foreach ((array) $fullInfo as $info) {
             if (isset($info['hidden']) && $info['hidden']) {
                 continue;
             }
             foreach ((array) $info['rates'] as $rate) {
                 if (isset($info['amount'])) {
                     $config = array('label' => $rate['title']);
                     if (!is_null($rate['percent'])) {
                         $config['percent'] = sprintf('(%0.2f%%)', $rate['percent']);
                     }
                     $taxesXmlObj->addCustomChild('item', is_null($rate['percent']) ? '' : $this->_formatPrice($info['amount']), $config);
                 }
             }
         }
     }
     $taxesXmlObj->addCustomChild('summary', $this->_formatPrice($this->getSource()->getTaxAmount()), array('label' => $this->__('Tax')));
 }
예제 #28
0
 /**
  * Render filters list xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $categoryId = $this->getRequest()->getParam('category_id', null);
     $categoryXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<category></category>');
     $filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId);
     $filtersXmlObj = $categoryXmlObj->addChild('filters');
     foreach ($filtersCollection->getItems() as $item) {
         if (!sizeof($item->getValues())) {
             continue;
         }
         $itemXmlObj = $filtersXmlObj->addChild('item');
         $itemXmlObj->addChild('name', $categoryXmlObj->xmlentities(strip_tags($item->getName())));
         $itemXmlObj->addChild('code', $categoryXmlObj->xmlentities($item->getCode()));
         $valuesXmlObj = $itemXmlObj->addChild('values');
         foreach ($item->getValues() as $value) {
             $valueXmlObj = $valuesXmlObj->addChild('value');
             $valueXmlObj->addChild('id', $categoryXmlObj->xmlentities($value->getValueString()));
             $valueXmlObj->addChild('label', $categoryXmlObj->xmlentities(strip_tags($value->getLabel())));
             $valueXmlObj->addChild('count', (int) $value->getProductsCount());
         }
     }
     $categoryXmlObj->appendChild($this->getProductSortFeildsXmlObject());
     return $categoryXmlObj->asNiceXml();
 }
예제 #29
0
파일: Bundle.php 프로젝트: quyip8818/Mag
 /**
  * Add item to XML object. Api version 23
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
  * @return null
  */
 public function addItemToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
 {
     /** @var $parentItem Mage_Sales_Model_Order_Item */
     $parentItem = $this->getItem();
     $items = array_merge(array($parentItem), $parentItem->getChildrenItems());
     $prevOptionId = '';
     /** @var $weeeHelper Mage_Weee_Helper_Data */
     $weeeHelper = $this->helper('weee');
     /** @var $taxHelper Mage_Tax_Helper_Data */
     $taxHelper = $this->helper('tax');
     /** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */
     $itemXml = $orderItemXmlObj->addChild('item');
     /** @var $optionsXml Mage_XmlConnect_Model_Simplexml_Element */
     $optionsXml = $itemXml->addChild('related_products');
     $this->setWeeeTaxAppliedAmount($parentItem->getWeeeTaxAppliedAmount());
     $this->setWeeeTaxDisposition($parentItem->getWeeeTaxDisposition());
     $typeOfDisplay1 = $weeeHelper->typeOfDisplay($parentItem, 1, 'sales') && $this->getWeeeTaxAppliedAmount();
     $typeOfDisplay2 = $weeeHelper->typeOfDisplay($parentItem, 2, 'sales') && $this->getWeeeTaxAppliedAmount();
     $typeOfDisplay4 = $weeeHelper->typeOfDisplay($parentItem, 4, 'sales') && $this->getWeeeTaxAppliedAmount();
     $typeOfDisplay014 = $weeeHelper->typeOfDisplay($parentItem, 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($parentItem));
     /** @var $item Mage_Sales_Model_Order_Item */
     foreach ($items as $item) {
         $isOption = $item->getParentItem() ? true : false;
         /** @var $objectXml Mage_XmlConnect_Model_Simplexml_Element */
         if ($isOption) {
             $objectXml = $optionsXml->addChild('item');
         } else {
             $objectXml = $itemXml;
         }
         $objectXml->addAttribute('product_id', $item->getProductId());
         $objectXml->addCustomChild('entity_type', $item->getProductType());
         if ($isOption) {
             $attributes = $this->getSelectionAttributes($item);
             if ($prevOptionId != $attributes['option_id']) {
                 $objectXml->addAttribute('label', $objectXml->xmlAttribute($attributes['option_label']));
                 $prevOptionId = $attributes['option_id'];
             }
         }
         $objectXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($item->getSku()));
         if ($isOption) {
             $name = $this->getValueHtml($item);
         } else {
             $name = $item->getName();
         }
         $objectXml->addCustomChild('name', $name);
         // set prices exactly for the Bundle product, but not for related products
         if (!$isOption) {
             $priceXml = $itemXml->addCustomChild('price_list');
             $priceInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'price'));
             $subtotalInfoXml = $priceXml->addCustomChild('prices', null, array('id' => 'subtotal'));
             // Price excluding tax
             if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
                 Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23($this, $parentItem, $priceInfoXml, $subtotalInfoXml);
             }
             // Price including tax
             if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
                 Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXmlApi23($this, $parentItem, $priceInfoXml, $subtotalInfoXml, true);
             }
         }
         // set quantities
         /** @var $qtyXml Mage_XmlConnect_Model_Simplexml_Element */
         if ($isOption && $this->isChildCalculated() || !$isOption && !$this->isChildCalculated()) {
             $qtyXml = $objectXml->addChild('quantity');
             if ($item->getQtyOrdered() > 0) {
                 $qtyXml->addCustomChild('value', $item->getQtyOrdered() * 1, array('label' => Mage::helper('sales')->__('Ordered')));
             }
             if ($item->getQtyShipped() > 0 && !$this->isShipmentSeparately()) {
                 $qtyXml->addCustomChild('value', $item->getQtyShipped() * 1, array('label' => Mage::helper('sales')->__('Shipped')));
             }
             if ($item->getQtyCanceled() > 0) {
                 $qtyXml->addCustomChild('value', $item->getQtyCanceled() * 1, array('label' => Mage::helper('sales')->__('Canceled')));
             }
             if ($item->getQtyRefunded() > 0) {
                 $qtyXml->addCustomChild('value', $item->getQtyRefunded() * 1, array('label' => Mage::helper('sales')->__('Refunded')));
             }
         } elseif ($item->getQtyShipped() > 0 && $isOption && $this->isShipmentSeparately()) {
             $qtyXml = $objectXml->addChild('quantity');
             $qtyXml->addCustomChild('value', $item->getQtyShipped() * 1, array('label' => Mage::helper('sales')->__('Shipped')));
         }
     }
     if ($parentItem->getDescription()) {
         $itemXml->addCustomChild('description', $parentItem->getDescription());
     }
     Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
 }
예제 #30
0
    /**
     * Add Payflow Pro payment method form to payment XML object
     *
     * @param Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj
     * @return Mage_XmlConnect_Model_Simplexml_Element
     */
    public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj)
    {
        $method = $this->getMethod();
        if (!$method) {
            return $paymentItemXmlObj;
        }
        $formXmlObj = $paymentItemXmlObj->addChild('form');
        $formXmlObj->addAttribute('name', 'payment_form_' . $method->getCode());
        $formXmlObj->addAttribute('method', 'post');
        $_ccType = $this->getInfoData('cc_type');
        $ccTypes = '';
        foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName) {
            if (!$_typeCode) {
                continue;
            }
            $ccTypes .= '
            <item' . ($_typeCode == $_ccType ? ' selected="1"' : '') . '>
                <label>' . $_typeName . '</label>
                <value>' . $_typeCode . '</value>
            </item>';
        }
        $ccMonthes = '';
        $_ccExpMonth = $this->getInfoData('cc_exp_month');
        foreach ($this->getCcMonths() as $k => $v) {
            if (!$k) {
                continue;
            }
            $ccMonthes .= '
            <item' . ($k == $_ccExpMonth ? ' selected="1"' : '') . '>
                <label>' . $v . '</label>
                <value>' . ($k ? $k : '') . '</value>
            </item>';
        }
        $ccYears = '';
        $_ccExpYear = $this->getInfoData('cc_exp_year');
        foreach ($this->getCcYears() as $k => $v) {
            if (!$k) {
                continue;
            }
            $ccYears .= '
            <item' . ($k == $_ccExpYear ? ' selected="1"' : '') . '>
                <label>' . $v . '</label>
                <value>' . ($k ? $k : '') . '</value>
            </item>';
        }
        $verification = '';
        if ($this->hasVerification()) {
            $verification = <<<EOT
<field name="payment[cc_cid]" type="text" label="{$this->__('Card Verification Number')}" required="true">
    <validators>
        <validator relation="payment[cc_type]" type="credit_card_svn" message="{$this->__('Card verification number is wrong')}'"/>
    </validators>
</field>
EOT;
        }
        $xml = <<<EOT
<fieldset>
    <field name="payment[cc_type]" type="select" label="{$this->__('Credit Card Type')}" required="true">
        <values>
            {$ccTypes}
        </values>
    </field>
    <field name="payment[cc_number]" type="text" label="{$this->__('Credit Card Number')}" required="true">
        <validators>
            <validator relation="payment[cc_type]" type="credit_card" message="{$this->__('Credit card number does not match credit card type.')}"/>
        </validators>
    </field>
    <field name="payment[cc_exp_month]" type="select" label="{$this->__('Expiration Date - Month')}" required="true">
        <values>
            {$ccMonthes}
        </values>
    </field>
    <field name="payment[cc_exp_year]" type="select" label="{$this->helper('Mage_XmlConnect_Helper_Data')->__('Expiration Date - Year')}" required="true">
        <values>
            {$ccYears}
        </values>
    </field>
    {$verification}
</fieldset>
EOT;
        $fieldsetXmlObj = Mage::getModel('Mage_XmlConnect_Model_Simplexml_Element', $xml);
        $formXmlObj->appendChild($fieldsetXmlObj);
    }