[-] FO : Fix Bug #PSCFV-7339 available date on product page
This commit is contained in:
@@ -240,7 +240,7 @@ span.view_scroll_spacer {
|
||||
}
|
||||
|
||||
#availability_statut span#availability_label,
|
||||
#availability_statut span#availability_date_label {
|
||||
#availability_date_label {
|
||||
display:inline-block;
|
||||
width:125px;
|
||||
font-weight:700;
|
||||
|
||||
@@ -44,7 +44,7 @@ function oosHookJsCode()
|
||||
for (var i = 0; i < oosHookJsCodeFunctions.length; i++)
|
||||
{
|
||||
if (function_exists(oosHookJsCodeFunctions[i]))
|
||||
setTimeout(oosHookJsCodeFunctions[i]+'()', 0);
|
||||
setTimeout(oosHookJsCodeFunctions[i] + '()', 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ function addCombination(idCombination, arrayOfIdAttributes, quantity, price, eco
|
||||
combination['reference'] = reference;
|
||||
combination['unit_price'] = unit_price;
|
||||
combination['minimal_quantity'] = minimal_quantity;
|
||||
combination['available_date'] = [];
|
||||
combination['available_date'] = available_date;
|
||||
combination['specific_price'] = [];
|
||||
combination['specific_price'] = combination_specific_price;
|
||||
@@ -88,9 +89,7 @@ function findCombination(firstTime)
|
||||
$.each(combinations[combination]['idsAttributes'], function(key, value)
|
||||
{
|
||||
if (!in_array(value, choice))
|
||||
{
|
||||
combinationMatchForm = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (combinationMatchForm)
|
||||
@@ -119,7 +118,7 @@ function findCombination(firstTime)
|
||||
|
||||
//show the large image in relation to the selected combination
|
||||
if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
|
||||
displayImage( $('#thumb_'+combinations[combination]['image']).parent() );
|
||||
displayImage( $('#thumb_' + combinations[combination]['image']).parent() );
|
||||
|
||||
//show discounts values according to the selected combination
|
||||
if (combinations[combination]['idCombination'] && combinations[combination]['idCombination'] > 0)
|
||||
@@ -141,6 +140,8 @@ function findCombination(firstTime)
|
||||
}
|
||||
//this combination doesn't exist (not created in back office)
|
||||
selectedCombination['unavailable'] = true;
|
||||
if (typeof(selectedCombination['available_date']) != 'undefined')
|
||||
delete selectedCombination['available_date'];
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
@@ -158,9 +159,7 @@ function updateDisplay()
|
||||
//hide the hook out of stock
|
||||
$('#oosHook').hide();
|
||||
|
||||
//hide availability date
|
||||
$('#availability_date_label').hide();
|
||||
$('#availability_date_value').hide();
|
||||
$('#availability_date').fadeOut();
|
||||
|
||||
//availability value management
|
||||
if (availableNowValue != '')
|
||||
@@ -172,16 +171,13 @@ function updateDisplay()
|
||||
$('#availability_statut:hidden').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
//hide the availability value
|
||||
$('#availability_statut:visible').hide();
|
||||
}
|
||||
|
||||
//'last quantities' message management
|
||||
if (!allowBuyWhenOutOfStock)
|
||||
{
|
||||
if (quantityAvailable <= maxQuantityToAllowDisplayOfLastQuantityMessage)
|
||||
$('#last_quantities').show('slow');
|
||||
$('#last_quantities').show('slow');
|
||||
else
|
||||
$('#last_quantities').hide('slow');
|
||||
}
|
||||
@@ -233,28 +229,27 @@ function updateDisplay()
|
||||
}
|
||||
if(stock_management == 1)
|
||||
$('#availability_statut:hidden').show();
|
||||
|
||||
//display availability date
|
||||
if (selectedCombination.length)
|
||||
|
||||
if (typeof(selectedCombination['available_date']) != 'undefined' && selectedCombination['available_date']['date'].length != 0)
|
||||
{
|
||||
var available_date = selectedCombination['available_date'];
|
||||
tab_date = available_date.split('-');
|
||||
var time_available = new Date(tab_date[2], tab_date[1], tab_date[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();
|
||||
// date displayed only if time_available
|
||||
if (now.getTime() < time_available.getTime())
|
||||
if (now.getTime() < time_available.getTime() && $('#availability_date_value').text() != selectedCombination['available_date']['date_formatted'])
|
||||
{
|
||||
$('#availability_date_value').text(selectedCombination['available_date']);
|
||||
$('#availability_date_label').show();
|
||||
$('#availability_date_value').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#availability_date_label').hide();
|
||||
$('#availability_date_value').hide();
|
||||
$('#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();
|
||||
|
||||
//show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible
|
||||
if (allowBuyWhenOutOfStock && !selectedCombination['unavailable'] && productAvailableForOrder == 1)
|
||||
{
|
||||
@@ -451,15 +446,17 @@ function displayDiscounts(combination)
|
||||
{
|
||||
$('#quantityDiscount tbody tr').each(function() {
|
||||
if (($(this).attr('id') != 'quantityDiscount_0') &&
|
||||
($(this).attr('id') != 'quantityDiscount_'+combination) &&
|
||||
($(this).attr('id') != 'quantityDiscount_' + combination) &&
|
||||
($(this).attr('id') != 'noQuantityDiscount'))
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
|
||||
if ($('#quantityDiscount_'+combination).length != 0) {
|
||||
$('#quantityDiscount_'+combination).show();
|
||||
if ($('#quantityDiscount_' + combination).length != 0)
|
||||
{
|
||||
$('#quantityDiscount_' + combination).show();
|
||||
$('#noQuantityDiscount').hide();
|
||||
} else
|
||||
}
|
||||
else
|
||||
$('#noQuantityDiscount').show();
|
||||
}
|
||||
|
||||
@@ -491,13 +488,13 @@ function refreshProductImages(id_product_attribute)
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
var thumb_width = $('#thumbs_list_frame >li').width()+parseInt($('#thumbs_list_frame >li').css('marginRight'));
|
||||
var thumb_width = $('#thumbs_list_frame >li').width() + parseInt($('#thumbs_list_frame >li').css('marginRight'));
|
||||
$('#thumbs_list_frame').width((parseInt((thumb_width)* i) + 3) + 'px'); // Bug IE6, needs 3 pixels more ?
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#thumbnail_' + idDefaultImage).show();
|
||||
displayImage($('#thumbnail_'+ idDefaultImage +' a'));
|
||||
displayImage($('#thumbnail_' + idDefaultImage + ' a'));
|
||||
}
|
||||
$('#thumbs_list').trigger('goto', 0);
|
||||
serialScrollFixLock('', '', '', '', 0);// SerialScroll Bug on goto 0 ?
|
||||
@@ -576,8 +573,7 @@ $(document).ready(function()
|
||||
'transitionIn' : 'elastic',
|
||||
'transitionOut' : 'elastic'
|
||||
});
|
||||
|
||||
original_url = window.location+'';
|
||||
original_url = window.location + '';
|
||||
first_url_check = true;
|
||||
checkUrl();
|
||||
initLocationChange();
|
||||
@@ -589,7 +585,7 @@ function saveCustomization()
|
||||
$('#quantityBackup').val($('#quantity_wanted').val());
|
||||
customAction = $('#customizationForm').attr('action');
|
||||
$('body select[id^="group_"]').each(function() {
|
||||
customAction = customAction.replace(new RegExp(this.id + '=\\d+'), this.id +'='+this.value);
|
||||
customAction = customAction.replace(new RegExp(this.id + '=\\d+'), this.id +'=' + this.value);
|
||||
});
|
||||
$('#customizationForm').attr('action', customAction);
|
||||
$('#customizationForm').submit();
|
||||
@@ -600,7 +596,7 @@ function submitPublishProduct(url, redirect, token)
|
||||
var id_product = $('#admin-action-product-id').val();
|
||||
|
||||
$.ajaxSetup({async: false});
|
||||
$.post(url+'/index.php', {
|
||||
$.post(url + '/index.php', {
|
||||
action:'publishProduct',
|
||||
id_product: id_product,
|
||||
status: 1,
|
||||
@@ -615,7 +611,6 @@ function submitPublishProduct(url, redirect, token)
|
||||
document.location.href = data;
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -667,17 +662,17 @@ function getProductAttribute()
|
||||
for (var i in attributesCombinations)
|
||||
for (var a in tab_attributes)
|
||||
if (attributesCombinations[i]['id_attribute'] === tab_attributes[a])
|
||||
request += '/'+attributesCombinations[i]['group']+'-'+attributesCombinations[i]['attribute'];
|
||||
request += '/'+attributesCombinations[i]['group'] + '-' + attributesCombinations[i]['attribute'];
|
||||
request = request.replace(request.substring(0, 1), '#/');
|
||||
url = window.location+'';
|
||||
url = window.location + '';
|
||||
|
||||
// redirection
|
||||
if (url.indexOf('#') != -1)
|
||||
url = url.substring(0, url.indexOf('#'));
|
||||
|
||||
// set ipa to the customization form
|
||||
$('#customizationForm').attr('action', $('#customizationForm').attr('action')+request)
|
||||
window.location = url+request;
|
||||
$('#customizationForm').attr('action', $('#customizationForm').attr('action') + request)
|
||||
window.location = url + request;
|
||||
}
|
||||
|
||||
function initLocationChange(time)
|
||||
@@ -691,7 +686,7 @@ function checkUrl()
|
||||
if (original_url != window.url || first_url_check)
|
||||
{
|
||||
first_url_check = false;
|
||||
url = window.location+'';
|
||||
url = window.location + '';
|
||||
// if we need to load a specific combination
|
||||
if (url.indexOf('#/') != -1)
|
||||
{
|
||||
@@ -715,17 +710,17 @@ function checkUrl()
|
||||
{
|
||||
count++;
|
||||
// add class 'selected' to the selected color
|
||||
$('#color_'+attributesCombinations[a]['id_attribute']).addClass('selected');
|
||||
$('#color_'+attributesCombinations[a]['id_attribute']).parent().addClass('selected');
|
||||
$('input:radio[value='+attributesCombinations[a]['id_attribute']+']').attr('checked', true);
|
||||
$('input:hidden[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
|
||||
$('select[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
|
||||
$('#color_' + attributesCombinations[a]['id_attribute']).addClass('selected');
|
||||
$('#color_' + attributesCombinations[a]['id_attribute']).parent().addClass('selected');
|
||||
$('input:radio[value=' + attributesCombinations[a]['id_attribute'] + ']').attr('checked', true);
|
||||
$('input:hidden[name=group_' + attributesCombinations[a]['id_attribute_group'] + ']').val(attributesCombinations[a]['id_attribute']);
|
||||
$('select[name=group_' + attributesCombinations[a]['id_attribute_group'] + ']').val(attributesCombinations[a]['id_attribute']);
|
||||
}
|
||||
// find combination
|
||||
if (count >= 0)
|
||||
{
|
||||
findCombination(false);
|
||||
original_url = window.location+'';
|
||||
original_url = window.location + '';
|
||||
}
|
||||
// no combination found = removing attributes from url
|
||||
else
|
||||
|
||||
@@ -121,15 +121,19 @@ var doesntExistNoMore = '{l s='This product is no longer in stock' js=1}';
|
||||
var doesntExistNoMoreBut = '{l s='with those attributes but is available with others.' js=1}';
|
||||
var uploading_in_progress = '{l s='Uploading in progress, please be patient.' js=1}';
|
||||
var fieldRequired = '{l s='Please fill in all the required fields before saving your customization.' js=1}';
|
||||
|
||||
{if isset($groups)}
|
||||
// Combinations
|
||||
{foreach from=$combinations key=idCombination item=combination}
|
||||
var specific_price_combination = new Array();
|
||||
var available_date = new Array();
|
||||
specific_price_combination['reduction_percent'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'percentage'}{$combination.specific_price.reduction*100}{else}0{/if};
|
||||
specific_price_combination['reduction_price'] = {if $combination.specific_price AND $combination.specific_price.reduction AND $combination.specific_price.reduction_type == 'amount'}{$combination.specific_price.reduction}{else}0{/if};
|
||||
specific_price_combination['price'] = {if $combination.specific_price AND $combination.specific_price.price}{$combination.specific_price.price}{else}0{/if};
|
||||
specific_price_combination['reduction_type'] = '{if $combination.specific_price}{$combination.specific_price.reduction_type}{/if}';
|
||||
addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, '{$combination.available_date}', specific_price_combination);
|
||||
available_date['date'] = '{$combination.available_date}';
|
||||
available_date['date_formatted'] = '{dateFormat date=$combination.available_date full=false}';
|
||||
addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, available_date, specific_price_combination);
|
||||
{/foreach}
|
||||
{/if}
|
||||
|
||||
@@ -337,13 +341,12 @@ var fieldRequired = '{l s='Please fill in all the required fields before saving
|
||||
<!-- availability -->
|
||||
<p id="availability_statut"{if ($product->quantity <= 0 && !$product->available_later && $allow_oosp) OR ($product->quantity > 0 && !$product->available_now) OR !$product->available_for_order OR $PS_CATALOG_MODE} style="display: none;"{/if}>
|
||||
<span id="availability_label">{l s='Availability:'}</span>
|
||||
<span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>{if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}</span>
|
||||
{if $product->quantity <= 0 && isset($product->available_date) && $product->available_date >= $smarty.now|date_format:'%Y-%m-%d'}
|
||||
<br class="clear"/><span id="availability_date_label">{l s='Availability date:'}</span>
|
||||
<span id="availability_date_value">{$product->available_date}</span>
|
||||
{/if}
|
||||
<span id="availability_value"{if $product->quantity <= 0} class="warning_inline"{/if}>{if $product->quantity <= 0}{if $allow_oosp}{$product->available_later}{else}{l s='This product is no longer in stock'}{/if}{else}{$product->available_now}{/if}</span>
|
||||
</p>
|
||||
<p id="availability_date"{if ($product->quantity > 0) OR !$product->available_for_order OR $PS_CATALOG_MODE OR !isset($product->available_date) OR $product->available_date < $smarty.now|date_format:'%Y-%m-%d'} style="display: none;"{/if}>
|
||||
<span id="availability_date_label">{l s='Availability date:'}</span>
|
||||
<span id="availability_date_value">{dateFormat date=$product->available_date full=false}</span>
|
||||
</p>
|
||||
|
||||
<!-- number of item in stock -->
|
||||
{if ($display_qties == 1 && !$PS_CATALOG_MODE && $product->available_for_order)}
|
||||
<p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}>
|
||||
|
||||
Reference in New Issue
Block a user