/** * 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(); }
/** * Render order review xml * * @return string */ protected function _toHtml() { $orderXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<order></order>'); /** * Order items */ $products = $this->getChildHtml('order_products'); if ($products) { $productsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($products); $orderXmlObj->appendChild($productsXmlObj); } /** * Totals */ $totalsXml = $this->getChildHtml('totals'); if ($totalsXml) { $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($totalsXml); $orderXmlObj->appendChild($totalsXmlObj); } /** * Agreements */ $agreements = $this->getChildHtml('agreements'); if ($agreements) { $agreementsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($agreements); $orderXmlObj->appendChild($agreementsXmlObj); } return $orderXmlObj->asNiceXml(); }
/** * Render customer address list xml * * @return string */ protected function _toHtml() { $addressXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<address></address>'); $customer = Mage::getSingleton('customer/session')->getCustomer(); $_billingAddssesId = $customer->getDefaultBilling(); $_shippingAddssesId = $customer->getDefaultShipping(); $billingAddress = $customer->getAddressById($_billingAddssesId); $shippingAddress = $customer->getAddressById($_shippingAddssesId); if ($billingAddress && $billingAddress->getId()) { $item = $addressXmlObj->addChild('item'); $item->addAttribute('label', $this->__('Default Billing Address')); $item->addAttribute('default_billing', 1); $this->prepareAddressData($billingAddress, $item); } if ($shippingAddress && $shippingAddress->getId()) { $item = $addressXmlObj->addChild('item'); $item->addAttribute('label', $this->__('Default Shipping Address')); $item->addAttribute('default_shipping', 1); $this->prepareAddressData($shippingAddress, $item); } $_additionalAddresses = $customer->getAdditionalAddresses(); if ($_additionalAddresses) { foreach ($_additionalAddresses as $_address) { $item = $addressXmlObj->addChild('item'); $item->addAttribute('label', $this->__('Additional Address')); $item->addAttribute('additional', 1); $this->prepareAddressData($_address, $item); } } return $addressXmlObj->asNiceXml(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * Search suggestions xml renderer * * @return string */ protected function _toHtml() { $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions></suggestions>'); if (!$this->getRequest()->getParam('q', false)) { return $suggestXmlObj->asNiceXml(); } $handler = Mage::getSingleton('factfinder_suggest/handler_suggest', array($this->getRequest()->getParam('q'))); $suggestData = $handler->getSuggestionsAsArray(); if (!($count = count($suggestData))) { return $suggestXmlObj->asNiceXml(); } $items = ''; foreach ($suggestData as $index => $item) { $items .= $suggestXmlObj->xmlentities(strip_tags($item['query'])) . self::SUGGEST_ITEM_SEPARATOR . (int) $item['hitCount'] . self::SUGGEST_ITEM_SEPARATOR; } $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions>' . $items . '</suggestions>'); return $suggestXmlObj->asNiceXml(); }
/** * 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(); }
/** * Search suggestions xml renderer * * @return string */ protected function _toHtml() { $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions></suggestions>'); if (!$this->getRequest()->getParam('q', false)) { return $suggestXmlObj->asNiceXml(); } $suggestData = $this->getSuggestData(); if (!($count = count($suggestData))) { return $suggestXmlObj->asNiceXml(); } $items = ''; foreach ($suggestData as $index => $item) { $items .= $suggestXmlObj->xmlentities(strip_tags($item['title'])) . self::SUGGEST_ITEM_SEPARATOR . (int) $item['num_of_results'] . self::SUGGEST_ITEM_SEPARATOR; // $itemXmlObj = $suggestXmlObj->addChild('item'); // $itemXmlObj->addChild('title', $suggestXmlObj->xmlentities(strip_tags($item['title']))); // $itemXmlObj->addChild('count', (int)$item['num_of_results']); } $suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions>' . $items . '</suggestions>'); return $suggestXmlObj->asNiceXml(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * Render order review items * * @return string */ protected function _toHtml() { $itemsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<products></products>'); $quote = Mage::getSingleton('checkout/session')->getQuote(); /* @var $item Mage_Sales_Model_Quote_Item */ foreach ($this->getItems() as $item) { $type = $this->_getItemType($item); $renderer = $this->getItemRenderer($type)->setItem($item); /** * General information */ $itemXml = $itemsXmlObj->addChild('item'); $itemXml->addChild('entity_id', $item->getProduct()->getId()); $itemXml->addChild('entity_type', $type); $itemXml->addChild('item_id', $item->getId()); $itemXml->addChild('name', $itemsXmlObj->xmlentities(strip_tags($renderer->getProductName()))); $itemXml->addChild('qty', $renderer->getQty()); $icon = $renderer->getProductThumbnail()->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')); $iconXml = $itemXml->addChild('icon', $icon); $file = Mage::helper('xmlconnect')->urlToPath($icon); $iconXml->addAttribute('modification_time', filemtime($file)); /** * Price */ $exclPrice = $inclPrice = 0.0; if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) { $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales'); if ($typeOfDisplay && $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); $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales'); if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) { $inclPrice = $_incl + $item->getWeeeTaxAppliedAmount(); } else { $inclPrice = $_incl - $item->getWeeeTaxDisposition(); } } $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice); $formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false); $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice); $formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false); $priceXmlObj = $itemXml->addChild('price'); $formatedPriceXmlObj = $itemXml->addChild('formated_price'); if ($this->helper('tax')->displayCartBothPrices()) { $priceXmlObj->addAttribute('excluding_tax', $exclPrice); $priceXmlObj->addAttribute('including_tax', $inclPrice); $formatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice); $formatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice); } else { if ($this->helper('tax')->displayCartPriceExclTax()) { $priceXmlObj->addAttribute('regular', $exclPrice); $formatedPriceXmlObj->addAttribute('regular', $formatedExclPrice); } if ($this->helper('tax')->displayCartPriceInclTax()) { $priceXmlObj->addAttribute('regular', $inclPrice); $formatedPriceXmlObj->addAttribute('regular', $formatedInclPrice); } } /** * Subtotal */ $exclPrice = $inclPrice = 0.0; if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) { $typeOfDisplay = Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales'); if ($typeOfDisplay && $item->getWeeeTaxAppliedAmount()) { $exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition(); } else { $exclPrice = $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()) { $inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount(); } else { $inclPrice = $_incl - $item->getWeeeTaxRowDisposition(); } } $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice); $formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false); $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice); $formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false); $subtotalPriceXmlObj = $itemXml->addChild('subtotal'); $subtotalFormatedPriceXmlObj = $itemXml->addChild('formated_subtotal'); if ($this->helper('tax')->displayCartBothPrices()) { $subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice); $subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice); $subtotalFormatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice); $subtotalFormatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice); } else { if ($this->helper('tax')->displayCartPriceExclTax()) { $subtotalPriceXmlObj->addAttribute('regular', $exclPrice); $subtotalFormatedPriceXmlObj->addAttribute('regular', $formatedExclPrice); } if ($this->helper('tax')->displayCartPriceInclTax()) { $subtotalPriceXmlObj->addAttribute('regular', $inclPrice); $subtotalFormatedPriceXmlObj->addAttribute('regular', $formatedInclPrice); } } /** * Options list */ if ($_options = $renderer->getOptionList()) { $itemOptionsXml = $itemXml->addChild('options'); foreach ($_options as $_option) { $_formatedOptionValue = $renderer->getFormatedOptionValue($_option); $optionXml = $itemOptionsXml->addChild('option'); $labelValue = $itemsXmlObj->xmlentities(strip_tags($_option['label'])); $optionXml->addAttribute('label', $labelValue); $textValue = $itemsXmlObj->xmlentities(strip_tags($_formatedOptionValue['value'])); $optionXml->addAttribute('text', $textValue); // if (isset($_formatedOptionValue['full_view'])) { // $label = strip_tags($_option['label']); // $value = strip_tags($_formatedOptionValue['full_view']); // } } } } return $itemsXmlObj->asNiceXml(); }
/** * Submit the order * * @return void */ public function saveOrderAction() { if (!$this->getRequest()->isPost()) { $this->_message($this->__('Specified invalid data.'), self::MESSAGE_STATUS_ERROR); return; } try { /** * Init checkout */ $this->_initCheckout(); /** * Set payment data */ $data = $this->getRequest()->getPost('payment', array()); $this->_checkout->savePayment($data); /** * Place order */ $this->_checkout->saveOrder(); /** * Format success report */ $message = new Mage_XmlConnect_Model_Simplexml_Element('<message></message>'); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $orderId = $this->_checkout->getLastOrderId(); $text = $this->__('Thank you for your purchase! '); $text .= $this->__('Your order # is: %s. ', $orderId); $text .= $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.'); $message->addChild('text', $text); $message->addChild('order_id', $orderId); $this->getResponse()->setBody($message->asNiceXml()); return; } catch (Mage_Core_Exception $e) { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); } catch (Exception $e) { $this->_message($this->__('Unable to place the order.'), self::MESSAGE_STATUS_ERROR); Mage::logException($e); } }
/** * Search results xml renderer * XML also contains filters that can be apply (accorfingly already applyed filters and search query) * and sort fields * * @return string */ protected function _toHtml() { $searchXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<search></search>'); $filtersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<filters></filters>'); $helper = Mage::helper('catalogsearch'); if (method_exists($helper, 'getEngine')) { $engine = Mage::helper('catalogsearch')->getEngine(); $isLayeredNavigationAllowed = $engine instanceof Varien_Object ? $engine->isLeyeredNavigationAllowed() : true; } else { $isLayeredNavigationAllowed = true; } $request = $this->getRequest(); $requestParams = $request->getParams(); $hasMoreProductItems = 0; /** * Products */ $productListBlock = $this->getChild('product_list'); if ($productListBlock) { $layer = Mage::getSingleton('catalogsearch/layer'); $productsXmlObj = $productListBlock->setLayer($layer)->setNeedBlockApplyingFilters(!$isLayeredNavigationAllowed)->getProductsXmlObject(); $searchXmlObject->appendChild($productsXmlObj); $hasMoreProductItems = (int) $productListBlock->getHasProductItems(); } $searchXmlObject->addAttribute('has_more_items', $hasMoreProductItems); /** * Filters */ $showFiltersAndOrders = (bool) count($productsXmlObj); $reguest = $this->getRequest(); foreach ($reguest->getParams() as $key => $value) { if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX) || 0 === strpos($key, parent::REQUEST_FILTER_PARAM_REFIX)) { $showFiltersAndOrders = false; break; } } if ($isLayeredNavigationAllowed && $productListBlock && $showFiltersAndOrders) { $filters = $productListBlock->getCollectedFilters(); /** * Render filters xml */ foreach ($filters as $filter) { if (!$this->_isFilterItemsHasValues($filter)) { continue; } $item = $filtersXmlObject->addChild('item'); $item->addChild('name', $searchXmlObject->xmlentities($filter->getName())); $item->addChild('code', $filter->getRequestVar()); $values = $item->addChild('values'); foreach ($filter->getItems() as $valueItem) { $count = (int) $valueItem->getCount(); if (!$count) { continue; } $value = $values->addChild('value'); $value->addChild('id', $valueItem->getValueString()); $value->addChild('label', $searchXmlObject->xmlentities(strip_tags($valueItem->getLabel()))); $value->addChild('count', $count); } } $searchXmlObject->appendChild($filtersXmlObject); } /** * Sort fields */ if ($showFiltersAndOrders) { $searchXmlObject->appendChild($this->getProductSortFeildsXmlObject()); } return $searchXmlObject->asNiceXml(); }
/** * Generate message xml and set it to response body * * @param string $text * @param string $status * @param string $type * @param string $action * @return void */ protected function _message($text, $status, $type = '', $action = '') { $message = new Mage_XmlConnect_Model_Simplexml_Element('<message></message>'); $message->addChild('status', $status); $message->addChild('text', $text); $this->getResponse()->setBody($message->asNiceXml()); }
/** * Add wishlist item to shopping cart and remove from wishlist * * If Product has required options - item removed from wishlist and redirect * to product view page with message about needed defined required options * * @return void */ public function cartAction() { $wishlist = $this->_getWishlist(); if (!$wishlist) { return; } $itemId = (int) $this->getRequest()->getParam('item'); /* @var $item Mage_Wishlist_Model_Item */ $item = Mage::getModel('wishlist/item')->load($itemId); if (!$item->getId() || $item->getWishlistId() != $wishlist->getId()) { $this->_message($this->__('Invalid item or wishlist.'), self::MESSAGE_STATUS_ERROR); return; } /* @var $session Mage_Wishlist_Model_Session */ $session = Mage::getSingleton('wishlist/session'); $cart = Mage::getSingleton('checkout/cart'); try { $item->addToCart($cart, true); $cart->save()->getQuote()->collectTotals(); $wishlist->save(); Mage::helper('wishlist')->calculate(); $this->_message($this->__('Item has been added to cart.'), self::MESSAGE_STATUS_SUCCESS); } catch (Mage_Core_Exception $e) { if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_NOT_SALABLE) { $this->_message($this->__('Product(s) currently out of stock.'), self::MESSAGE_STATUS_ERROR); } else { if ($e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS || $e->getCode() == Mage_Wishlist_Model_Item::EXCEPTION_CODE_IS_GROUPED_PRODUCT) { $item->delete(); $message = new Mage_XmlConnect_Model_Simplexml_Element('<message></message>'); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $message->addChild('has_required_options', 1); $message->addChild('product_id', $item->getProductId()); $this->getResponse()->setBody($message->asNiceXml()); } else { $this->_message($e->getMessage(), self::MESSAGE_STATUS_ERROR); } } } catch (Exception $e) { $this->_message($this->__('Can\'t add item to shopping cart.'), self::MESSAGE_STATUS_ERROR); } Mage::helper('wishlist')->calculate(); }
/** * Render payment methods xml * * @return string * @throw Mage_Core_Exception */ protected function _toHtml() { $methodsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<payment_methods></payment_methods>'); $methodBlocks = $this->getChild(); $methodArray = array('payment_ccsave' => 'Mage_Payment_Model_Method_Cc', 'payment_checkmo' => 'Mage_Payment_Model_Method_Checkmo', 'payment_purchaseorder' => 'Mage_Payment_Model_Method_Purchaseorder'); $usedMethods = $sortedAvailableMethodCodes = $usedCodes = array(); $allAvailableMethods = Mage::helper('payment')->getStoreMethods(Mage::app()->getStore(), $this->getQuote()); foreach ($allAvailableMethods as $method) { $sortedAvailableMethodCodes[] = $method->getCode(); } /** * Collect directly supported by xmlconnect methods */ 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 (!is_null($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); } $methodItemXmlObj = $methodsXmlObj->addChild('method'); $methodItemXmlObj->addAttribute('post_name', 'payment[method]'); $methodItemXmlObj->addAttribute('code', $method->getCode()); $methodItemXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($method->getTitle()))); if ($this->getQuote()->getPayment()->getMethod() == $method->getCode()) { $methodItemXmlObj->addAttribute('selected', 1); } $renderer->addPaymentFormToXmlObj($methodItemXmlObj); } if (!count($usedMethods)) { Mage::throwException($this->__('Sorry, no payment options are available for this order at this time.')); } return $methodsXmlObj->asNiceXml(); }
/** * 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(); }
/** * Check if customer is loggined * * @return void */ public function isLogginedAction() { $message = new Mage_XmlConnect_Model_Simplexml_Element('<message></message>'); $message->addChild('is_loggined', (int) $this->_getSession()->isLoggedIn()); $this->getResponse()->setBody($message->asNiceXml()); }
/** * Create order action * * @return void */ public function saveOrderAction() { if (!$this->getRequest()->isPost()) { $this->_message($this->__('Specified invalid data.'), self::MESSAGE_STATUS_ERROR); return; } try { if ($requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds()) { $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array())); if ($diff = array_diff($requiredAgreements, $postedAgreements)) { $error = $this->__('Please agree to all the terms and conditions before placing the order.'); $this->_message($error, self::MESSAGE_STATUS_ERROR); return; } } if ($data = $this->getRequest()->getPost('payment', false)) { $this->getOnepage()->getQuote()->getPayment()->importData($data); } $this->getOnepage()->saveOrder(); $message = new Mage_XmlConnect_Model_Simplexml_Element('<message></message>'); $message->addChild('status', self::MESSAGE_STATUS_SUCCESS); $orderId = $this->getOnepage()->getLastOrderId(); $text = $this->__('Thank you for your purchase! '); $text .= $this->__('Your order # is: %s. ', $orderId); $text .= $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.'); $message->addChild('text', $text); $message->addChild('order_id', $orderId); $this->getOnepage()->getQuote()->save(); $this->getOnepage()->getCheckout()->clear(); $this->getResponse()->setBody($message->asNiceXml()); return; } catch (Mage_Core_Exception $e) { Mage::logException($e); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage()); $error = $e->getMessage(); } catch (Exception $e) { Mage::logException($e); Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage()); $error = $this->__('An error occurred while processing your order. Please contact us or try again later.'); } $this->getOnepage()->getQuote()->save(); $this->_message($error, self::MESSAGE_STATUS_ERROR); }
/** * 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(); }
/** * Render payment methods xml * * @return string * @throw Mage_Core_Exception */ protected function _toHtml() { $methodsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<payment_methods></payment_methods>'); /** * Pre-defined array of methods that we are going to render */ $methodArray = array('payment_ccsave' => 'Mage_Payment_Model_Method_Cc', 'payment_checkmo' => 'Mage_Payment_Model_Method_Checkmo', 'payment_purchaseorder' => 'Mage_Payment_Model_Method_Purchaseorder'); /** * Check is available Payment Bridge and add methods for rendering */ if (is_object(Mage::getConfig()->getNode('modules/Enterprise_Pbridge'))) { $pbridgeMethodArray = array('pbridge_authorizenet' => 'Enterprise_Pbridge_Model_Payment_Method_Authorizenet', 'pbridge_paypal' => 'Enterprise_Pbridge_Model_Payment_Method_Paypal', 'pbridge_verisign' => 'Enterprise_Pbridge_Model_Payment_Method_Payflow_Pro', 'pbridge_paypaluk' => 'Enterprise_Pbridge_Model_Payment_Method_Paypaluk'); $pbBlockRenderer = 'xmlconnect/checkout_payment_method_'; $pbBlockName = 'xmlconnect.checkout.payment.method.'; foreach ($pbridgeMethodArray as $block => $class) { $currentBlockRenderer = $pbBlockRenderer . $block; $currentBlockName = $pbBlockName . $block; $this->getLayout()->addBlock($currentBlockRenderer, $currentBlockName); $this->setChild($block, $currentBlockName); } $methodArray = $methodArray + $pbridgeMethodArray; } $usedMethods = $sortedAvailableMethodCodes = $usedCodes = array(); /** * Receive available methods for checkout */ $allAvailableMethods = Mage::helper('payment')->getStoreMethods(Mage::app()->getStore(), $this->getQuote()); /** * 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); } $methodItemXmlObj = $methodsXmlObj->addChild('method'); $methodItemXmlObj->addAttribute('post_name', 'payment[method]'); $methodItemXmlObj->addAttribute('code', $method->getCode()); $methodItemXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($method->getTitle()))); if ($this->getQuote()->getPayment()->getMethod() == $method->getCode()) { $methodItemXmlObj->addAttribute('selected', 1); } $renderer->addPaymentFormToXmlObj($methodItemXmlObj); } if (!count($usedMethods)) { Mage::throwException($this->__('Sorry, no payment options are available for this order at this time.')); } return $methodsXmlObj->asNiceXml(); }
/** * Render shopping cart xml * * @return string */ protected function _toHtml() { $cartMessages = $this->getMessages(); $quote = $this->getQuote(); $xmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<cart></cart>'); $xmlObject->addAttribute('is_virtual', (int) $this->helper('checkout/cart')->getIsVirtualQuote()); $xmlObject->addAttribute('summary_qty', (int) $this->helper('checkout/cart')->getSummaryCount()); if (strlen($quote->getCouponCode())) { $xmlObject->addAttribute('has_coupon_code', 1); } $products = $xmlObject->addChild('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->addChild('item'); $itemXml->addChild('entity_id', $item->getProduct()->getId()); $itemXml->addChild('entity_type', $type); $itemXml->addChild('item_id', $item->getId()); $itemXml->addChild('name', $xmlObject->xmlentities(strip_tags($renderer->getProductName()))); $itemXml->addChild('code', 'cart[' . $item->getId() . '][qty]'); $itemXml->addChild('qty', $renderer->getQty()); $icon = $renderer->getProductThumbnail()->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small')); $iconXml = $itemXml->addChild('icon', $icon); $file = Mage::helper('xmlconnect')->urlToPath($icon); $iconXml->addAttribute('modification_time', filemtime($file)); /** * Price */ $exclPrice = $inclPrice = 0.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); $formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false); $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice); $formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false); $priceXmlObj = $itemXml->addChild('price'); $formatedPriceXmlObj = $itemXml->addChild('formated_price'); if ($this->helper('tax')->displayCartBothPrices()) { $priceXmlObj->addAttribute('excluding_tax', $exclPrice); $priceXmlObj->addAttribute('including_tax', $inclPrice); $formatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice); $formatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice); } else { if ($this->helper('tax')->displayCartPriceExclTax()) { $priceXmlObj->addAttribute('regular', $exclPrice); $formatedPriceXmlObj->addAttribute('regular', $formatedExclPrice); } if ($this->helper('tax')->displayCartPriceInclTax()) { $priceXmlObj->addAttribute('regular', $inclPrice); $formatedPriceXmlObj->addAttribute('regular', $formatedInclPrice); } } /** * Subtotal */ $exclPrice = $inclPrice = 0.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->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition(); } else { $exclPrice = $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()) { $inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount(); } else { $inclPrice = $_incl - $item->getWeeeTaxRowDisposition(); } } $exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice); $formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false); $inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice); $formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false); $subtotalPriceXmlObj = $itemXml->addChild('subtotal'); $subtotalFormatedPriceXmlObj = $itemXml->addChild('formated_subtotal'); if ($this->helper('tax')->displayCartBothPrices()) { $subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice); $subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice); $subtotalFormatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice); $subtotalFormatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice); } else { if ($this->helper('tax')->displayCartPriceExclTax()) { $subtotalPriceXmlObj->addAttribute('regular', $exclPrice); $subtotalFormatedPriceXmlObj->addAttribute('regular', $formatedExclPrice); } if ($this->helper('tax')->displayCartPriceInclTax()) { $subtotalPriceXmlObj->addAttribute('regular', $inclPrice); $subtotalFormatedPriceXmlObj->addAttribute('regular', $formatedInclPrice); } } /** * Options list */ if ($_options = $renderer->getOptionList()) { $itemOptionsXml = $itemXml->addChild('options'); foreach ($_options as $_option) { $_formatedOptionValue = $renderer->getFormatedOptionValue($_option); $optionXml = $itemOptionsXml->addChild('option'); $optionXml->addAttribute('label', $xmlObject->xmlentities(strip_tags($_option['label']))); $optionXml->addAttribute('text', $xmlObject->xmlentities(strip_tags($_formatedOptionValue['value']))); // if (isset($_formatedOptionValue['full_view'])) { // $label = strip_tags($_option['label']); // $value = strip_tags($_formatedOptionValue['full_view']); // } } } /** * Item messages */ if ($messages = $renderer->getMessages()) { $itemMessagesXml = $itemXml->addChild('messages'); foreach ($messages as $message) { $messageXml = $itemMessagesXml->addChild('option'); $messageXml->addChild('type', $message['type']); $messageXml->addChild('text', $xmlObject->xmlentities(strip_tags($message['text']))); } } } /** * Cart messages */ if ($cartMessages) { $messagesXml = $xmlObject->addChild('messages'); foreach ($cartMessages as $status => $messages) { foreach ($messages as $message) { $messageXml = $messagesXml->addChild('message'); $messageXml->addChild('status', $status); $messageXml->addChild('text', strip_tags($message)); } } } /** * Cross Sell Products */ $crossSellXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($this->getChildHtml('crosssell')); $xmlObject->appendChild($crossSellXmlObj); return $xmlObject->asNiceXml(); }