// Release branch merged

This commit is contained in:
François Gaillard
2013-03-27 10:25:16 +01:00
1089 changed files with 4260 additions and 52622 deletions
+18 -16
View File
@@ -25,17 +25,11 @@
$(document).ready(function()
{
// If block cart isn't used, we don't bind the handle actions
if (window.ajaxCart !== undefined)
{
$('.cart_quantity_up').unbind('click').live('click', function(){ upQuantity($(this).attr('id').replace('cart_quantity_up_', '')); return false; });
$('.cart_quantity_down').unbind('click').live('click', function(){ downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false; });
$('.cart_quantity_delete' ).unbind('click').live('click', function(){ deleteProductFromSummary($(this).attr('id')); return false; });
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el); } });
}
$('.cart_address_delivery').live('change', function(){ changeAddressDelivery($(this)); });
$('.cart_quantity_up').unbind('click').live('click', function(){upQuantity($(this).attr('id').replace('cart_quantity_up_', '')); return false;});
$('.cart_quantity_down').unbind('click').live('click', function(){downQuantity($(this).attr('id').replace('cart_quantity_down_', '')); return false;});
$('.cart_quantity_delete' ).unbind('click').live('click', function(){deleteProductFromSummary($(this).attr('id')); return false;});
$('.cart_quantity_input').typeWatch({highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el);}});
$('.cart_address_delivery').live('change', function(){changeAddressDelivery($(this));});
cleanSelectAddressDelivery();
});
@@ -149,9 +143,8 @@ function changeAddressDelivery(obj)
var id_address_delivery = 0;
var options = $('#select_address_delivery_'+id_product+'_'+id_product_attribute+'_'+old_id_address_delivery+' option');
$.each(options, function(i) {
if ($(options[i]).val() > 0 && $(options[i]).val() !== old_id_address_delivery
&& $('#product_' + id_product + '_' + id_product_attribute + '_0_' + $(options[i]).val()).length == 0 // Check the address is not already used for a similare products
)
// Check the address is not already used for a similare products
if ($(options[i]).val() > 0 && $(options[i]).val() !== old_id_address_delivery && $('#product_' + id_product + '_' + id_product_attribute + '_0_' + $(options[i]).val()).length == 0)
{
id_address_delivery = $(options[i]).val();
return false;
@@ -223,7 +216,8 @@ function updateAddressId(id_product, id_product_attribute, old_id_address_delive
});
});
line.attr('id', line.attr('id').replace(/_\d+$/, '_' + id_address_delivery)).removeClass('address_' + old_id_address_delivery).addClass('address_' + id_address_delivery).find('span[id^=cart_quantity_custom_], input[name^=quantity_], .cart_quantity_down, .cart_quantity_up, .cart_quantity_delete').each(function(){
line.attr('id', line.attr('id').replace(/_\d+$/, '_' + id_address_delivery)).removeClass('address_' + old_id_address_delivery).addClass('address_' + id_address_delivery).find('span[id^=cart_quantity_custom_], span[id^=total_product_price_], input[name^=quantity_], .cart_quantity_down, .cart_quantity_up, .cart_quantity_delete').each(function(){
if (typeof($(this).attr('name')) != 'undefined')
$(this).attr('name', $(this).attr('name').replace(/_\d+(_hidden|)$/, '_' + id_address_delivery));
if (typeof($(this).attr('id')) != 'undefined')
@@ -233,6 +227,14 @@ function updateAddressId(id_product, id_product_attribute, old_id_address_delive
});
line.find('#select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + old_id_address_delivery).attr('id', 'select_address_delivery_' + id_product + '_' + id_product_attribute + '_' + id_address_delivery);
if (window.ajaxCart !== undefined)
{
$('#cart_block_list dd, #cart_block_list dt').each(function(){
if (typeof($(this).attr('id')) != 'undefined')
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + id_address_delivery));
});
}
}
function updateQty(val, cart, el)
@@ -342,7 +344,7 @@ function deleteProductFromSummary(id)
if (jsonData.summary.products[i].id_product == productId
&& jsonData.summary.products[i].id_product_attribute == productAttributeId
&& jsonData.summary.products[i].id_address_delivery == id_address_delivery
&& (parseInt(jsonData.summary.products[i].customization_quantity) > 1))
&& (parseInt(jsonData.summary.products[i].customization_quantity) > 0))
exist = true;
}
// if all customization removed => delete product line
+10 -8
View File
@@ -142,7 +142,13 @@ function updateAddressSelection()
// Update global var deliveryAddress
deliveryAddress = idAddress_delivery;
if (window.ajaxCart !== undefined)
{
$('#cart_block_list dd, #cart_block_list dt').each(function(){
if (typeof($(this).attr('id')) != 'undefined')
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_' + idAddress_delivery));
});
}
updateCarrierList(jsonData.carrier_data);
updatePaymentMethods(jsonData);
updateCartSummary(jsonData.summary);
@@ -385,18 +391,16 @@ function updateNewAccountToAddressBlock()
// update block user info
if (json.block_user_info !== '' && $('#header_user').length == 1)
{
$('#header_user').fadeOut('slow', function() {
$(this).attr('id', 'header_user_old').after(json.block_user_info).fadeIn('slow');
$('#header_user_old').remove();
var elt = $(json.block_user_info).find('#header_user_info').html();
$('#header_user_info').fadeOut('nortmal', function() {
$(this).html(elt).fadeIn();
});
}
$('#opc_new_account').fadeIn('fast', function() {
//After login, the products are automatically associated to an address
$.each(json.summary.products, function() {
updateAddressId(this.id_product, this.id_product_attribute, '0', this.id_address_delivery);
});
updateCartSummary(json.summary);
updateAddressesDisplay(true);
updateCarrierList(json.carrier_data);
@@ -610,10 +614,8 @@ $(function() {
// It's not a new customer
if ($('#opc_id_customer').val() !== '0')
{
if (!saveAddress('delivery'))
return false;
}
// update id_customer
$('#opc_id_customer').val(jsonData.id_customer);
+36 -34
View File
@@ -148,6 +148,9 @@ function findCombination(firstTime)
//update display of the availability of the product AND the prices of the product
function updateDisplay()
{
var productPriceDisplay = productPrice;
var productPriceWithoutReductionDisplay = productPriceWithoutReduction;
if (!selectedCombination['unavailable'] && quantityAvailable > 0 && productAvailableForOrder == 1)
{
//show the choice of quantities
@@ -303,6 +306,22 @@ function updateDisplay()
var tax = (taxRate / 100) + 1;
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.reduction_price || product_specific_price.reduction_percent)
{
reduction_price = (specific_currency ? product_specific_price.reduction_price : product_specific_price.reduction_price * currencyRate);
reduction = productPriceDisplay * (parseFloat(product_specific_price.reduction_percent) / 100) + reduction_price;
if (reduction_price && (displayPrice || noTaxForThisProduct))
reduction = ps_round(reduction / tax, 6);
}
if (selectedCombination.specific_price)
{
if (selectedCombination['specific_price'].reduction_type == 'percentage')
@@ -311,7 +330,7 @@ function updateDisplay()
$('#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(selectedCombination['specific_price'].reduction_price, currencyFormat, currencySign, currencyBlank));
$('#reduction_amount_display').html('-' + formatCurrency(reduction_price, currencyFormat, currencySign, currencyBlank));
$('#reduction_percent').hide();
$('#reduction_amount').show();
} else {
@@ -322,7 +341,7 @@ function updateDisplay()
else
if (product_specific_price['reduction_type'] == 'percentage')
$('#reduction_percent_display').html(product_specific_price['specific_price'].reduction_percent);
if (product_specific_price['reduction_type'] != '' || selectedCombination['specific_price'].reduction_type != '')
$('#discount_reduced_price,#old_price').show();
else
@@ -343,61 +362,44 @@ function updateDisplay()
var taxExclPrice = priceTaxExclWithoutGroupReduction + (selectedCombination['price'] * currencyRate);
if (!displayPrice && !noTaxForThisProduct)
productPrice = taxExclPrice * tax; // Need to be global => no var
productPriceDisplay = taxExclPrice * tax; // Need to be global => no var
else
productPrice = ps_round(taxExclPrice, 2); // Need to be global => no var
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)
{
selectedCombination['specific_price'].reduction_price = (specific_currency ? selectedCombination['specific_price'].reduction_price : selectedCombination['specific_price'].reduction_price * currencyRate);
reduction = productPrice * (parseFloat(selectedCombination['specific_price'].reduction_percent) / 100) + selectedCombination['specific_price'].reduction_price;
if (selectedCombination['specific_price'].reduction_price && (displayPrice || noTaxForThisProduct))
reduction = ps_round(reduction / tax, 6);
}
else if (product_specific_price.reduction_price || product_specific_price.reduction_percent)
{
product_specific_price.reduction_price = (specific_currency ? product_specific_price.reduction_price : product_specific_price.reduction_price * currencyRate);
reduction = productPrice * (parseFloat(product_specific_price.reduction_percent) / 100) + product_specific_price.reduction_price;
if (product_specific_price.reduction_price && (displayPrice || noTaxForThisProduct))
reduction = ps_round(reduction / tax, 6);
}
productPriceWithoutReduction = productPrice * group_reduction;
productPrice -= reduction;
var tmp = productPrice * group_reduction;
productPrice = ps_round(productPrice * group_reduction, 2);
productPriceDisplay -= reduction;
var tmp = productPriceDisplay * group_reduction;
productPriceDisplay = ps_round(productPriceDisplay * group_reduction, 2);
var ecotaxAmount = !displayPrice ? ps_round(selectedCombination['ecotax'] * (1 + ecotaxTax_rate / 100), 2) : selectedCombination['ecotax'];
productPrice += ecotaxAmount;
productPriceWithoutReduction += ecotaxAmount;
productPriceDisplay += ecotaxAmount;
productPriceWithoutReductionDisplay += ecotaxAmount;
var our_price = '';
if (productPrice > 0) {
our_price = formatCurrency(productPrice, currencyFormat, currencySign, currencyBlank);
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(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
if (productPriceWithoutReduction > productPrice)
$('#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 = productPrice / tax;
productPricePretaxed = productPriceDisplay / tax;
else
productPricePretaxed = productPrice;
productPricePretaxed = productPriceDisplay;
$('#pretaxe_price_display').text(formatCurrency(productPricePretaxed, currencyFormat, currencySign, currencyBlank));
// Unit price
productUnitPriceRatio = parseFloat(productUnitPriceRatio);
if (productUnitPriceRatio > 0 )
{
newUnitPrice = (productPrice / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
newUnitPrice = (productPriceDisplay / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
$('#unit_price_display').text(formatCurrency(newUnitPrice, currencyFormat, currencySign, currencyBlank));
}