mighi Posted February 3, 2014 Share Posted February 3, 2014 Ciao a tutti, sto facendo un sito con Prestashop 1.5.6.1 Ho un problema che riguarda i prezzi specifici, in sostanza ho un prodotto che ad esempio costa 10€. A questo prodotto ho impostato diversi attributi ad esempio colore e tipo di stampa, impostando un prezzo solo a quest'ultima. Avendo la necessità di fare degli sconti in base alla quantità scelta, ho impostato nei prezzi specifici degli sconti a tutte le possibili combinazioni. Tutto funziona perfettamente ad eccezione del fatto che se vado nella pagina del prodotto nel FO i prezzi cambiano solo in base alla combinazione, io vorrei che cambiasse anche in base alla quantità e quindi che venisse mostrato il prezzo con una diminuzione se ad esempio scelgo di prendere 50 o 100 prodotti. Qualcuno ha già avuto a che fare con un problema del genere??? in giro ho trovato questo ma non mi funziona : http://www.prestashop.com/forums/topic/230544-use-ajax-cart-script-to-product-page/ Link to comment Share on other sites More sharing options...
mighi Posted March 15, 2014 Author Share Posted March 15, 2014 Come al solito sul forum italiano tutto tace... Se a qualcuno interesso ho risolto sta cosa del cambio di prezzo in base alla quantià in product.tpl, basta aggiungere questo codice alla fine del file product.js (url_tema/js/product.js) $(document).ready(function(){ $("#quantity_wanted").on("input",function(){ if (!selectedCombination['unavailable'] && productShowPrice == 1){ var priceTaxExclWithoutGroupReduction = ''; // retrieve price without group_reduction in order to compute the group reduction after // the specific price discount (done in the JS in order to keep backward compatibility) priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction); var tax = (taxRate / 100) + 1; var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate); if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute']) { if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0) var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate); else var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate); } else if (product_specific_price.price && product_specific_price.price >= 0) var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate); if (!displayPrice && !noTaxForThisProduct) productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var else productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction; var reduction = 0; if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent) { reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate); reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price; if (reduction_price && (displayPrice || noTaxForThisProduct)) reduction = ps_round(reduction / tax, 6); } else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price) { if (product_specific_price.reduction_type == 'amount') reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate); else reduction_price = 0; if (product_specific_price.reduction_type == 'percentage') reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction); reduction = reduction_price + reduction_percent; if (reduction_price && (displayPrice || noTaxForThisProduct)) reduction = ps_round(reduction / tax, 6); } if (selectedCombination.specific_price) { if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage') { $('#reduction_amount').hide(); $('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%'); $('#reduction_percent').show(); } else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) { $('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank)); $('#reduction_percent').hide(); $('#reduction_amount').show(); } else { $('#reduction_percent').hide(); $('#reduction_amount').hide(); } } if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '') $('#discount_reduced_price,#old_price').show(); else $('#discount_reduced_price,#old_price').hide(); if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage') $('#reduction_percent').show(); else $('#reduction_percent').hide(); if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price'])) $('#not_impacted_by_discount').show(); else $('#not_impacted_by_discount').hide(); productPriceDisplay -= reduction; productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2); var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax']; if (ecotaxAmount != default_eco_tax) productPriceDisplay += ecotaxAmount - default_eco_tax; else productPriceDisplay += ecotaxAmount; if (ecotaxAmount != default_eco_tax) productPriceWithoutReductionDisplay += ecotaxAmount - default_eco_tax; else productPriceWithoutReductionDisplay += ecotaxAmount; var our_price = ''; if (productPriceDisplay > 0) { our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank); } else { our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank); } $('#our_price_display').text(our_price); $('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank)); if (productPriceWithoutReductionDisplay > productPriceDisplay) $('#old_price,#old_price_display,#old_price_display_taxes').show(); else $('#old_price,#old_price_display,#old_price_display_taxes').hide(); // Special feature: "Display product price tax excluded on product page" var productPricePretaxed = ''; if (!noTaxForThisProduct) productPricePretaxed = productPriceDisplay / tax; else productPricePretaxed = productPriceDisplay; } var val = $("#quantity_wanted").val(); var price = productPriceDisplay*val; var att_s = $('#group_2').val(); var att_c = $('#color_to_pick_list li.selected a').attr('id').replace("color_",""); var att_p = $('#group_6').val(); var id_prodotto = $('#product_page_product_id').val(); var quantita = $('#quantity_wanted').val(); $("#our_price_display").fadeOut(100).text(formatCurrency(price, currencyFormat, currencySign, currencyBlank)).fadeIn(100); }); }); Sono molto vicino a far cambiare il prezzo anche in base ai prezzi specifici, devo solo fare le query... 1 Link to comment Share on other sites More sharing options...
dibimedia Posted January 5, 2015 Share Posted January 5, 2015 Come al solito sul forum italiano tutto tace... Se a qualcuno interesso ho risolto sta cosa del cambio di prezzo in base alla quantià in product.tpl, basta aggiungere questo codice alla fine del file product.js (url_tema/js/product.js) $(document).ready(function(){ $("#quantity_wanted").on("input",function(){ if (!selectedCombination['unavailable'] && productShowPrice == 1){ var priceTaxExclWithoutGroupReduction = ''; // retrieve price without group_reduction in order to compute the group reduction after // the specific price discount (done in the JS in order to keep backward compatibility) priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction); var tax = (taxRate / 100) + 1; var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate); if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute']) { if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0) var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate); else var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate); } else if (product_specific_price.price && product_specific_price.price >= 0) var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate); if (!displayPrice && !noTaxForThisProduct) productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var else productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction; var reduction = 0; if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent) { reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate); reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price; if (reduction_price && (displayPrice || noTaxForThisProduct)) reduction = ps_round(reduction / tax, 6); } else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price) { if (product_specific_price.reduction_type == 'amount') reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate); else reduction_price = 0; if (product_specific_price.reduction_type == 'percentage') reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction); reduction = reduction_price + reduction_percent; if (reduction_price && (displayPrice || noTaxForThisProduct)) reduction = ps_round(reduction / tax, 6); } if (selectedCombination.specific_price) { if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage') { $('#reduction_amount').hide(); $('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%'); $('#reduction_percent').show(); } else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) { $('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank)); $('#reduction_percent').hide(); $('#reduction_amount').show(); } else { $('#reduction_percent').hide(); $('#reduction_amount').hide(); } } if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '') $('#discount_reduced_price,#old_price').show(); else $('#discount_reduced_price,#old_price').hide(); if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage') $('#reduction_percent').show(); else $('#reduction_percent').hide(); if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price'])) $('#not_impacted_by_discount').show(); else $('#not_impacted_by_discount').hide(); productPriceDisplay -= reduction; productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2); var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax']; if (ecotaxAmount != default_eco_tax) productPriceDisplay += ecotaxAmount - default_eco_tax; else productPriceDisplay += ecotaxAmount; if (ecotaxAmount != default_eco_tax) productPriceWithoutReductionDisplay += ecotaxAmount - default_eco_tax; else productPriceWithoutReductionDisplay += ecotaxAmount; var our_price = ''; if (productPriceDisplay > 0) { our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank); } else { our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank); } $('#our_price_display').text(our_price); $('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank)); if (productPriceWithoutReductionDisplay > productPriceDisplay) $('#old_price,#old_price_display,#old_price_display_taxes').show(); else $('#old_price,#old_price_display,#old_price_display_taxes').hide(); // Special feature: "Display product price tax excluded on product page" var productPricePretaxed = ''; if (!noTaxForThisProduct) productPricePretaxed = productPriceDisplay / tax; else productPricePretaxed = productPriceDisplay; } var val = $("#quantity_wanted").val(); var price = productPriceDisplay*val; var att_s = $('#group_2').val(); var att_c = $('#color_to_pick_list li.selected a').attr('id').replace("color_",""); var att_p = $('#group_6').val(); var id_prodotto = $('#product_page_product_id').val(); var quantita = $('#quantity_wanted').val(); $("#our_price_display").fadeOut(100).text(formatCurrency(price, currencyFormat, currencySign, currencyBlank)).fadeIn(100); }); }); Sono molto vicino a far cambiare il prezzo anche in base ai prezzi specifici, devo solo fare le query... Grazie per lo script Ho seguito le istruzioni, ma non succede niente... Link to comment Share on other sites More sharing options...
vladio Posted August 5, 2016 Share Posted August 5, 2016 Come al solito sul forum italiano tutto tace... Se a qualcuno interesso ho risolto sta cosa del cambio di prezzo in base alla quantià in product.tpl, basta aggiungere questo codice alla fine del file product.js (url_tema/js/product.js) $(document).ready(function(){ $("#quantity_wanted").on("input",function(){ if (!selectedCombination['unavailable'] && productShowPrice == 1){ var priceTaxExclWithoutGroupReduction = ''; // retrieve price without group_reduction in order to compute the group reduction after // the specific price discount (done in the JS in order to keep backward compatibility) priceTaxExclWithoutGroupReduction = ps_round(productPriceTaxExcluded, 6) * (1 / group_reduction); var tax = (taxRate / 100) + 1; var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate); if (selectedCombination.specific_price && selectedCombination.specific_price['id_product_attribute']) { if (selectedCombination.specific_price['price'] && selectedCombination.specific_price['price'] >=0) var taxExclPrice = (specific_currency ? selectedCombination.specific_price['price'] : selectedCombination.specific_price['price'] * currencyRate); else var taxExclPrice = productBasePriceTaxExcluded * currencyRate + (selectedCombination['price'] * currencyRate); } else if (product_specific_price.price && product_specific_price.price >= 0) var taxExclPrice = (specific_currency ? product_specific_price.price : product_specific_price.price * currencyRate) + (selectedCombination['price'] * currencyRate); if (!displayPrice && !noTaxForThisProduct) productPriceDisplay = ps_round(taxExclPrice * tax, 2); // Need to be global => no var else productPriceDisplay = ps_round(taxExclPrice, 2); // Need to be global => no var productPriceWithoutReductionDisplay = productPriceDisplay * group_reduction; var reduction = 0; if (selectedCombination['specific_price'].reduction_price || selectedCombination['specific_price'].reduction_percent) { reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate); reduction = productPriceDisplay * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + reduction_price; if (reduction_price && (displayPrice || noTaxForThisProduct)) reduction = ps_round(reduction / tax, 6); } else if (product_specific_price && product_specific_price.reduction && !selectedCombination.specific_price) { if (product_specific_price.reduction_type == 'amount') reduction_price = (specific_currency ? product_specific_price.reduction : product_specific_price.reduction * currencyRate); else reduction_price = 0; if (product_specific_price.reduction_type == 'percentage') reduction_percent = productPriceDisplay * parseFloat(product_specific_price.reduction); reduction = reduction_price + reduction_percent; if (reduction_price && (displayPrice || noTaxForThisProduct)) reduction = ps_round(reduction / tax, 6); } if (selectedCombination.specific_price) { if (selectedCombination['specific_price'] && selectedCombination['specific_price'].reduction_type == 'percentage') { $('#reduction_amount').hide(); $('#reduction_percent_display').html('-' + parseFloat(selectedCombination['specific_price'].reduction_percent) + '%'); $('#reduction_percent').show(); } else if (selectedCombination['specific_price'].reduction_type == 'amount' && selectedCombination['specific_price'].reduction_price != 0) { $('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank)); $('#reduction_percent').hide(); $('#reduction_amount').show(); } else { $('#reduction_percent').hide(); $('#reduction_amount').hide(); } } if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '') $('#discount_reduced_price,#old_price').show(); else $('#discount_reduced_price,#old_price').hide(); if ((product_specific_price['reduction_type'] == 'percentage' && selectedCombination['specific_price'].reduction_type == 'percentage') || selectedCombination['specific_price'].reduction_type == 'percentage') $('#reduction_percent').show(); else $('#reduction_percent').hide(); if (product_specific_price['price'] || (selectedCombination.specific_price && selectedCombination.specific_price['price'])) $('#not_impacted_by_discount').show(); else $('#not_impacted_by_discount').hide(); productPriceDisplay -= reduction; productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2); var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax']; if (ecotaxAmount != default_eco_tax) productPriceDisplay += ecotaxAmount - default_eco_tax; else productPriceDisplay += ecotaxAmount; if (ecotaxAmount != default_eco_tax) productPriceWithoutReductionDisplay += ecotaxAmount - default_eco_tax; else productPriceWithoutReductionDisplay += ecotaxAmount; var our_price = ''; if (productPriceDisplay > 0) { our_price = formatCurrency(productPriceDisplay, currencyFormat, currencySign, currencyBlank); } else { our_price = formatCurrency(0, currencyFormat, currencySign, currencyBlank); } $('#our_price_display').text(our_price); $('#old_price_display').text(formatCurrency(productPriceWithoutReductionDisplay, currencyFormat, currencySign, currencyBlank)); if (productPriceWithoutReductionDisplay > productPriceDisplay) $('#old_price,#old_price_display,#old_price_display_taxes').show(); else $('#old_price,#old_price_display,#old_price_display_taxes').hide(); // Special feature: "Display product price tax excluded on product page" var productPricePretaxed = ''; if (!noTaxForThisProduct) productPricePretaxed = productPriceDisplay / tax; else productPricePretaxed = productPriceDisplay; } var val = $("#quantity_wanted").val(); var price = productPriceDisplay*val; var att_s = $('#group_2').val(); var att_c = $('#color_to_pick_list li.selected a').attr('id').replace("color_",""); var att_p = $('#group_6').val(); var id_prodotto = $('#product_page_product_id').val(); var quantita = $('#quantity_wanted').val(); $("#our_price_display").fadeOut(100).text(formatCurrency(price, currencyFormat, currencySign, currencyBlank)).fadeIn(100); }); }); Sono molto vicino a far cambiare il prezzo anche in base ai prezzi specifici, devo solo fare le query... ciao hai risoltocon il problema. io ho lo stesso ma con le combinazioni non mi cambia prezzo. ho trovato un file product.zip sul forum inglese ma non mi fa fare download. se ci sei riuscito mi fai sapere come? grazie mille Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now