2012-11-22 28 views
6

Magento के 1.6+ संस्करणों में एक उत्कृष्ट बग है जहां एक विकल्प का चयन होने पर स्तरीय कीमतों के लिए% बचत 100% तक डिफ़ॉल्ट हो जाती है। अन्य भागीदारों मेंMagento स्तरीय कीमतें - वाई के लिए एक्स एक्स में स्तरीय मूल्य के लिए कक्षा घोषणा - जावास्क्रिप्ट

for (var i = 0; i < this.tierPrices.length; i++) { 

से लाइन 747 के आसपास product.js बदलते

for (var i = 0; i > this.tierPrices.length; i++) { 

यह% बचत के साथ समस्या का समाधान होता लेकिन यह है कि कोड ब्लॉक मार डाला कभी नहीं रहा है होना करने के लिए सुझाव दिया है। मैं जावास्क्रिप्ट विशेषज्ञ का कोई मतलब नहीं हूं लेकिन विकल्प चुनने पर यह ब्लॉक स्तरीय मूल्य और% बचत को अपडेट कर रहा है। मैं 'टिप्पणी करने' की बजाय, इस मुद्दे की जड़ खोजना चाहता था।

फायरबग में मेरे डिबगिंग से मैंने देखा कि स्तरीय मूल्य के लिए वर्ग product.js में गलत है और इसलिए, 0 की एक स्तरीय कीमत पुनर्प्राप्त की जाती है, जिसके कारण% बचत हमेशा 100% होती है। Firebug,

class="tier-prices product-pricing"> 
     Buy 10 for 
     <span class="price">$40.00</span> 

के रूप में कीमत product.js आप

$$('.tier-prices .price).each(function (el) { 

स्तरीय मूल्य लिया गया है करने के लिए ऊपर बदलते हैं तो

$$('.price.tier-' + i).each(function (el) { 

का उपयोग कर वस्तुओं प्राप्त करने का प्रयास किया जाता है जबकि चलता लेकिन किसी उत्पाद पर एक से अधिक स्तरीय मूल्य के लिए, उन्हें अलग-अलग संदर्भित करने का कोई तरीका नहीं है। उपरोक्त वर्ग "मूल्य" में एक अद्वितीय पहचानकर्ता या पुनरावृत्ति संख्या घोषित नहीं है।

श्रेणी = "कीमत" कहां श्रेणी के लिए घोषित किया गया है? tierprices.phtml के कोड में यह इस

<?php echo $this->__('Buy %1$s for %2$s each', $_price['price_qty'], $_price['formated_price'])?> 
+0

अच्छा सवाल है कि –

उत्तर

6

मैंने इस पर कुछ समय बिताया है क्योंकि मैंने ग्राहक की Magento साइट को 1.7.0.2 तक अपग्रेड करने के बाद वास्तव में मुझे बग शुरू कर दिया था।

इसमें दो भाग हैं, मैं स्थानों और फिक्सेस को बताने जा रहा हूं, लेकिन ये सबूत अपग्रेड नहीं होंगे (इसके लिए आप फ़ाइलों की प्रतियां बनाना और उन्हें अपने थीम विशिष्ट फ़ोल्डरों में रखना चाहते हैं , हालांकि मुझे यकीन नहीं है कि जेएस फ़ाइल के साथ सवाल संभव है या नहीं)।

1) देखें फिक्स

फ़ाइल /design/frontend/base/default/template/catalog/product/view/tierprices.phtml

आप लाइनों 32-34

$_product = $this->getProduct(); 
$_tierPrices = $this->getTierPrices(); 
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true); 

निम्न कोड के साथ प्रतिस्थापित करना होगा:

$_product = $this->getProduct(); 
$_tierPrices = array(); 

foreach($this->getTierPrices() as $index => $info) { 
    $_tierPrices[$index] = $info; 
    $_tierPrices[$index]['formated_price'] = str_replace('class="price"', 'class="price tier-'.$index.'"', $info['formated_price']); 
    $_tierPrices[$index]['formated_price_incl_tax'] = str_replace('class="price"', 'class="price tier-'.$index.' tier-'.$index.'-incl-tax"', $info['formated_price_incl_tax']); 
} 
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true); 

यह ठीक करता है के साथ मुद्दे कक्षा को ठीक से प्रस्तुत नहीं किया जा रहा है जैसा कि आप पहले ही पता लगा चुके थे। Here is where I found this code - हालांकि यह सभी मुद्दों को ठीक नहीं करता है, इसलिए जेएस बदलता है।

2) जे एस

फ़ाइल में

ठीक js/Varien/product.js आप लाइनों 757-769 प्रतिस्थापित करने की आवश्यकता:

$$('.benefit').each(function (el) { 
    var parsePrice = function (html) { 
     return parseFloat(/\d+\.?\d*/.exec(html)); 
    }; 
    var container = $(this.containers[3]) ? this.containers[3] : this.containers[0]; 
    var price = parsePrice($(container).innerHTML); 
    var tierPrice = $$('.price.tier-' + i); 
    tierPrice = tierPrice.length ? parseInt(tierPrice[0].innerHTML, 10) : 0; 
    var $percent = Selector.findChildElements(el, ['.percent.tier-' + i]); 
    $percent.each(function (el) { 
     el.innerHTML = Math.ceil(100 - ((100/price) * tierPrice)); 
    }); 
}, this); 
इस के साथ

:

// 
// Code fixed to prevent the redundant inner loop and to use actual tiered pricing in calculation 
// It also takes the optional price variants into consideration (eg: +£2 for a blue tshirt) 
// Note: I've made this comment deliberately large, to keep the line numbers in sync 
// 
var parsePrice = function (html) { 
    return parseFloat(/\d+\.?\d*/.exec(html)); 
}; 
var container = $(this.containers[3]) ? this.containers[3] : this.containers[0]; 
var price = parsePrice($(container).innerHTML); 
$$('.percent.tier-' + i).each(function (el) { 
    el.innerHTML = Math.ceil(100 - ((100/price) * (this.tierPrices[i] + parseFloat(optionPrices)))); 
}, this); 

मुझे आशा है कि यह कम से कम एक व्यक्ति की बचत होती है उनके जीवन के कुछ घंटे।

टी

+1

धन्यवाद Tr1stan के लिए +1, एक इलाज काम करता है। – GenAtBlueJalappeno

+0

धन्यवाद, बहुत अच्छा काम किया। अगर आपकी त्वचा में कस्टम product.js है तो भूलें मत आपको इसे संशोधित करना चाहिए। – Jonathan

+0

धन्यवाद, आपने मुझे बहुत समय बचाया! – fahu

0

की तरह लग रहा हिस्सा class="price"Mage_Directory_Model_Currency::formatPrecision() से परिणाम है और मार डाला जब $this->formatPrice() या गहरी मॉडल परतों में कीमत Mage::helper('core')->formatPrice();

आप जोड़ सकते हैं साथ स्वरूपित है Mage_Directory_Model_Currency को विस्तारित (और पुनः लिखने) द्वारा अद्वितीय पहचानकर्ता लेकिन ध्यान रखें कि formatPrecision हर जगह उपयोग किया जाता है। तो आप स्तरीय कीमतों को स्वरूपित करने के लिए अपना स्वयं का सहायक/मॉडल तर्क लिख सकते हैं।

संबंधित मुद्दे