/** * 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 CC Save Payment info to order XML object * * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj * @return Mage_XmlConnect_Model_Simplexml_Element */ public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) { $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())); if ($_specificInfo = $this->getSpecificInformation()) { foreach ($_specificInfo as $label => $value) { $orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label)); } } }
/** * Add Check / Money order info to order XML object * * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj * @return Mage_XmlConnect_Model_Simplexml_Element */ public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) { $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())); if ($this->getInfo()->getAdditionalData()) { if ($this->getPayableTo()) { $orderItemXmlObj->addCustomChild('item', $this->getPayableTo(), array('label' => Mage::helper('sales')->__('Make Check payable to:'))); } if ($this->getMailingAddress()) { $orderItemXmlObj->addCustomChild('item', $this->getMailingAddress(), array('label' => Mage::helper('payment')->__('Send Check to:'))); } } }
/** * Add price details to xml object * * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj * @param Mage_Sales_Model_Quote_Address_Rate $rate * @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods */ protected function _addPriceToXmlObj($xmlObj, $rate) { $price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); $incl = $this->_getShippingPrice($rate->getPrice(), true); $renderedInclTax = ''; if ($incl != $price && $this->helper('tax')->displayShippingBothPrices()) { $inclTaxFormat = ' (%s %s)'; $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl); } $price .= $renderedInclTax; $xmlObj->addAttribute('price', $rate->getPrice() * 1); $xmlObj->addAttribute('formatted_price', $xmlObj->escapeXml($price)); return $this; }
/** * Add Authorizenet info to order XML object * * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj * @return Mage_XmlConnect_Model_Simplexml_Element */ public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) { $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); if (!$this->getHideTitle()) { $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())); } $cards = $this->getCards(); $showCount = count($cards) > 1; foreach ($cards as $key => $card) { $creditCard = $orderItemXmlObj->addCustomChild('item', null, array('label' => $showCount ? $this->__('Credit Card %s', $key + 1) : $this->__('Credit Card'))); foreach ($card as $label => $value) { $creditCard->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label)); } } }
/** * Add value and options to select * * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Select */ protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj) { $value = $this->getEscapedValue(); if ($value !== null) { $xmlObj->addAttribute('value', $xmlObj->xmlAttribute($value)); } $this->_addOptions($xmlObj); return $this; }
/** * 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; }
/** * 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(); }
/** * Add validator message for validator rule * * @throws Mage_Core_Exception * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj * @return Mage_XmlConnect_Model_Simplexml_Form_Abstract */ protected function _addMessage(Mage_XmlConnect_Model_Simplexml_Element $xmlObj) { if ($this->getMessage()) { $message = $this->getMessage(); } elseif (array_key_exists($this->getType(), $this->getValidatorTypeMessages())) { $message = $this->_validatorTypeMessages[$this->getType()]; } else { Mage::throwException(Mage::helper('xmlconnect')->__('"message" attribute is required for "%s" validator rule.', $this->getType())); } $xmlObj->addAttribute('message', $xmlObj->xmlAttribute($message)); return $this; }
/** * Add weee tax product info to xml object * * @param Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj * @param bool $subtotalFlag use true to get subtotal product info * @return Mage_XmlConnect_Model_Simplexml_Element */ protected function _addWeeeToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj, $subtotalFlag = false) { $_item = $this->getItem(); $weeeXmlObj = $priceXmlObj->addCustomChild('weee'); if ($subtotalFlag) { $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); } else { $_incl = $this->helper('checkout')->getPriceInclTax($_item); } $typeOfDisplay2 = Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales'); if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()) { foreach (Mage::helper('weee')->getApplied($_item) as $tax) { if ($subtotalFlag) { $amount = $tax['row_amount']; } else { $amount = $tax['amount']; } $weeeXmlObj->addCustomChild('item', null, array('name' => $tax['title'], 'amount' => $this->_formatPrice($amount))); } } elseif ($_item->getWeeeTaxAppliedAmount() && ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales'))) { foreach (Mage::helper('weee')->getApplied($_item) as $tax) { if ($subtotalFlag) { $amount = $tax['row_amount_incl_tax']; } else { $amount = $tax['amount_incl_tax']; } $weeeXmlObj->addCustomChild('item', null, array('name' => $tax['title'], 'amount' => $this->_formatPrice($amount))); } } if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) { if ($subtotalFlag) { $totalExcl = $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition(); } else { $totalExcl = $_item->getCalculationPrice() + $_item->getWeeeTaxAppliedAmount() + $_item->getWeeeTaxDisposition(); } $totalExcl = $this->_formatPrice($totalExcl); $priceXmlObj->addAttribute('total_excluding_tax', $priceXmlObj->escapeXml($totalExcl)); } if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) { if ($subtotalFlag) { $totalIncl = $_incl + $_item->getWeeeTaxAppliedRowAmount(); } else { $totalIncl = $_incl + $_item->getWeeeTaxAppliedAmount(); } $totalIncl = $this->_formatPrice($totalIncl); $priceXmlObj->addAttribute('total_including_tax', $priceXmlObj->escapeXml($totalIncl)); } return $priceXmlObj; }
/** * Add Purchase Order Payment info to order XML object * * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj * @return Mage_XmlConnect_Model_Simplexml_Element */ public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) { $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())); $orderItemXmlObj->addCustomChild('item', $this->getInfo()->getPoNumber(), array('label' => Mage::helper('sales')->__('Purchase Order Number:'))); }
/** * Add value to element * * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract */ protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj) { if ($this->getEscapedValue()) { $xmlObj->addAttribute('value', $xmlObj->xmlAttribute($this->getEscapedValue())); } return $this; }
/** * Add value to element * * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj * @return Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract */ protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj) { $xmlObj->addAttribute('value', (int) $this->getValue()); return $this; }
/** * Add form name to element * * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj * @return Mage_XmlConnect_Model_Simplexml_Form_Abstract */ protected function _addName(Mage_XmlConnect_Model_Simplexml_Element $xmlObj) { if ($this->getName()) { $name = $this->getName(); } elseif ($this->getNameRequired()) { $name = $this->getXmlId(); } if (isset($name)) { $xmlObj->addAttribute('name', $xmlObj->xmlAttribute($name)); } return $this; }
/** * 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(); }
/** * Add Check / Money order info to order XML object * * @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj * @return Mage_XmlConnect_Model_Simplexml_Element */ public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj) { $orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode()); $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle())); }
/** * Retrieve option type name by specified option real type name * * @param Mage_XmlConnect_Model_Simplexml_Element $xmlItem * @param string $type * @param int|null $value * @return Mage_XmlConnect_Block_Catalog_Product_Options */ protected function _setCartSelectedValue($xmlItem, $type, $value = null) { if (empty($value)) { return $this; } switch ($type) { case Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE: case Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT: $xmlItem->addAttribute('selected', 1); break; case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX: $xmlItem->addAttribute('value', 1); break; case Mage_Catalog_Model_Product_Option::OPTION_TYPE_FIELD: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_AREA: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_FILE: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_TIME: case Mage_Catalog_Model_Product_Option::OPTION_TYPE_DATE_TIME: default: $xmlItem->addAttribute('value', $value); break; } return $this; }
/** * Add payment method through Pbridge iframe XML object * * @param Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj * @return Mage_XmlConnect_Model_Simplexml_Element */ public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj) { $paymentItemXmlObj->addAttribute('is_pbridge', 1); $paymentItemXmlObj->addChild('pb_iframe', $paymentItemXmlObj->xmlentities($this->createIframe())); return $paymentItemXmlObj; }
/** * Set store items to xml object by nesting level * * @param Mage_XmlConnect_Model_Simplexml_Element $storeSwitcherXmlObj * @param Mage_XmlConnect_Model_Simplexml_Element $switcherItemsXmlObj * @param array $website * @param array $group * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_StoreSwitcher */ protected function _setStoreItemsByNestingLevel($storeSwitcherXmlObj, $switcherItemsXmlObj, $website, $group) { $showWebsite = $showGroup = false; foreach ($this->getStores($group) as $store) { if ($showWebsite == false) { $showWebsite = true; $this->_addSwitcherItem($switcherItemsXmlObj, null, array('label' => $website->getName(), 'level' => 1), true); } if ($showGroup == false) { $showGroup = true; $this->_addSwitcherItem($switcherItemsXmlObj, null, array('label' => $group->getName(), 'level' => 2), true); } if ($this->getStoreId() == $store->getId()) { $storeSwitcherXmlObj->addAttribute('value', $this->getStoreId()); } $this->_addSwitcherItem($switcherItemsXmlObj, $store->getId(), array('label' => $store->getName(), 'level' => 3)); } return $this; }
/** * 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(); }