Testingshopping/prestashop/themes/default-bootstrap/js/product.js
//update display of the availability of the product AND the prices of the product
update display of the availability of the product AND the prices of the product
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)
	{
		$('#quantity_wanted_p:hidden').show('slow');
		$('#add_to_cart:hidden').fadeIn(600);
		$('#oosHook').hide();
		$('#availability_date').fadeOut();
		if (stock_management && availableNowValue != '')
		{
			$('#availability_value').removeClass('label-warning').addClass('label-success').text(availableNowValue).show();
			$('#availability_statut:hidden').show('slow');
		}
		else
			$('#availability_statut:visible').hide('slow');
		if (!allowBuyWhenOutOfStock)
		{
			if (quantityAvailable <= maxQuantityToAllowDisplayOfLastQuantityMessage)
				$('#last_quantities').show('slow');
			else
				$('#last_quantities').hide('slow');
		}
		if (quantitiesDisplayAllowed)
		{
			$('#pQuantityAvailable:hidden').show('slow');
			$('#quantityAvailable').text(quantityAvailable);
			if (quantityAvailable < 2) 
			{
				$('#quantityAvailableTxt').show();
				$('#quantityAvailableTxtMultiple').hide();
			}
			else
			{
				$('#quantityAvailableTxt').hide();
				$('#quantityAvailableTxtMultiple').show();
			}
		}
	}
	else
	{
		if (productAvailableForOrder == 1)
		{
			$('#oosHook').show();
			if ($('#oosHook').length > 0 && function_exists('oosHookJsCode'))
				oosHookJsCode();
		}
		$('#last_quantities:visible').hide('slow');
		$('#pQuantityAvailable:visible').hide('slow');
		if (!allowBuyWhenOutOfStock)
			$('#quantity_wanted_p:visible').hide('slow');
		if (!selectedCombination['unavailable'])
		{
			$('#availability_value').text(doesntExistNoMore + (globalQuantity > 0 ? ' ' + doesntExistNoMoreBut : ''));
			if (!allowBuyWhenOutOfStock)
				$('#availability_value').removeClass('label-success').addClass('label-warning');
		}
		else
		{
			$('#availability_value').text(doesntExist).removeClass('label-success').addClass('label-warning');
			$('#oosHook').hide();
		}
		if ((stock_management == 1 && !allowBuyWhenOutOfStock) || (!stock_management && selectedCombination['unavailable']))
			$('#availability_statut:hidden').show();
		if (typeof(selectedCombination['available_date']) !== 'undefined' && typeof(selectedCombination['available_date']['date_formatted']) !== 'undefined' && selectedCombination['available_date']['date'].length != 0)
		{
			var available_date = selectedCombination['available_date']['date'];
			var tab_date = available_date.split('-');
			var time_available = new Date(tab_date[0], tab_date[1], tab_date[2]);
			time_available.setMonth(time_available.getMonth()-1);
			var now = new Date();
			if (now.getTime() < time_available.getTime() && $('#availability_date_value').text() != selectedCombination['available_date']['date_formatted'])
			{
				$('#availability_date').fadeOut('normal', function(){
					$('#availability_date_value').text(selectedCombination['available_date']['date_formatted']);
					$(this).fadeIn();
				});
			}
			else if (now.getTime() < time_available.getTime())
				$('#availability_date').fadeIn();
		}
		else
			$('#availability_date').fadeOut();
		if (allowBuyWhenOutOfStock && !selectedCombination['unavailable'] && productAvailableForOrder)
		{
			$('#add_to_cart:hidden').fadeIn(600);
			if (stock_management && availableLaterValue != '')
			{
				$('#availability_value').addClass('label-warning').text(availableLaterValue).show('slow');
				$('#availability_statut:hidden').show('slow');
			}
			else
				$('#availability_statut:visible').hide('slow');
		}
		else
		{
			$('#add_to_cart:visible').fadeOut(600);
			if (stock_management == 1 && productAvailableForOrder)
				$('#availability_statut:hidden').show('slow');
		}
		if (productAvailableForOrder == 0)
			$('#availability_statut:visible').hide();
	}
	if (selectedCombination['reference'] || productReference)
	{
		if (selectedCombination['reference'])
			$('#product_reference span').text(selectedCombination['reference']);
		else if (productReference)
			$('#product_reference span').text(productReference);
		$('#product_reference:hidden').show('slow');
	}
	else
		$('#product_reference:visible').hide('slow');
	if (productHasAttributes)
		updatePrice();
}
function updateDisplay ( ) { var productPriceDisplay = productPrice ; var productPriceWithoutReductionDisplay = productPriceWithoutReduction ; if ( ! selectedCombination [ 'unavailable' ] && quantityAvailable > 0 && productAvailableForOrder == 1 ) { $ ( '#quantity_wanted_p:hidden' ) . show ( 'slow' ) ; $ ( '#add_to_cart:hidden' ) . fadeIn ( 600 ) ; $ ( '#oosHook' ) . hide ( ) ; $ ( '#availability_date' ) . fadeOut ( ) ; if ( stock_management && availableNowValue != '' ) { $ ( '#availability_value' ) . removeClass ( 'label-warning' ) . addClass ( 'label-success' ) . text ( availableNowValue ) . show ( ) ; $ ( '#availability_statut:hidden' ) . show ( 'slow' ) ; } else $ ( '#availability_statut:visible' ) . hide ( 'slow' ) ; if ( ! allowBuyWhenOutOfStock ) { if ( quantityAvailable <= maxQuantityToAllowDisplayOfLastQuantityMessage ) $ ( '#last_quantities' ) . show ( 'slow' ) ; else $ ( '#last_quantities' ) . hide ( 'slow' ) ; } if ( quantitiesDisplayAllowed ) { $ ( '#pQuantityAvailable:hidden' ) . show ( 'slow' ) ; $ ( '#quantityAvailable' ) . text ( quantityAvailable ) ; if ( quantityAvailable < 2 ) { $ ( '#quantityAvailableTxt' ) . show ( ) ; $ ( '#quantityAvailableTxtMultiple' ) . hide ( ) ; } else { $ ( '#quantityAvailableTxt' ) . hide ( ) ; $ ( '#quantityAvailableTxtMultiple' ) . show ( ) ; } } } else { if ( productAvailableForOrder == 1 ) { $ ( '#oosHook' ) . show ( ) ; if ( $ ( '#oosHook' ) . length > 0 && function_exists ( 'oosHookJsCode' ) ) oosHookJsCode ( ) ; } $ ( '#last_quantities:visible' ) . hide ( 'slow' ) ; $ ( '#pQuantityAvailable:visible' ) . hide ( 'slow' ) ; if ( ! allowBuyWhenOutOfStock ) $ ( '#quantity_wanted_p:visible' ) . hide ( 'slow' ) ; if ( ! selectedCombination [ 'unavailable' ] ) { $ ( '#availability_value' ) . text ( doesntExistNoMore + ( globalQuantity > 0 ? ' ' + doesntExistNoMoreBut : '' ) ) ; if ( ! allowBuyWhenOutOfStock ) $ ( '#availability_value' ) . removeClass ( 'label-success' ) . addClass ( 'label-warning' ) ; } else { $ ( '#availability_value' ) . text ( doesntExist ) . removeClass ( 'label-success' ) . addClass ( 'label-warning' ) ; $ ( '#oosHook' ) . hide ( ) ; } if ( ( stock_management == 1 && ! allowBuyWhenOutOfStock ) || ( ! stock_management && selectedCombination [ 'unavailable' ] ) ) $ ( '#availability_statut:hidden' ) . show ( ) ; if ( typeof ( selectedCombination [ 'available_date' ] ) !== 'undefined' && typeof ( selectedCombination [ 'available_date' ] [ 'date_formatted' ] ) !== 'undefined' && selectedCombination [ 'available_date' ] [ 'date' ] . length != 0 ) { var available_date = selectedCombination [ 'available_date' ] [ 'date' ] ; var tab_date = available_date . split ( '-' ) ; var time_available = new Date ( tab_date [ 0 ] , tab_date [ 1 ] , tab_date [ 2 ] ) ; time_available . setMonth ( time_available . getMonth ( ) - 1 ) ; var now = new Date ( ) ; if ( now . getTime ( ) < time_available . getTime ( ) && $ ( '#availability_date_value' ) . text ( ) != selectedCombination [ 'available_date' ] [ 'date_formatted' ] ) { $ ( '#availability_date' ) . fadeOut ( 'normal' , function ( ) { $ ( '#availability_date_value' ) . text ( selectedCombination [ 'available_date' ] [ 'date_formatted' ] ) ; $ ( this ) . fadeIn ( ) ; } ) ; } else if ( now . getTime ( ) < time_available . getTime ( ) ) $ ( '#availability_date' ) . fadeIn ( ) ; } else $ ( '#availability_date' ) . fadeOut ( ) ; if ( allowBuyWhenOutOfStock && ! selectedCombination [ 'unavailable' ] && productAvailableForOrder ) { $ ( '#add_to_cart:hidden' ) . fadeIn ( 600 ) ; if ( stock_management && availableLaterValue != '' ) { $ ( '#availability_value' ) . addClass ( 'label-warning' ) . text ( availableLaterValue ) . show ( 'slow' ) ; $ ( '#availability_statut:hidden' ) . show ( 'slow' ) ; } else $ ( '#availability_statut:visible' ) . hide ( 'slow' ) ; } else { $ ( '#add_to_cart:visible' ) . fadeOut ( 600 ) ; if ( stock_management == 1 && productAvailableForOrder ) $ ( '#availability_statut:hidden' ) . show ( 'slow' ) ; } if ( productAvailableForOrder == 0 ) $ ( '#availability_statut:visible' ) . hide ( ) ; } if ( selectedCombination [ 'reference' ] || productReference ) { if ( selectedCombination [ 'reference' ] ) $ ( '#product_reference span' ) . text ( selectedCombination [ 'reference' ] ) ; else if ( productReference ) $ ( '#product_reference span' ) . text ( productReference ) ; $ ( '#product_reference:hidden' ) . show ( 'slow' ) ; } else $ ( '#product_reference:visible' ) . hide ( 'slow' ) ; if ( productHasAttributes ) updatePrice ( ) ; }
update display of the availability of the product AND the prices of the product
update display of the availability of the product AND the prices of the product
//show the choice of quantities //show the "add to cart" button ONLY if it was hidden //hide the hook out of stock //availability value management //'last quantities' message management // we have 1 or less product in stock and need to show "item" instead of "items" //show the hook out of stock //hide 'last quantities' message if it was previously visible //hide the quantity of pieces if it was previously visible //hide the choice of quantities //display that the product is unavailable with theses attributes //show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible // If we have combinations, update price section: amounts, currency, discount amounts,...