updatePrice

This commit is contained in:
Michael RICOIS 2017-09-22 14:50:39 +02:00
parent a96a6037ab
commit bde9585919
2 changed files with 25 additions and 5 deletions

View File

@ -1,4 +1,5 @@
$(function(){
/*
$('.configurator-opt-change').on('change', function(e) {
$.post($(this).data('url'), $('form#buy_block').serialize(), function (data) {
$('span#our_price_display').replaceWith('<span id="our_price_display" class="price" itemprop="price" content="'+data.price+'">'+data.priceDisplay+'</span>');
@ -9,6 +10,14 @@ $(function(){
$('span#our_price_display').replaceWith('<span id="our_price_display" class="price" itemprop="price" content="'+data.price+'">'+data.priceDisplay+'</span>');
}, 'json').fail(function(){});
});
*/
$('.configurator-opt-change').on('change', function(e) {
updatePrice();
});
$('.configurator-opt-click').on('click', function(e){
updatePrice();
});
$('.configurator-opt-datepicker').datepicker({dateFormat: "dd/mm/yy"});
$('.configurator-opt-file').fileupload({
@ -34,7 +43,6 @@ $(function(){
for (var i=0; i<inputElems.length; i++) {
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true){
count++;
console.log(count);
if (count > 1) {
$(this).prop('checked', false);
$(this).parent().removeClass('checked');
@ -49,7 +57,6 @@ $(function(){
for (var i=0; i<inputElems.length; i++) {
if (inputElems[i].type === "checkbox" && inputElems[i].checked === true){
count++;
console.log(count);
if (count > 2) {
$(this).prop('checked', false);
$(this).parent().removeClass('checked');

View File

@ -705,7 +705,6 @@ function updatePrice()
}
}
// Apply Tax if necessary
if (noTaxForThisProduct || customerGroupWithoutTax)
{
@ -766,6 +765,20 @@ function updatePrice()
unit_price = priceWithDiscountsDisplay / productUnitPriceRatio;
}
var forfaitAlreadyAdd = false
$('input[data-price]').each(function() {
if ($(this).attr('type') === "checkbox" && $(this).prop('checked') === true) {
if ($(this).attr('id').substr(0,7) == 'PARFUMS') {
if (forfaitAlreadyAdd === false) {
priceWithDiscountsDisplay = priceWithDiscountsDisplay + parseFloat($(this).data('price'));
forfaitAlreadyAdd = true;
}
} else {
priceWithDiscountsDisplay = priceWithDiscountsDisplay + parseFloat($(this).data('price'));
}
}
});
/* Update the page content, no price calculation happens after */
// Hide everything then show what needs to be shown