public function getJsonConfig() { Mage::app()->getLocale()->getJsPriceFormat(); $store = Mage::app()->getStore(); $optionsArray = $this->getOptions(); $options = array(); $selected = array(); foreach ($optionsArray as $_option) { if (!$_option->getSelections()) { continue; } $option = array('selections' => array(), 'title' => $_option->getTitle(), 'isMulti' => $_option->getType() == 'multi' || $_option->getType() == 'checkbox'); $selectionCount = count($_option->getSelections()); foreach ($_option->getSelections() as $_selection) { $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1; $selection = array('qty' => $_qty, 'customQty' => $_selection->getSelectionCanChangeQty(), 'price' => Mage::helper('core')->currency($_selection->getFinalPrice(), false, false), 'priceValue' => Mage::helper('core')->currency($_selection->getSelectionPriceValue(), false, false), 'priceType' => $_selection->getSelectionPriceType(), 'tierPrice' => $_selection->getTierPrice(), 'name' => $_selection->getName(), 'plusDisposition' => 0, 'minusDisposition' => 0); $responseObject = new Varien_Object(); $args = array('response_object' => $responseObject, 'selection' => $_selection); Mage::dispatchEvent('bundle_product_view_config', $args); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $o => $v) { $selection[$o] = $v; } } $option['selections'][$_selection->getSelectionId()] = $selection; if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) { $selected[$_option->getId()][] = $_selection->getSelectionId(); } } $options[$_option->getId()] = $option; } $config = array('options' => $options, 'selected' => $selected, 'bundleId' => $this->getProduct()->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'basePrice' => Mage::helper('core')->currency($this->getProduct()->getPrice(), false, false), 'priceType' => $this->getProduct()->getPriceType(), 'specialPrice' => $this->getProduct()->getSpecialPrice()); return Mage::helper('core')->jsonEncode($config); }
public function _getJsonConfig() { $config = array(); if (!$this->hasOptions()) { return Mage::helper('core')->jsonEncode($config); } $_request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false); /* @var $product Mage_Catalog_Model_Product */ $product = $this->getProduct(); $_request->setProductClassId($product->getTaxClassId()); $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request); $_request = Mage::getSingleton('tax/calculation')->getRateRequest(); $_request->setProductClassId($product->getTaxClassId()); $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request); $_regularPrice = $product->getPrice(); $_finalPrice = $product->getFinalPrice(); $_priceInclTax = Mage::helper('tax')->getPrice($product, $_finalPrice, true); $_priceExclTax = Mage::helper('tax')->getPrice($product, $_finalPrice); $_tierPrices = array(); $_tierPricesInclTax = array(); foreach ($product->getTierPrice() as $tierPrice) { $_tierPrices[] = Mage::helper('core')->currency($tierPrice['website_price'], false, false); $_tierPricesInclTax[] = Mage::helper('core')->currency(Mage::helper('tax')->getPrice($product, (int) $tierPrice['website_price'], true), false, false); } $config = array('productId' => $product->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(), 'showBothPrices' => Mage::helper('tax')->displayBothPrices(), 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false), 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false), 'priceInclTax' => Mage::helper('core')->currency($_priceInclTax, false, false), 'priceExclTax' => Mage::helper('core')->currency($_priceExclTax, false, false), 'skipCalculate' => $_priceExclTax != $_priceInclTax ? 0 : 1, 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'idSuffix' => '_cloneover', 'oldPlusDisposition' => 0, 'plusDisposition' => 0, 'plusDispositionTax' => 0, 'oldMinusDisposition' => 0, 'minusDisposition' => 0, 'tierPrices' => $_tierPrices, 'tierPricesInclTax' => $_tierPricesInclTax); $responseObject = new Varien_Object(); Mage::dispatchEvent('catalog_product_view_config', array('response_object' => $responseObject)); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $option => $value) { $config[$option] = $value; } } return Mage::helper('core')->jsonEncode($config); }
/** * Get JSON encripted configuration array which can be used for JS dynamic * price calculation depending on product options * * @return string */ public function getJsonConfig() { if (!Mage::helper('rewards')->isBaseMageVersionAtLeast('1.4')) { return parent::getJsonConfig(); } $config = array(); $_request = Mage::getSingleton('tax/calculation')->getRateRequest(false, false, false); $_request->setProductClassId($this->getProduct()->getTaxClassId()); $defaultTax = Mage::getSingleton('tax/calculation')->getRate($_request); $_request = Mage::getSingleton('tax/calculation')->getRateRequest(); $_request->setProductClassId($this->getProduct()->getTaxClassId()); $currentTax = Mage::getSingleton('tax/calculation')->getRate($_request); $_regularPrice = $this->getProduct()->getPrice(); $_finalPrice = $this->getProduct()->getFinalPrice(); $_priceInclTax = Mage::helper('tax')->getPrice($this->getProduct(), $_finalPrice, true); $_priceExclTax = Mage::helper('tax')->getPrice($this->getProduct(), $_finalPrice); $config = array('productId' => $this->getProduct()->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', 'showIncludeTax' => Mage::helper('tax')->displayPriceIncludingTax(), 'showBothPrices' => Mage::helper('tax')->displayBothPrices(), 'productPrice' => Mage::helper('core')->currency($_finalPrice, false, false), 'productOldPrice' => Mage::helper('core')->currency($_regularPrice, false, false), 'skipCalculate' => $_priceExclTax != $_priceInclTax ? 0 : 1, 'defaultTax' => $defaultTax, 'currentTax' => $currentTax, 'idSuffix' => '_clone', 'oldPlusDisposition' => 0, 'plusDisposition' => 0, 'oldMinusDisposition' => 0, 'minusDisposition' => 0); $responseObject = new Varien_Object(); Mage::dispatchEvent('catalog_product_view_config', array('response_object' => $responseObject)); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $option => $value) { $config[$option] = $value; } } return Mage::helper('core')->jsonEncode($config); }
/** * Returns JSON encoded config to be used in JS scripts * * @return string */ public function getJsonConfig() { Mage::app()->getLocale()->getJsPriceFormat(); $optionsArray = $this->getOptions(); $options = array(); $selected = array(); $currentProduct = $this->getProduct(); /* @var $coreHelper Mage_Core_Helper_Data */ $coreHelper = Mage::helper('core'); /* @var $bundlePriceModel Mage_Bundle_Model_Product_Price */ $bundlePriceModel = Mage::getModel('bundle/product_price'); $preConfiguredFlag = $currentProduct->hasPreconfiguredValues(); if ($preConfiguredFlag) { $preConfiguredValues = $currentProduct->getPreconfiguredValues(); $defaultValues = array(); } $position = 0; foreach ($optionsArray as $_option) { /* @var $_option Mage_Bundle_Model_Option */ if (!$_option->getSelections()) { continue; } $optionId = $_option->getId(); $option = array('selections' => array(), 'title' => $_option->getTitle(), 'isMulti' => in_array($_option->getType(), array('multi', 'checkbox')), 'position' => $position++); $selectionCount = count($_option->getSelections()); /** @var $taxHelper Mage_Tax_Helper_Data */ $taxHelper = Mage::helper('tax'); foreach ($_option->getSelections() as $_selection) { /* @var $_selection Mage_Catalog_Model_Product */ $selectionId = $_selection->getSelectionId(); $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1; // recalculate currency $tierPrices = $_selection->getTierPrice(); foreach ($tierPrices as &$tierPriceInfo) { $tierPriceInfo['price'] = $bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['price']); $tierPriceInfo['website_price'] = $bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['website_price']); $tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false); $tierPriceInfo['priceInclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], true, null, null, null, null, null, false); $tierPriceInfo['priceExclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], false, null, null, null, null, null, false); } unset($tierPriceInfo); // break the reference with the last element $itemPrice = $bundlePriceModel->getSelectionFinalTotalPrice($currentProduct, $_selection, $currentProduct->getQty(), $_selection->getQty(), false, false); $canApplyMAP = false; /* @var $taxHelper Mage_Tax_Helper_Data */ $taxHelper = Mage::helper('tax'); $_priceInclTax = $taxHelper->getPrice($_selection, $itemPrice, true, null, null, null, null, null, false); $_priceExclTax = $taxHelper->getPrice($_selection, $itemPrice, false, null, null, null, null, null, false); if ($currentProduct->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) { $_priceInclTax = $taxHelper->getPrice($currentProduct, $itemPrice, true, null, null, null, null, null, false); $_priceExclTax = $taxHelper->getPrice($currentProduct, $itemPrice, false, null, null, null, null, null, false); } $selection = array('qty' => $_qty, 'customQty' => $_selection->getSelectionCanChangeQty(), 'price' => $coreHelper->currency($_selection->getFinalPrice(), false, false), 'priceInclTax' => $coreHelper->currency($_priceInclTax, false, false), 'priceExclTax' => $coreHelper->currency($_priceExclTax, false, false), 'priceValue' => $coreHelper->currency($_selection->getSelectionPriceValue(), false, false), 'priceType' => $_selection->getSelectionPriceType(), 'tierPrice' => $tierPrices, 'name' => $_selection->getName(), 'plusDisposition' => 0, 'minusDisposition' => 0, 'canApplyMAP' => $canApplyMAP, 'tierPriceHtml' => $this->getTierPriceHtml($_selection, $currentProduct)); $responseObject = new Varien_Object(); $args = array('response_object' => $responseObject, 'selection' => $_selection); Mage::dispatchEvent('bundle_product_view_config', $args); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $o => $v) { $selection[$o] = $v; } } $option['selections'][$selectionId] = $selection; if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) { $selected[$optionId][] = $selectionId; } } $options[$optionId] = $option; // Add attribute default value (if set) if ($preConfiguredFlag) { $configValue = $preConfiguredValues->getData('bundle_option/' . $optionId); if ($configValue) { $defaultValues[$optionId] = $configValue; } } } $config = array('options' => $options, 'selected' => $selected, 'bundleId' => $currentProduct->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'basePrice' => $coreHelper->currency($currentProduct->getPrice(), false, false), 'priceType' => $currentProduct->getPriceType(), 'specialPrice' => $currentProduct->getSpecialPrice(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', 'isFixedPrice' => $this->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED, 'isMAPAppliedDirectly' => Mage::helper('catalog')->canApplyMsrp($this->getProduct(), null, false)); if ($preConfiguredFlag && !empty($defaultValues)) { $config['defaultValues'] = $defaultValues; } return $coreHelper->jsonEncode($config); }
public function getJsonConfig() { Mage::app()->getLocale()->getJsPriceFormat(); $optionsArray = $this->getOptions(); $options = array(); $selected = array(); $currentProduct = $this->getProduct(); $coreHelper = Mage::helper('core'); if ($preconfiguredFlag = $currentProduct->hasPreconfiguredValues()) { $preconfiguredValues = $currentProduct->getPreconfiguredValues(); $defaultValues = array(); } foreach ($optionsArray as $_option) { if (!$_option->getSelections()) { continue; } $optionId = $_option->getId(); $option = array('selections' => array(), 'title' => $_option->getTitle(), 'isMulti' => in_array($_option->getType(), array('multi', 'checkbox'))); $selectionCount = count($_option->getSelections()); foreach ($_option->getSelections() as $_selection) { $selectionId = $_selection->getSelectionId(); $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1; // recalculate currency $tierPrices = $_selection->getTierPrice(); foreach ($tierPrices as &$tierPriceInfo) { $tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false); } unset($tierPriceInfo); // break the reference with the last element $taxPercent = 0; $taxClassId = $_selection->getTaxClassId(); if ($taxClassId) { $request = Mage::getSingleton('tax/calculation')->getRateRequest(); $taxPercent = Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxClassId)); } $selection = array('qty' => $_qty, 'customQty' => $_selection->getSelectionCanChangeQty(), 'price' => $coreHelper->currency($_selection->getFinalPrice(), false, false), 'taxPercent' => $taxPercent, 'priceValue' => $coreHelper->currency($_selection->getSelectionPriceValue(), false, false), 'priceType' => $_selection->getSelectionPriceType(), 'tierPrice' => $tierPrices, 'name' => $_selection->getName(), 'plusDisposition' => 0, 'minusDisposition' => 0); $responseObject = new Varien_Object(); $args = array('response_object' => $responseObject, 'selection' => $_selection); Mage::dispatchEvent('bundle_product_view_config', $args); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $o => $v) { $selection[$o] = $v; } } $option['selections'][$selectionId] = $selection; if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) { $selected[$optionId][] = $selectionId; } } $options[$optionId] = $option; // Add attribute default value (if set) if ($preconfiguredFlag) { $configValue = $preconfiguredValues->getData('bundle_option/' . $optionId); if ($configValue) { $defaultValues[$optionId] = $configValue; } } } $config = array('options' => $options, 'selected' => $selected, 'bundleId' => $currentProduct->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'basePrice' => $coreHelper->currency($currentProduct->getPrice(), false, false), 'priceType' => $currentProduct->getPriceType(), 'specialPrice' => $currentProduct->getSpecialPrice(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false'); if ($preconfiguredFlag && !empty($defaultValues)) { $config['defaultValues'] = $defaultValues; } return $coreHelper->jsonEncode($config); }
/** * Returns JSON encoded config to be used in JS scripts * * @return string */ public function getJsonConfig() { Mage::app()->getLocale()->getJsPriceFormat(); $optionsArray = $this->getOptions(); $options = array(); $selected = array(); $currentProduct = $this->getProduct(); /* @var $coreHelper Mage_Core_Helper_Data */ $coreHelper = Mage::helper('core'); /* @var $bundlePriceModel Mage_Bundle_Model_Product_Price */ $bundlePriceModel = Mage::getModel('bundle/product_price'); $preConfiguredFlag = $currentProduct->hasPreconfiguredValues(); if ($preConfiguredFlag) { $preConfiguredValues = $currentProduct->getPreconfiguredValues(); $defaultValues = array(); } $position = 0; foreach ($optionsArray as $_option) { /* @var $_option Mage_Bundle_Model_Option */ if (!$_option->getSelections()) { continue; } $optionId = $_option->getId(); $option = array('selections' => array(), 'title' => $_option->getTitle(), 'isMulti' => in_array($_option->getType(), array('multi', 'checkbox')), 'position' => $position++); $selectionCount = count($_option->getSelections()); /** @var $taxHelper Mage_Tax_Helper_Data */ $taxHelper = Mage::helper('tax'); foreach ($_option->getSelections() as $_selection) { /* @var $_selection Mage_Catalog_Model_Product */ $selectionId = $_selection->getSelectionId(); $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1; // recalculate currency $tierPrices = $_selection->getTierPrice(); foreach ($tierPrices as &$tierPriceInfo) { $tierPriceInfo['price'] = $bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['price']); $tierPriceInfo['website_price'] = $bundlePriceModel->getLowestPrice($currentProduct, $tierPriceInfo['website_price']); $tierPriceInfo['price'] = $coreHelper->currency($tierPriceInfo['price'], false, false); $tierPriceInfo['priceInclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], true, null, null, null, null, null, false); $tierPriceInfo['priceExclTax'] = $taxHelper->getPrice($_selection, $tierPriceInfo['price'], false, null, null, null, null, null, false); } unset($tierPriceInfo); // break the reference with the last element $itemPrice = $bundlePriceModel->getSelectionFinalTotalPrice($currentProduct, $_selection, $currentProduct->getQty(), $_selection->getQty(), false, false); $canApplyMAP = false; /* @var $taxHelper Mage_Tax_Helper_Data */ $taxHelper = Mage::helper('tax'); $_priceInclTax = $taxHelper->getPrice($_selection, $itemPrice, true, null, null, null, null, null, false); $_priceExclTax = $taxHelper->getPrice($_selection, $itemPrice, false, null, null, null, null, null, false); if ($currentProduct->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED) { $_priceInclTax = $taxHelper->getPrice($currentProduct, $itemPrice, true, null, null, null, null, null, false); $_priceExclTax = $taxHelper->getPrice($currentProduct, $itemPrice, false, null, null, null, null, null, false); } $_child_product = Mage::getModel('catalog/product')->load($_selection->product_id); $sizeValue = $_child_product->short_size; $articleCodeValue = $_child_product->article_code_new; if ($currentProduct->getAttributeSetId() == '9') { $fuelAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'fuel_efficiency'); $fuelOptionValue = $fuelAttributeDetails->getSource()->getOptionText($_child_product->fuel_efficiency); $wetAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'wet_grip'); $wetOptionValue = $wetAttributeDetails->getSource()->getOptionText($_child_product->wet_grip); $noiseOptionValue = $_child_product->noise; $diameterAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'diameter'); $diameterOptionValue = $diameterAttributeDetails->getSource()->getOptionText($_child_product->diameter); $widthAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'width'); $widthOptionValue = $widthAttributeDetails->getSource()->getOptionText($_child_product->width); $profileAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'profile'); $profileOptionValue = $profileAttributeDetails->getSource()->getOptionText($_child_product->profile); $boltCircleOptionValue = ''; $speedIndexDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'speed_index'); $speedIndexValue = $speedIndexDetails->getSource()->getOptionText($_child_product->speed_index); $loadCapacityDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'load_capacity'); $loadCapacityValue = $loadCapacityDetails->getSource()->getOptionText($_child_product->load_capacity); $etValue = ''; $center_hole = ''; $sku = ''; } else { $fuelOptionValue = ''; $noiseOptionValue = ''; $wetOptionValue = ''; $profileOptionValue = ''; $diameterAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'diameter'); $diameterOptionValue = $diameterAttributeDetails->getSource()->getOptionText($_child_product->diameter); $bltAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'bolt_circle'); $boltCircleOptionValue = $bltAttributeDetails->getSource()->getOptionText($_child_product->bolt_circle); $widthOptionValue = ''; $speedIndexValue = ''; $loadCapacityValue = ''; $etAttributeDetails = Mage::getSingleton("eav/config")->getAttribute("catalog_product", 'et_measurement'); $etValue = $etAttributeDetails->getSource()->getOptionText($_child_product->et_measurement); $center_hole = $_child_product->center_hole; $sku = $_child_product->sku; } $selection = array('qty' => $_qty, 'customQty' => $_selection->getSelectionCanChangeQty(), 'price' => $coreHelper->currency($_selection->getFinalPrice(), false, false), 'priceInclTax' => $coreHelper->currency($_priceInclTax, false, false), 'priceExclTax' => $coreHelper->currency($_priceExclTax, false, false), 'priceValue' => $coreHelper->currency($_selection->getSelectionPriceValue(), false, false), 'priceType' => $_selection->getSelectionPriceType(), 'tierPrice' => $tierPrices, 'name' => $_selection->getName(), 'plusDisposition' => 0, 'minusDisposition' => 0, 'canApplyMAP' => $canApplyMAP, 'tierPriceHtml' => $this->getTierPriceHtml($_selection, $currentProduct), 'product_id' => $_selection->product_id, 'fuel_efficiency' => $fuelOptionValue, 'wet_grip' => $wetOptionValue, 'noise' => $noiseOptionValue, 'bolt_circle' => $boltCircleOptionValue, 'size' => $sizeValue, 'article_code' => $articleCodeValue, 'speed_index' => $speedIndexValue, 'load_capacity' => $loadCapacityValue, 'et_measurement' => $etValue, 'center_hole' => $center_hole, 'sku' => $sku); $responseObject = new Varien_Object(); $args = array('response_object' => $responseObject, 'selection' => $_selection); Mage::dispatchEvent('bundle_product_view_config', $args); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $o => $v) { $selection[$o] = $v; } } $option['selections'][$selectionId] = $selection; if (Mage::app()->getRequest()->getQuery('option') != '') { $isDefault = Mage::app()->getRequest()->getQuery('option'); } else { $isDefault = $selectionId; } if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) { $selected[$optionId][] = $isDefault; } } $options[$optionId] = $option; // Add attribute default value (if set) if ($preConfiguredFlag) { $configValue = $preConfiguredValues->getData('bundle_option/' . $optionId); if ($configValue) { $defaultValues[$optionId] = $configValue; } } } $config = array('options' => $options, 'selected' => $selected, 'bundleId' => $currentProduct->getId(), 'priceFormat' => Mage::app()->getLocale()->getJsPriceFormat(), 'basePrice' => $coreHelper->currency($currentProduct->getPrice(), false, false), 'priceType' => $currentProduct->getPriceType(), 'specialPrice' => $currentProduct->getSpecialPrice(), 'includeTax' => Mage::helper('tax')->priceIncludesTax() ? 'true' : 'false', 'isFixedPrice' => $this->getProduct()->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED, 'isMAPAppliedDirectly' => Mage::helper('catalog')->canApplyMsrp($this->getProduct(), null, false)); if ($preConfiguredFlag && !empty($defaultValues)) { $config['defaultValues'] = $defaultValues; } return $coreHelper->jsonEncode($config); }
public function getJsBundlePoints($product) { Mage::app()->getLocale()->getJsPriceFormat(); $store = Mage::app()->getStore(); $optionsArray = $this->getOptions($product); $selected = array(); $pts_array = array(); $isPriceFixedType = $product->getPriceType() == Mage_Bundle_Model_Product_Price::PRICE_TYPE_FIXED; foreach ($optionsArray as $_option) { if (!$_option->getSelections()) { continue; } $selectionCount = count($_option->getSelections()); foreach ($_option->getSelections() as $_selection) { $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1; $price_tmp = $product->getPriceModel()->getSelectionPreFinalPrice($product, $_selection, 1); $subprice = $this->formatOptionPrice($price_tmp, $product); /*if (!Mage::helper('rewardpoints/data')->isCustomProductPoints($_selection)){ $pts = Mage::helper('rewardpoints/data')->convertProductMoneyToPoints(($subprice)); } else { $pts = Mage::helper('rewardpoints/data')->getProductPoints($_selection); } //BUNDLE FIX PRICE FIX $extra_points = Mage::getModel('rewardpoints/catalogpointrules')->getCatalogRulePointsGathered($product, $pts, Mage::app()->getStore()->getId(), 1, null, true); */ //BUNDLE FIX PRICE FIX //$item = $isPriceFixedType ? $product : $_selection; $item = $_selection; //$extra_points = Mage::getModel('rewardpoints/catalogpointrules')->getCatalogRulePointsGathered($product, $pts, Mage::app()->getStore()->getId(), 1, null, true); //getProductPoints($product, $noCeil = false, $from_list = false, $money_points = false, $tierprice_incl_tax = null, $tierprice_excl_tax = null) $tierprice_incl_tax = Mage::helper('tax')->getPrice($product, $subprice, true); $tierprice_excl_tax = Mage::helper('tax')->getPrice($product, $subprice); $current_point = ceil(Mage::helper('rewardpoints')->getProductPoints($item, false, true, false, (double) $tierprice_incl_tax, (double) $tierprice_excl_tax)); $selection = array('points' => $current_point, 'subprice' => $subprice, 'optionId' => $_option->getId()); $responseObject = new Varien_Object(); $args = array('response_object' => $responseObject, 'selection' => $_selection); Mage::dispatchEvent('bundle_product_view_config', $args); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $o => $v) { $selection[$o] = $v; } } $pts_array[$_selection->getSelectionId()] = $selection; if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) { $selected[$_option->getId()][] = $_selection->getSelectionId(); } } } if (version_compare(Mage::getVersion(), '1.4.0', '>=')) { return Mage::helper('core')->jsonEncode($pts_array); } else { return Zend_Json::encode($pts_array); } }
public function getJsBundlePoints($product) { Mage::app()->getLocale()->getJsPriceFormat(); $store = Mage::app()->getStore(); $optionsArray = $this->getOptions($product); $selected = array(); $pts_array = array(); foreach ($optionsArray as $_option) { if (!$_option->getSelections()) { continue; } $selectionCount = count($_option->getSelections()); foreach ($_option->getSelections() as $_selection) { $_qty = !($_selection->getSelectionQty() * 1) ? '1' : $_selection->getSelectionQty() * 1; $price_tmp = $product->getPriceModel()->getSelectionPreFinalPrice($product, $_selection, 1); $subprice = $this->formatOptionPrice($price_tmp, $product); if (!Mage::helper('rewardpoints/data')->isCustomProductPoints($_selection)) { $pts = Mage::helper('rewardpoints/data')->convertProductMoneyToPoints($subprice); } else { $pts = Mage::helper('rewardpoints/data')->getProductPoints($_selection); } $selection = array('points' => $pts, 'subprice' => $subprice, 'optionId' => $_option->getId()); $responseObject = new Varien_Object(); $args = array('response_object' => $responseObject, 'selection' => $_selection); Mage::dispatchEvent('bundle_product_view_config', $args); if (is_array($responseObject->getAdditionalOptions())) { foreach ($responseObject->getAdditionalOptions() as $o => $v) { $selection[$o] = $v; } } $pts_array[$_selection->getSelectionId()] = $selection; if (($_selection->getIsDefault() || $selectionCount == 1 && $_option->getRequired()) && $_selection->isSalable()) { $selected[$_option->getId()][] = $_selection->getSelectionId(); } } } if (version_compare(Mage::getVersion(), '1.4.0', '>=')) { return Mage::helper('core')->jsonEncode($pts_array); } else { return Zend_Json::encode($pts_array); } }