[+] FO : New Responsive, Bootstrap template
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
$( '.prestashop-page' ).live( 'pageshow',function(event)
|
||||
{
|
||||
var quantity = new Array();
|
||||
|
||||
$("[name='cart_product_id[]']").each(function(i){
|
||||
quantity[$(this).val()] = parseInt($('[name="product_cart_quantity_'+$(this).val()+'"]').val());
|
||||
});
|
||||
|
||||
$(".display_block_card_product").children().each(function(i){
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$(".grouped_buttons_card").children().each(function(i){
|
||||
$(this).click(function(){
|
||||
$(".display_block_card_product").children().each(function(i){
|
||||
$(this).hide();
|
||||
});
|
||||
$("#"+$(this).attr('id')+"sheet").show();
|
||||
});
|
||||
});
|
||||
|
||||
$('[name*="product_cart_quantity_"]').change(function()
|
||||
{
|
||||
ids = $(this).attr("name").split('_');
|
||||
id = ids[3];
|
||||
val = parseInt($(this).val());
|
||||
|
||||
if (quantity[id] < val)
|
||||
{
|
||||
CartUpd.ajaxUpdQty(id, val - quantity[id], 1);
|
||||
quantity[id] = val;
|
||||
}
|
||||
else if (quantity[id] > val)
|
||||
{
|
||||
CartUpd.ajaxUpdQty(id, quantity[id] - val, 0);
|
||||
quantity[id] = val;
|
||||
}
|
||||
});
|
||||
|
||||
$('[id*="delete_cart_"]').click(function()
|
||||
{
|
||||
ids = $(this).attr("id").split('_');
|
||||
CartUpd.deleteProductFromSummary(ids[2]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var CartUpd = (function()
|
||||
{
|
||||
return {
|
||||
ajaxUpdQty : function(id, qty, op)
|
||||
{
|
||||
productAttributeId = $("#cart_product_attribute_id_"+id).val();
|
||||
id_address_delivery = $("#cart_product_address_delivery_id_"+id).val();
|
||||
customizationId = 0;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
data: 'controller=cart&ajax=true&add=true&getproductprice&summary&id_product='+id+'&ipa='+productAttributeId+'&id_address_delivery='+id_address_delivery+ ( op == 0 ? '&op=down' : '' ) + ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&qty='+qty+'&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (!jsonData.hasError)
|
||||
CartUpd.updData(jsonData);
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteProductFromSummary : function(id)
|
||||
{
|
||||
productAttributeId = $("#cart_product_attribute_id_"+id).val();
|
||||
id_address_delivery = $("#cart_product_address_delivery_id_"+id).val();
|
||||
customizationId = 0;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType: 'json',
|
||||
data: 'controller=cart&ajax=true&delete=true&summary=true&id_product='+id+'&ipa='+productAttributeId+'&id_address_delivery='+id_address_delivery+ ( (customizationId != 0) ? '&id_customization='+customizationId : '') + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (!jsonData.hasError)
|
||||
{
|
||||
if (jsonData.refresh)
|
||||
location.reload();
|
||||
$("#cart_total_products").html(jsonData.summary.total_products_wt);
|
||||
$("#cart_total_price").html(jsonData.summary.total_price);
|
||||
$("#element_product_"+id).fadeOut();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
,
|
||||
updData : function(data)
|
||||
{
|
||||
var products = data.summary.products;
|
||||
|
||||
$(products).each(function(i){
|
||||
price = this.price_wt * this.quantity;
|
||||
$("#grouped_buttons_card_"+this.id_product+"_totsheet").html((price).toFixed(2));
|
||||
});
|
||||
|
||||
$("#cart_total_products").html(data.summary.total_products_wt);
|
||||
$("#cart_total_price").html(data.summary.total_price);
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,42 @@
|
||||
// Allows to set the same height on ui-block element
|
||||
// for #category-list items.
|
||||
$( '.prestashop-page' ).live( 'pageshow',function(event)
|
||||
{
|
||||
if ($('.ui-grid-a.same-height').length)
|
||||
{
|
||||
$('.ui-grid-a.same-height .ui-block-a').each(function()
|
||||
{
|
||||
if ($(this).height() != $(this).next('.ui-block-b').height())
|
||||
{
|
||||
var height1 = $(this).height();
|
||||
var height2 = $(this).next('.ui-block-b').height();
|
||||
if (height1 < height2) {
|
||||
$(this).height(height2).find('.ui-btn-inner.ui-li').height(height2);
|
||||
if ($(this).find('.ui-bar').length) {
|
||||
var less_h = [
|
||||
parseInt($(this).find('.ui-bar').css('padding-top')),
|
||||
parseInt($(this).find('.ui-bar').css('padding-bottom')),
|
||||
parseInt($(this).find('.ui-bar').css('border-top-width')),
|
||||
parseInt($(this).find('.ui-bar').css('border-bottom-width'))
|
||||
];
|
||||
$(this).find('.ui-bar').height(height2-less_h[0]-less_h[1]-less_h[2]-less_h[3]);
|
||||
}
|
||||
} else {
|
||||
$(this).next('.ui-block-b').height(height1).find('.ui-btn-inner.ui-li').height(height1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$( '.prestashop-page' ).live( 'pageinit',function(event)
|
||||
{
|
||||
if ($('.wrapper_pagination_mobile').length)
|
||||
{
|
||||
$('.wrapper_pagination_mobile').find('.disabled').live('click', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
//show the order-details with ajax
|
||||
function showOrder(mode, var_content, file)
|
||||
{
|
||||
/*$.get(
|
||||
file,
|
||||
((mode == 1) ? {'id_order': var_content, 'ajax': true} : {'id_order_return': var_content, 'ajax': true}),
|
||||
function(data)
|
||||
{
|
||||
$('#block-order-detail').fadeOut('slow', function()
|
||||
{
|
||||
$(this).html(data);
|
||||
// if return is allowed
|
||||
if ($('div#order-detail-content table td.order_cb').length > 0)
|
||||
{
|
||||
//return slip : check or uncheck every checkboxes
|
||||
$('form div#order-detail-content th input[type=checkbox]').click(function()
|
||||
{
|
||||
$('form div#order-detail-content td input[type=checkbox]').each(function()
|
||||
{
|
||||
this.checked = $('form div#order-detail-content th input[type=checkbox]').is(':checked');
|
||||
updateOrderLineDisplay(this);
|
||||
});
|
||||
});
|
||||
//return slip : enable or disable 'global' quantity editing
|
||||
$('form div#order-detail-content td input[type=checkbox]').click(function()
|
||||
{
|
||||
updateOrderLineDisplay(this);
|
||||
});
|
||||
//return slip : limit quantities
|
||||
$('form div#order-detail-content td input.order_qte_input').keyup(function()
|
||||
{
|
||||
var maxQuantity = parseInt($(this).parent().find('span.order_qte_span').text());
|
||||
var quantity = parseInt($(this).val());
|
||||
if (isNaN($(this).val()) && $(this).val() != '')
|
||||
{
|
||||
$(this).val(maxQuantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (quantity > maxQuantity)
|
||||
$(this).val(maxQuantity);
|
||||
else if (quantity < 1)
|
||||
$(this).val(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
//catch the submit event of sendOrderMessage form
|
||||
$('form#sendOrderMessage').submit(function(){
|
||||
return sendOrderMessage();
|
||||
});
|
||||
$(this).fadeIn('slow');
|
||||
$('html, body').animate({scrollTop: $(this).offset().top},'slow');
|
||||
// $.scrollTo(this, 1200);
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
function updateOrderLineDisplay(domCheckbox)
|
||||
{
|
||||
var lineQuantitySpan = $(domCheckbox).parent().parent().find('span.order_qte_span');
|
||||
var lineQuantityInput = $(domCheckbox).parent().parent().find('input.order_qte_input');
|
||||
if($(domCheckbox).is(':checked'))
|
||||
{
|
||||
lineQuantitySpan.hide();
|
||||
lineQuantityInput.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
lineQuantityInput.hide();
|
||||
lineQuantityInput.val(lineQuantitySpan.text());
|
||||
lineQuantitySpan.show();
|
||||
}
|
||||
}
|
||||
|
||||
//send a message in relation to the order with ajax
|
||||
function sendOrderMessage ()
|
||||
{
|
||||
paramString = "ajax=true";
|
||||
$('form#sendOrderMessage').find('input, textarea').each(function(){
|
||||
paramString += '&' + $(this).attr('name') + '=' + encodeURI($(this).val());
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: baseDir + "index.php?controller=order-detail" + '&rand=' + new Date().getTime(),
|
||||
data: paramString,
|
||||
success: function (msg){
|
||||
$('#block-order-detail').fadeOut('slow', function() {
|
||||
$(this).html(msg);
|
||||
//catch the submit event of sendOrderMessage form
|
||||
$('form#sendOrderMessage').submit(function(){
|
||||
return sendOrderMessage();
|
||||
});
|
||||
$(this).fadeIn('slow');
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
@@ -0,0 +1,53 @@
|
||||
//set up the theme switcher on the homepage
|
||||
$('div').live('pagecreate',function(event)
|
||||
{
|
||||
if ( !$(this).is('.ui-dialog'))
|
||||
{
|
||||
var appendEl = $(this).find('.ui-footer:last');
|
||||
if ( !appendEl.length ) {
|
||||
appendEl = $(this).find('.ui-content');
|
||||
}
|
||||
if( appendEl.is("[data-position]") ) {
|
||||
return;
|
||||
}
|
||||
/*$('<a href="#themeswitcher" data-'+ $.mobile.ns +'rel="dialog" data-'+ $.mobile.ns +'transition="pop">Switch theme</a>')
|
||||
.buttonMarkup({
|
||||
'icon':'gear',
|
||||
'inline': true,
|
||||
'shadow': false,
|
||||
'theme': 'd'
|
||||
})
|
||||
.appendTo( appendEl )
|
||||
.wrap('<div class="jqm-themeswitcher">')
|
||||
.bind( "vclick", function(){
|
||||
$.themeswitcher();
|
||||
});*/
|
||||
}
|
||||
});
|
||||
|
||||
//collapse page navs after use
|
||||
$(function()
|
||||
{
|
||||
$('body').delegate('.content-secondary .ui-collapsible-content', 'click', function() {
|
||||
$(this).trigger("collapse")
|
||||
});
|
||||
});
|
||||
|
||||
function setDefaultTransition()
|
||||
{
|
||||
var winwidth = $( window ).width(),
|
||||
trans ="slide";
|
||||
if( winwidth >= 1000 ){
|
||||
trans = "none";
|
||||
}
|
||||
else if( winwidth >= 650 ){
|
||||
trans = "fade";
|
||||
}
|
||||
$.mobile.defaultPageTransition = trans;
|
||||
}
|
||||
|
||||
$(function()
|
||||
{
|
||||
setDefaultTransition();
|
||||
$( window ).bind( "throttledresize", setDefaultTransition );
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,308 @@
|
||||
$( '.prestashop-page' ).live( 'pageinit' , function() {
|
||||
initEvent();
|
||||
});
|
||||
$( '.prestashop-page' ).live( 'pagechange' , function() {
|
||||
initEvent();
|
||||
});
|
||||
|
||||
function initEvent()
|
||||
{
|
||||
$('.qty-field').change(function() {
|
||||
var initial_quantity = $(this).data('initial-quantity');
|
||||
var current_quantity = $(this).val();
|
||||
|
||||
if (initial_quantity != current_quantity)
|
||||
{
|
||||
var op = 'up';
|
||||
if (initial_quantity > current_quantity)
|
||||
op = 'down';
|
||||
|
||||
var qty = Math.abs(current_quantity - initial_quantity);
|
||||
|
||||
$.mobile.showPageLoadingMsg();
|
||||
$.ajax({
|
||||
url: baseDir,
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'controller=cart&add=true&id_product='+$(this).data('id-product')+'&ipa='+$(this).data('id-product-attribute')+'&op='+op+'&qty='+qty+'&id_address_delivery=0&token='+static_token,
|
||||
success: function()
|
||||
{
|
||||
window.location.href = orderOpcUrl;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('.address-field').change(function() {
|
||||
$.mobile.showPageLoadingMsg();
|
||||
$.ajax({
|
||||
url: baseDir,
|
||||
async: true,
|
||||
cache: false,
|
||||
data: 'controller=order-opc&ajax=true&mobile_theme=true&method=updateAddressesSelected&id_address_delivery=' + $('#delivery-address-choice').val() + '&id_address_invoice=' + $('#invoice-address-choice').val() + '&token=' + static_token,
|
||||
success: function()
|
||||
{
|
||||
window.location.href = orderOpcUrl;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//
|
||||
$("#addressesAreEquals").bind("change", function(event, ui) {
|
||||
$("#address_invoice_form").toggle();
|
||||
});
|
||||
|
||||
$('.delivery_option_radio').click(function() {
|
||||
updateCarrierSection($(this));
|
||||
});
|
||||
|
||||
$('#gift').click(function() {
|
||||
// Gift checkbox update
|
||||
giftShowDiv();
|
||||
updateCarrierSection($(this));
|
||||
});
|
||||
|
||||
$('#gift_div').change(function() {
|
||||
updateCarrierSection($(this));
|
||||
});
|
||||
|
||||
$('#cgv').click(function() {
|
||||
if ($('#cgv:checked').length != 0)
|
||||
var checked = 1;
|
||||
else
|
||||
var checked = 0;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
window.location.href = orderOpcUrl+'#cgv_checkbox';
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function updateCarrierList(json)
|
||||
{
|
||||
var html = json.carrier_block;
|
||||
|
||||
// @todo check with theme 1.4
|
||||
//if ($('#HOOK_EXTRACARRIER').length == 0 && json.HOOK_EXTRACARRIER !== null && json.HOOK_EXTRACARRIER != undefined)
|
||||
// html += json.HOOK_EXTRACARRIER;
|
||||
|
||||
$('#carrier_area').replaceWith(html);
|
||||
bindInputs();
|
||||
/* update hooks for carrier module */
|
||||
$('#HOOK_BEFORECARRIER').html(json.HOOK_BEFORECARRIER);
|
||||
}
|
||||
|
||||
function giftShowDiv()
|
||||
{
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
}
|
||||
|
||||
function updateCarrierSection(elm)
|
||||
{
|
||||
var recyclablePackage = 0;
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio_carrier');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
if ($(this).prop('checked'))
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
if (delivery_option_params == '&')
|
||||
delivery_option_params = '&delivery_option=&'
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
if ($('input#gift:checked').length)
|
||||
{
|
||||
gift = 1;
|
||||
giftMessage = encodeURIComponent($('textarea#gift_message').val());
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments' + delivery_option_params + 'recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (!elm.is('#gift'))
|
||||
window.location.href = orderOpcUrl+'#delivery_choose';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bindInputs()
|
||||
{
|
||||
// Order message update
|
||||
$('#message').blur(function() {
|
||||
$('#opc_delivery_methods-overlay').fadeIn('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: false,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateMessage&message=' + encodeURIComponent($('#message').val()) + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Recyclable checkbox
|
||||
$('#recyclable').click(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Gift checkbox update
|
||||
$('#gift').click(function() {
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
if ($('#gift').is(':checked'))
|
||||
$('#gift_div').show();
|
||||
else
|
||||
$('#gift_div').hide();
|
||||
|
||||
// Gift message update
|
||||
$('#gift_message').change(function() {
|
||||
updateCarrierSelectionAndGift();
|
||||
});
|
||||
|
||||
// Term Of Service (TOS)
|
||||
$('#cgv').click(function() {
|
||||
updatePaymentMethodsDisplay();
|
||||
});
|
||||
}
|
||||
|
||||
function updateCarrierSelectionAndGift()
|
||||
{
|
||||
var recyclablePackage = 0;
|
||||
var gift = 0;
|
||||
var giftMessage = '';
|
||||
|
||||
var delivery_option_radio = $('.delivery_option_radio');
|
||||
var delivery_option_params = '&';
|
||||
$.each(delivery_option_radio, function(i) {
|
||||
if ($(this).prop('checked'))
|
||||
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
|
||||
});
|
||||
if (delivery_option_params == '&')
|
||||
delivery_option_params = '&delivery_option=&';
|
||||
|
||||
if ($('input#recyclable:checked').length)
|
||||
recyclablePackage = 1;
|
||||
if ($('input#gift:checked').length)
|
||||
{
|
||||
gift = 1;
|
||||
giftMessage = encodeURIComponent($('#gift_message').val());
|
||||
}
|
||||
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateCarrierAndGetPayments' + delivery_option_params + 'recyclable=' + recyclablePackage + '&gift=' + gift + '&gift_message=' + giftMessage + '&token=' + static_token ,
|
||||
success: function(jsonData)
|
||||
{
|
||||
if (jsonData.hasError)
|
||||
{
|
||||
var errors = '';
|
||||
for(var error in jsonData.errors)
|
||||
//IE6 bug fix
|
||||
if(error !== 'indexOf')
|
||||
errors += $('<div />').html(jsonData.errors[error]).text() + "\n";
|
||||
alert(errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
updateCartSummary(jsonData.summary);
|
||||
updatePaymentMethods(jsonData);
|
||||
updateHookShoppingCart(jsonData.summary.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.summary.HOOK_SHOPPING_CART_EXTRA);
|
||||
updateCarrierList(jsonData.carrier_data);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
refreshDeliveryOptions();
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
if (textStatus !== 'abort')
|
||||
alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
|
||||
$('#opc_delivery_methods-overlay, #opc_payment_methods-overlay').fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatePaymentMethods(json)
|
||||
{
|
||||
$('#HOOK_TOP_PAYMENT').html(json.HOOK_TOP_PAYMENT);
|
||||
$('#opc_payment_methods-content #HOOK_PAYMENT').html(json.HOOK_PAYMENT);
|
||||
}
|
||||
|
||||
function updatePaymentMethodsDisplay()
|
||||
{
|
||||
var checked = '';
|
||||
if ($('#cgv:checked').length !== 0)
|
||||
checked = 1;
|
||||
else
|
||||
checked = 0;
|
||||
$('#opc_payment_methods-overlay').fadeIn('slow', function(){
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: orderOpcUrl + '?rand=' + new Date().getTime(),
|
||||
async: true,
|
||||
cache: false,
|
||||
dataType : "json",
|
||||
data: 'ajax=true&method=updateTOSStatusAndGetPayments&checked=' + checked + '&token=' + static_token,
|
||||
success: function(json)
|
||||
{
|
||||
updatePaymentMethods(json);
|
||||
}
|
||||
});
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,732 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
|
||||
// TODO finish the customization behaviour
|
||||
|
||||
var ProductFn = (function()
|
||||
{
|
||||
return {
|
||||
// PrestaShop internal settings
|
||||
currencySign:'',
|
||||
currencyRate:'',
|
||||
currencyFormat:'',
|
||||
currencyBlank:'',
|
||||
taxRate: 0,
|
||||
|
||||
// Parameters
|
||||
id_product: '',
|
||||
productHasAttributes: false,
|
||||
quantitiesDisplayAllowed: false,
|
||||
quantityAvailable: 0,
|
||||
allowBuyWhenOutOfStock: false,
|
||||
availableNowValue: '',
|
||||
availableLaterValue: '',
|
||||
productPriceTaxExcluded: 0,
|
||||
reduction_percent: 0,
|
||||
reduction_price: 0,
|
||||
specific_price: 0,
|
||||
product_specific_price: [],
|
||||
globalQuantity: 0,
|
||||
|
||||
specific_currency: false,
|
||||
group_reduction: '',
|
||||
default_eco_tax: 0,
|
||||
ecotaxTax_rate: 0,
|
||||
currentDate: '',
|
||||
maxQuantityToAllowDisplayOfLastQuantityMessage: 0,
|
||||
noTaxForThisProduct: false,
|
||||
displayPrice: 0,
|
||||
productReference: '',
|
||||
productAvailableForOrder: '',
|
||||
productShowPrice: '0',
|
||||
productUnitPriceRatio: '',
|
||||
|
||||
productPriceWithoutReduction: '',
|
||||
productPrice: '',
|
||||
|
||||
// Customizable field
|
||||
img_ps_dir: '',
|
||||
customizationFields: [],
|
||||
|
||||
// Images
|
||||
img_prod_dir: '',
|
||||
combinationImages: [],
|
||||
|
||||
// Translations
|
||||
doesntExist: '',
|
||||
doesntExistNoMore: '',
|
||||
doesntExistNoMoreBut: '',
|
||||
uploading_in_progress: '',
|
||||
fieldRequired: '',
|
||||
|
||||
// Combinations attributes informations
|
||||
attributesCombinations: [],
|
||||
combinations: [],
|
||||
selectedCombination: {},
|
||||
|
||||
original_url: '',
|
||||
already_init: false,
|
||||
|
||||
init: function()
|
||||
{
|
||||
if (ProductFn.already_init) {
|
||||
return true;
|
||||
}
|
||||
ProductFn.already_init = true;
|
||||
if ($('.attributes_group select').length || $('.attributes_group input[type=radio]').length) {
|
||||
initAttrSelector();
|
||||
}
|
||||
ProductFn.checkMinimalQuantity();
|
||||
$('#quantity_wanted').bind('keyup', function() {
|
||||
if ($(this).val() != '') {
|
||||
ProductFn.checkMinimalQuantity();
|
||||
}
|
||||
});
|
||||
$('#quantity_wanted').bind('blur', function() {
|
||||
ProductFn.checkMinimalQuantity();
|
||||
});
|
||||
|
||||
checkUrl();
|
||||
},
|
||||
checkMinimalQuantity: function()
|
||||
{
|
||||
if ($('#quantity_wanted').val() < ProductFn.selectedCombination.minimalQuantity)
|
||||
{
|
||||
$('#quantity_wanted').css('border', '1px solid red');
|
||||
$('#minimal_quantity_wanted_p').css({color: 'red', display: 'block'});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#quantity_wanted').css('border', '1px solid #BDC2C9');
|
||||
$('#minimal_quantity_wanted_p').css({color: '#374853'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initAttrSelector()
|
||||
{
|
||||
$('.attributes_group select').change(function()
|
||||
{
|
||||
findCombination();
|
||||
});
|
||||
$('.attributes_group input[type=radio]').click(function()
|
||||
{
|
||||
findCombination();
|
||||
});
|
||||
}
|
||||
|
||||
// search the combinations' case of attributes and update displaying of availability, prices, ecotax, and image
|
||||
function findCombination(firstTime)
|
||||
{
|
||||
$('#minimal_quantity_wanted_p').fadeOut();
|
||||
$('#quantity_wanted').val(1);
|
||||
|
||||
//create a temporary 'choice' array containing the choices of the customer
|
||||
var choice = new Array();
|
||||
$('div#attributes select, div#attributes input[type=hidden], div#attributes input[type=radio]:checked').each(function(){
|
||||
choice.push($(this).val());
|
||||
});
|
||||
|
||||
ProductFn.selectedCombination = new ProductCombination();
|
||||
var combinationFound = false;
|
||||
//testing every combination to find the conbination's attributes' case of the user
|
||||
for (var combination = 0; combination < ProductFn.combinations.length; ++combination)
|
||||
{
|
||||
var oCombination = ProductFn.combinations[combination];
|
||||
//verify if this combinaison is the same that the user's choice
|
||||
var combinationMatchForm = true;
|
||||
$.each(oCombination.idsAttributes, function(key, value) {
|
||||
if (!in_array(value, choice)) {
|
||||
combinationMatchForm = false;
|
||||
}
|
||||
});
|
||||
|
||||
if (combinationMatchForm)
|
||||
{
|
||||
combinationFound = true;
|
||||
//get the data of product with these attributes
|
||||
ProductFn.selectedCombination = oCombination;
|
||||
|
||||
if (oCombination.minimalQuantity > 1)
|
||||
{
|
||||
$('#minimal_quantity_label').html(oCombination.minimalQuantity);
|
||||
$('#minimal_quantity_wanted_p').fadeIn();
|
||||
$('#quantity_wanted').val(oCombination.minimalQuantity);
|
||||
}
|
||||
|
||||
ProductFn.checkMinimalQuantity();
|
||||
|
||||
// Is the hidden field for the form
|
||||
$('#idCombination').val(oCombination.id);
|
||||
|
||||
//get the data of product with these attributes
|
||||
ProductFn.quantityAvailable = oCombination.quantity;
|
||||
|
||||
// show the large image in relation to the selected combination
|
||||
if (oCombination.idImage && oCombination.idImage != -1)
|
||||
ProductDisplay.image(firstTime);
|
||||
|
||||
// show discounts values according to the selected combination
|
||||
if (oCombination.id && oCombination.id > 0)
|
||||
{
|
||||
ProductDisplay.discounts();
|
||||
ProductDisplay.refreshImages(oCombination.id);
|
||||
}
|
||||
|
||||
//leave the loop because combination has been found
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!combinationFound)
|
||||
{
|
||||
//this combination doesn't exist (not created in back office)
|
||||
ProductFn.selectedCombination.unavailable = true;
|
||||
}
|
||||
//update the display
|
||||
ProductDisplay.update();
|
||||
}
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: customAction + '?rand=' + new Date().getTime(),
|
||||
data: 'ajax=true&'+$('#customizationForm').serialize(),
|
||||
dataType: 'json',
|
||||
async : true,
|
||||
success: function(data) {
|
||||
$('#customizedDatas').fadeOut();
|
||||
$('#customizedDatas').html(input_save_customized_datas);
|
||||
$('#customizedDatas').fadeIn();
|
||||
if (!data.hasErrors)
|
||||
{
|
||||
$('#customizationForm').find('.error').fadeOut(function(){
|
||||
$(this).remove();
|
||||
});
|
||||
// display a confirmation message
|
||||
if ($('#customizationForm').find('.success').val() == undefined)
|
||||
$('#customizationForm').prepend("<p class='success'>"+data.conf+"</p>");
|
||||
else
|
||||
$('#customizationForm.success').html("<p class='success'>"+data.conf+"</p>");
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#customizationForm').find('.success').fadeOut(function(){
|
||||
$(this).remove();
|
||||
});
|
||||
// display an error message
|
||||
if ($('#customizationForm').find('.error').val() == undefined)
|
||||
{
|
||||
$('#customizationForm').prepend("<p class='error'></p>");
|
||||
for (var i = 0; i < data.errors.length; i++)
|
||||
$('#customizationForm .error').html($('#customizationForm .error').html()+data.errors[i]+"<br />");
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#customizationForm .error').html('');
|
||||
for (var i = 0; i < data.errors.length; i++)
|
||||
$('#customizationForm .error').html($('#customizationForm .error').html()+data.errors[i]+"<br />");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function checkUrl()
|
||||
{
|
||||
var url = ProductFn.original_url;
|
||||
// if we need to load a specific combination
|
||||
if (url.indexOf('#/') != -1)
|
||||
{
|
||||
// get the params to fill from a "normal" url
|
||||
var params = url.substring(url.indexOf('#') + 1, url.length);
|
||||
var tabParams = params.split('/');
|
||||
var tabValues = new Array();
|
||||
if (tabParams[0] == '')
|
||||
tabParams.shift();
|
||||
for (i in tabParams)
|
||||
tabValues.push(tabParams[i].split('-'));
|
||||
//var product_id = $('#product_page_product_id').val();
|
||||
// fill html with values
|
||||
var count = 0;
|
||||
for (z in tabValues)
|
||||
for (a in ProductFn.attributesCombinations)
|
||||
if (ProductFn.attributesCombinations[a].group == tabValues[z][0]
|
||||
&& ProductFn.attributesCombinations[a].attribute == tabValues[z][1])
|
||||
{
|
||||
count++;
|
||||
// add class 'selected' to the selected color
|
||||
$('#attributes').find('input:radio[value='+ProductFn.attributesCombinations[a].id_attribute+']').attr('checked', 'checked').checkboxradio("refresh")
|
||||
$('#attributes').find('input:hidden[name=group_'+ProductFn.attributesCombinations[a].id_attribute_group+']').val(ProductFn.attributesCombinations[a].id_attribute)
|
||||
$('#attributes').find('select[name=group_'+ProductFn.attributesCombinations[a].id_attribute_group+']')
|
||||
.find('option[value='+ProductFn.attributesCombinations[a].id_attribute+']').attr('selected', 'selected').end().selectmenu('refresh');;
|
||||
}
|
||||
// find combination
|
||||
if (count > 0) {
|
||||
findCombination(true);
|
||||
}
|
||||
var $url = $.mobile.path.parseUrl(ProductFn.original_url);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
var ProductDisplay = (function()
|
||||
{
|
||||
return {
|
||||
idDefaultImage: 0,
|
||||
//update display of the discounts table
|
||||
discounts: function()
|
||||
{
|
||||
$('#quantityDiscount table tbody tr').each(function() {
|
||||
if (($(this).attr('id') != 'quantityDiscount_0') &&
|
||||
($(this).attr('id') != 'quantityDiscount_'+ProductFn.selectedCombination.id) &&
|
||||
($(this).attr('id') != 'noQuantityDiscount'))
|
||||
$(this).fadeOut('slow');
|
||||
});
|
||||
|
||||
if ($('#quantityDiscount_'+ProductFn.selectedCombination.id).length != 0) {
|
||||
$('#quantityDiscount_'+ProductFn.selectedCombination.id).show();
|
||||
$('#noQuantityDiscount').hide();
|
||||
} else
|
||||
$('#noQuantityDiscount').show();
|
||||
},
|
||||
refreshImages: function(id_product_attribute)
|
||||
{
|
||||
// Change the current product images regarding the combination selected
|
||||
/*$('#thumbs_list_frame').scrollTo('li:eq(0)', 700, {axis:'x'});*/
|
||||
$('.thumbs_list li').hide();
|
||||
id_product_attribute = parseInt(id_product_attribute);
|
||||
|
||||
if (typeof(ProductFn.combinationImages) != 'undefined' && typeof(ProductFn.combinationImages[id_product_attribute]) != 'undefined')
|
||||
{
|
||||
for (var i = 0; i < ProductFn.combinationImages[id_product_attribute].length; i++)
|
||||
$('#thumbnail_' + parseInt(ProductFn.combinationImages[id_product_attribute][i])).show();
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
/*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_' + ProductDisplay.idDefaultImage).show();
|
||||
ProductDisplay.image($('#thumbnail_'+ ProductDisplay.idDefaultImage +' a'));
|
||||
}
|
||||
//$('#thumbs_list').trigger('goto', 0);
|
||||
//serialScrollFixLock('', '', '', '', 0);// SerialScroll Bug on goto 0 ?
|
||||
},
|
||||
//update display of the large image
|
||||
image: function($el, no_animation)
|
||||
{
|
||||
$el = $('#thumbnail_'+ProductFn.selectedCombination.idImage+' img');
|
||||
|
||||
if (typeof(no_animation) == 'undefined')
|
||||
no_animation = false;
|
||||
if ($el.data('large'))
|
||||
{
|
||||
var newSrc = $el.data('large').replace('thickbox','large');
|
||||
if ($('#bigpic').attr('src') != newSrc)
|
||||
{
|
||||
$('#bigpic').fadeOut((no_animation ? 0 : 'fast'), function() {
|
||||
$(this).attr('src', newSrc).show();
|
||||
});
|
||||
}
|
||||
$('.view_product .thumbs_list li a').removeClass('shown');
|
||||
$el.addClass('shown');
|
||||
}
|
||||
},
|
||||
|
||||
quantityIsAvailable: function()
|
||||
{
|
||||
//show the choice of quantities
|
||||
$('#quantity_wanted_p:hidden').show('slow');
|
||||
|
||||
//show the "add to cart" button ONLY if it was hidden
|
||||
$('#add_to_cart:hidden').fadeIn(600);
|
||||
|
||||
//hide availability date
|
||||
/* =============================================
|
||||
* Don't exists ??
|
||||
$('#availability_date_label').hide();
|
||||
$('#availability_date_value').hide();
|
||||
============================================= */
|
||||
|
||||
//availability value management
|
||||
if (ProductFn.availableNowValue != '')
|
||||
{
|
||||
//update the availability statut of the product
|
||||
$('#availability_value').removeClass('warning_inline');
|
||||
$('#availability_value').text(ProductFn.availableNowValue);
|
||||
$('#availability_statut:hidden').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
//hide the availability value
|
||||
$('#availability_statut:visible').hide();
|
||||
}
|
||||
|
||||
//'last quantities' message management
|
||||
if (!ProductFn.allowBuyWhenOutOfStock)
|
||||
{
|
||||
if (ProductFn.quantityAvailable <= ProductFn.maxQuantityToAllowDisplayOfLastQuantityMessage)
|
||||
$('#last_quantities').show('slow');
|
||||
else
|
||||
$('#last_quantities').hide('slow');
|
||||
}
|
||||
|
||||
if (ProductFn.quantitiesDisplayAllowed)
|
||||
{
|
||||
$('#pQuantityAvailable:hidden').show('slow');
|
||||
$('#quantityAvailable').text(ProductFn.quantityAvailable);
|
||||
|
||||
if (ProductFn.quantityAvailable < 2) // we have 1 or less product in stock and need to show "item" instead of "items"
|
||||
{
|
||||
$('#quantityAvailableTxt').show();
|
||||
$('#quantityAvailableTxtMultiple').hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#quantityAvailableTxt').hide();
|
||||
$('#quantityAvailableTxtMultiple').show();
|
||||
}
|
||||
}
|
||||
},
|
||||
quantityIsNotAvailable: function()
|
||||
{
|
||||
//hide 'last quantities' message if it was previously visible
|
||||
$('#last_quantities:visible').hide('slow');
|
||||
|
||||
//hide the quantity of pieces if it was previously visible
|
||||
$('#pQuantityAvailable:visible').hide('slow');
|
||||
|
||||
//hide the choice of quantities
|
||||
if (!ProductFn.allowBuyWhenOutOfStock)
|
||||
$('#quantity_wanted_p:visible').hide('slow');
|
||||
|
||||
//display that the product is unavailable with theses attributes
|
||||
if (!ProductFn.selectedCombination['unavailable'])
|
||||
$('#availability_value').text(ProductFn.doesntExistNoMore + (ProductFn.globalQuantity > 0 ? ' ' + ProductFn.doesntExistNoMoreBut : '')).addClass('warning_inline');
|
||||
else
|
||||
{
|
||||
$('#availability_value').text(doesntExist).addClass('warning_inline');
|
||||
$('#oosHook').hide();
|
||||
}
|
||||
$('#availability_statut:hidden').show();
|
||||
|
||||
//display availability date
|
||||
if (ProductFn.selectedCombination.length)
|
||||
{
|
||||
var available_date = ProductFn.selectedCombination['available_date'];
|
||||
tab_date = available_date.split('-');
|
||||
var time_available = new Date(tab_date[2], tab_date[1], tab_date[0]);
|
||||
time_available.setMonth(time_available.getMonth()-1);
|
||||
var now = new Date();
|
||||
// date displayed only if time_available
|
||||
if (now.getTime() < time_available.getTime())
|
||||
{
|
||||
$('#availability_date_value').text(ProductFn.selectedCombination['available_date']);
|
||||
$('#availability_date_label').show();
|
||||
$('#availability_date_value').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#availability_date_label').hide();
|
||||
$('#availability_date_value').hide();
|
||||
}
|
||||
}
|
||||
//show the 'add to cart' button ONLY IF it's possible to buy when out of stock AND if it was previously invisible
|
||||
if (ProductFn.allowBuyWhenOutOfStock && !ProductFn.selectedCombination['unavailable'] && ProductFn.productAvailableForOrder == 1)
|
||||
{
|
||||
$('#add_to_cart:hidden').fadeIn(600);
|
||||
|
||||
if (ProductFn.availableLaterValue != '')
|
||||
{
|
||||
$('#availability_value').text(ProductFn.availableLaterValue);
|
||||
$('p#availability_statut:hidden').show('slow');
|
||||
}
|
||||
else
|
||||
$('p#availability_statut:visible').hide('slow');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#add_to_cart:visible').fadeOut(600);
|
||||
$('p#availability_statut:hidden').show('slow');
|
||||
}
|
||||
|
||||
if (ProductFn.productAvailableForOrder == 0)
|
||||
$('p#availability_statut:visible').hide();
|
||||
},
|
||||
combinationRef: function()
|
||||
{
|
||||
if (ProductFn.selectedCombination.reference || ProductFn.productReference)
|
||||
{
|
||||
if (ProductFn.selectedCombination.reference)
|
||||
$('#product_reference span').text(ProductFn.selectedCombination.reference);
|
||||
else if (ProductFn.productReference)
|
||||
$('#product_reference span').text(ProductFn.productReference);
|
||||
$('#product_reference:hidden').show('slow');
|
||||
}
|
||||
else
|
||||
$('#product_reference:visible').hide('slow');
|
||||
},
|
||||
price: function()
|
||||
{
|
||||
// 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)
|
||||
if (!ProductFn.displayPrice && !ProductFn.noTaxForThisProduct)
|
||||
{
|
||||
var priceTaxExclWithoutGroupReduction = ps_round(ProductFn.productPriceTaxExcluded, 6) * (1 / ProductFn.group_reduction);
|
||||
} else {
|
||||
var priceTaxExclWithoutGroupReduction = ps_round(ProductFn.productPriceTaxExcluded, 6) * (1 / ProductFn.group_reduction);
|
||||
}
|
||||
var combination_add_price = ProductFn.selectedCombination.price * ProductFn.group_reduction;
|
||||
|
||||
var tax = (ProductFn.taxRate / 100) + 1;
|
||||
|
||||
var display_specific_price;
|
||||
if (ProductFn.selectedCombination.specific_price)
|
||||
{
|
||||
display_specific_price = ProductFn.selectedCombination.specific_price.price;
|
||||
if (ProductFn.selectedCombination.specific_price.reduction_type == 'percentage')
|
||||
{
|
||||
$('#reduction_amount').hide();
|
||||
$('#reduction_percent_display').html('-' + parseFloat(ProductFn.selectedCombination.specific_price.reduction_percent) + '%');
|
||||
$('#reduction_percent').show();
|
||||
} else if (ProductFn.selectedCombination.specific_price.reduction_type == 'amount') {
|
||||
$('#reduction_percent').hide();
|
||||
$('#reduction_amount').show();
|
||||
} else {
|
||||
$('#reduction_percent').hide();
|
||||
$('#reduction_amount').hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
display_specific_price = ProductFn.product_specific_price.price;
|
||||
if (ProductFn.product_specific_price.reduction_type == 'percentage')
|
||||
$('#reduction_percent_display').html(ProductFn.product_specific_price.specific_price.reduction_percent);
|
||||
}
|
||||
|
||||
if (ProductFn.product_specific_price.reduction_type != '' || ProductFn.selectedCombination.specific_price.reduction_type != '')
|
||||
$('#discount_reduced_price,#old_price').show();
|
||||
else
|
||||
$('#discount_reduced_price,#old_price').hide();
|
||||
|
||||
if (ProductFn.product_specific_price.reduction_type == 'percentage' || ProductFn.selectedCombination.specific_price.reduction_type == 'percentage')
|
||||
$('#reduction_percent').show();
|
||||
else
|
||||
$('#reduction_percent').hide();
|
||||
if (ProductFn.display_specific_price)
|
||||
$('#not_impacted_by_discount').show();
|
||||
else
|
||||
$('#not_impacted_by_discount').hide();
|
||||
|
||||
var taxExclPrice = 0;
|
||||
if (ProductFn.display_specific_price) {
|
||||
taxExclPrice = ProductFn.specific_currency ? ProductFn.display_specific_price : ProductFn.display_specific_price * ProductFn.currencyRate;
|
||||
} else {
|
||||
taxExclPrice = priceTaxExclWithoutGroupReduction;
|
||||
}
|
||||
taxExclPrice += ProductFn.selectedCombination['price'] * ProductFn.currencyRate
|
||||
|
||||
if (ProductFn.display_specific_price)
|
||||
ProductFn.productPriceWithoutReduction = priceTaxExclWithoutGroupReduction + selectedCombination['price'] * currencyRate; // Need to be global => no var
|
||||
|
||||
if (!ProductFn.displayPrice && !ProductFn.noTaxForThisProduct)
|
||||
{
|
||||
ProductFn.productPrice = taxExclPrice * tax; // Need to be global => no var
|
||||
if (ProductFn.display_specific_price)
|
||||
ProductFn.productPriceWithoutReduction = ps_round(ProductFn.productPriceWithoutReduction * tax, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProductFn.productPrice = ps_round(taxExclPrice, 2); // Need to be global => no var
|
||||
if (ProductFn.display_specific_price)
|
||||
ProductFn.productPriceWithoutReduction = ps_round(ProductFn.productPriceWithoutReduction, 2);
|
||||
}
|
||||
|
||||
var reduction = 0;
|
||||
if (ProductFn.selectedCombination.specific_price.reduction_price || ProductFn.selectedCombination.specific_price.reduction_percent)
|
||||
{
|
||||
ProductFn.selectedCombination.specific_price.reduction_price = (ProductFn.specific_currency ? ProductFn.selectedCombination.specific_price.reduction_price : ProductFn.selectedCombination.specific_price.reduction_price * ProductFn.currencyRate);
|
||||
reduction = ProductFn.productPrice * (parseFloat(ProductFn.selectedCombination.specific_price.reduction_percent) / 100) + ProductFn.selectedCombination.specific_price.reduction_price;
|
||||
if (ProductFn.selectedCombination.specific_price.reduction_price && (ProductFn.displayPrice || ProductFn.noTaxForThisProduct))
|
||||
reduction = ps_round(reduction / tax, 6);
|
||||
}
|
||||
else if (ProductFn.product_specific_price.reduction_price || ProductFn.product_specific_price.reduction_percent)
|
||||
{
|
||||
ProductFn.product_specific_price.reduction_price = (ProductFn.specific_currency ? ProductFn.product_specific_price.reduction_price : ProductFn.product_specific_price.reduction_price * ProductFn.currencyRate);
|
||||
reduction = ProductFn.productPrice * (parseFloat(ProductFn.product_specific_price.reduction_percent) / 100) + ProductFn.product_specific_price.reduction_price;
|
||||
if (ProductFn.product_specific_price.reduction_price && (ProductFn.displayPrice || ProductFn.noTaxForThisProduct))
|
||||
reduction = ps_round(reduction / tax, 6);
|
||||
}
|
||||
|
||||
if (!ProductFn.display_specific_price)
|
||||
ProductFn.productPriceWithoutReduction = ProductFn.productPrice * ProductFn.group_reduction;
|
||||
|
||||
|
||||
ProductFn.productPrice -= reduction;
|
||||
var tmp = ProductFn.productPrice * ProductFn.group_reduction;
|
||||
ProductFn.productPrice = ps_round(ProductFn.productPrice * ProductFn.group_reduction, 2);
|
||||
|
||||
var ecotaxAmount = !ProductFn.displayPrice ? ps_round(ProductFn.selectedCombination.ecotax * (1 + ProductFn.ecotaxTax_rate / 100), 2) : ProductFn.selectedCombination.ecotax;
|
||||
ProductFn.productPrice += ecotaxAmount;
|
||||
ProductFn.productPriceWithoutReduction += ecotaxAmount;
|
||||
|
||||
//productPrice = ps_round(productPrice * currencyRate, 2);
|
||||
var our_price = '';
|
||||
if (ProductFn.productPrice > 0) {
|
||||
our_price = formatCurrency(ProductFn.productPrice, ProductFn.currencyFormat, ProductFn.currencySign, ProductFn.currencyBlank);
|
||||
} else {
|
||||
our_price = formatCurrency(0, ProductFn.currencyFormat, ProductFn.currencySign, ProductFn.currencyBlank);
|
||||
}
|
||||
$('#our_price_display').text(our_price);
|
||||
|
||||
|
||||
$('#old_price_display').text(formatCurrency(ProductFn.productPriceWithoutReduction, ProductFn.currencyFormat, ProductFn.currencySign, ProductFn.currencyBlank));
|
||||
if (ProductFn.productPriceWithoutReduction > ProductFn.productPrice)
|
||||
$('#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"
|
||||
if (!ProductFn.noTaxForThisProduct)
|
||||
var productPricePretaxed = ProductFn.productPrice / tax;
|
||||
else
|
||||
var productPricePretaxed = ProductFn.productPrice;
|
||||
$('#pretaxe_price_display').text(formatCurrency(productPricePretaxed, ProductFn.currencyFormat, ProductFn.currencySign, ProductFn.currencyBlank));
|
||||
// Unit price
|
||||
ProductFn.productUnitPriceRatio = parseFloat(ProductFn.productUnitPriceRatio);
|
||||
if (ProductFn.productUnitPriceRatio > 0 )
|
||||
{
|
||||
var newUnitPrice = (productPrice / parseFloat(productUnitPriceRatio)) + selectedCombination['unit_price'];
|
||||
$('#unit_price_display').text(formatCurrency(newUnitPrice, currencyFormat, currencySign, currencyBlank));
|
||||
}
|
||||
|
||||
// Ecotax
|
||||
var ecotaxAmount = !ProductFn.displayPrice ? ps_round(ProductFn.selectedCombination.ecotax * (1 + ProductFn.ecotaxTax_rate / 100), 2) : ProductFn.selectedCombination.ecotax;
|
||||
$('#ecotax_price_display').text(formatCurrency(ecotaxAmount, ProductFn.currencyFormat, ProductFn.currencySign, ProductFn.currencyBlank));
|
||||
},
|
||||
//update display of the availability of the product AND the prices of the product
|
||||
update: function()
|
||||
{
|
||||
if (!ProductFn.selectedCombination.unavailable
|
||||
&& ProductFn.quantityAvailable > 0
|
||||
&& ProductFn.productAvailableForOrder == 1) {
|
||||
this.quantityIsAvailable();
|
||||
} else {
|
||||
this.quantityIsNotAvailable();
|
||||
}
|
||||
this.combinationRef();
|
||||
|
||||
//update display of the the prices in relation to tax, discount, ecotax, and currency criteria
|
||||
if (!ProductFn.selectedCombination.unavailable && ProductFn.productShowPrice == 1)
|
||||
{
|
||||
this.price();
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
function ProductCombination(id)
|
||||
{
|
||||
if (typeof id == 'undefined') {
|
||||
id = 0;
|
||||
}
|
||||
this.id = id;
|
||||
this.idsAttributes = [];
|
||||
this.quantity = 0;
|
||||
this.price = 0;
|
||||
this.ecotax = ProductFn.default_eco_tax;
|
||||
this.idImage = 0,
|
||||
this.reference = '';
|
||||
this.unitPrice = 0;
|
||||
this.minimalQuantity = 0;
|
||||
this.availableDate = '';
|
||||
this.specific_price = new SpecificPriceCombination();
|
||||
this.unavailable = false;
|
||||
}
|
||||
|
||||
function AttributeCombination(idAttribute)
|
||||
{
|
||||
this.id_attribute = idAttribute;
|
||||
this.attribute = '';
|
||||
this.group = '';
|
||||
this.id_attribute_group = '';
|
||||
}
|
||||
|
||||
function SpecificPriceCombination()
|
||||
{
|
||||
this.reduction_percent = 0;
|
||||
this.reduction_price = 0;
|
||||
this.price = 0;
|
||||
this.reduction_type = '';
|
||||
}
|
||||
|
||||
|
||||
// Disable for this page the JQM hash behaviour,
|
||||
// this allow to get the product attributes in the url.
|
||||
$(document).bind("mobileinit", function(){
|
||||
ProductFn.original_url = window.location+'';
|
||||
$.extend($.mobile , {
|
||||
hashListeningEnabled: false,
|
||||
});
|
||||
});
|
||||
|
||||
$( '.prestashop-page' ).live( 'pageshow',function(event)
|
||||
{
|
||||
initProductPage();
|
||||
if ($('.btn-cart').length)
|
||||
{
|
||||
if ($('.btn-cart').hasClass('disabled'))
|
||||
{
|
||||
$('.btn-cart').parent().addClass('disabled');
|
||||
$('.btn-cart').live('click', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
ProductFn.init();
|
||||
|
||||
$('img[data-large]').click(function() {
|
||||
$.scrollTo('0');
|
||||
});
|
||||
$('img[data-large]').touchGallery({
|
||||
getSource: function() {
|
||||
return $(this).data('large');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
$( '.prestashop-page' ).live( 'pageshow',function(event)
|
||||
{
|
||||
if ($('#stores_search_block .ui-btn').length)
|
||||
{
|
||||
$('#stores_search_block .ui-btn').live('click', function()
|
||||
{
|
||||
searchStores();
|
||||
});
|
||||
}
|
||||
});
|
||||
function searchStores()
|
||||
{
|
||||
// gets pattern and radius requested
|
||||
var pattern = $('#location').val();
|
||||
var radius = $('#radius').val();
|
||||
|
||||
// if pattern and radius are valid
|
||||
if (pattern != '' && radius > 0 && radius <= 100)
|
||||
{
|
||||
// as usual, ask Google for the coordinates :)
|
||||
var geocoder = new google.maps.Geocoder();
|
||||
geocoder.geocode({address: pattern}, function(res, code) {
|
||||
|
||||
if (code == google.maps.GeocoderStatus.OK)
|
||||
getStores(res[0].geometry.location, radius);
|
||||
|
||||
});
|
||||
}
|
||||
else if ($('.stores_block').is(':visible'))
|
||||
$('.stores_block').hide();
|
||||
}
|
||||
|
||||
function getStores(coordinates, radius)
|
||||
{
|
||||
// given the coordinates, gets latitude/longitude
|
||||
var latitude = coordinates.lat();
|
||||
var longitude = coordinates.lng();
|
||||
|
||||
// if parameters are valid, calls the StoresController
|
||||
if (latitude != undefined && latitude != undefined && radius != undefined)
|
||||
{
|
||||
// ajax call
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
headers: { "cache-control": "no-cache" },
|
||||
url: 'index.php?controller=stores' + '&rand=' + new Date().getTime(),
|
||||
data: 'ajax=true&latitude=' + latitude + '&longitude=' + longitude + '&radius=' + radius,
|
||||
dataType: 'json',
|
||||
async : true,
|
||||
success: function(data) {
|
||||
var list = $('#stores_list');
|
||||
// hide if nothing to display
|
||||
if (data.length == 0)
|
||||
list.hide();
|
||||
else // constructs <ul>
|
||||
{
|
||||
// resets the list
|
||||
list.html('');
|
||||
// for each stores to display
|
||||
$.each(data, function(index, element) {
|
||||
// constructs the address
|
||||
var store_address = '';
|
||||
store_address += element.address1 + (element.address2 != null ? element.address2 : ' ') + ', ';
|
||||
store_address += element.city + ', ' + element.postcode + (element.state != null ? ' ' + element.state : '') + ', ' + element.country;
|
||||
|
||||
// apprends <li>, wrapped in a google map link
|
||||
list.append($(
|
||||
'<li>' +
|
||||
'<a href="http://maps.google.com/maps?q=' + encodeURI(store_address) + '">' +
|
||||
'<img src="' + img_store_dir + parseInt(element.picture) + '.jpg" width="80"/>' +
|
||||
'<h3>'+ element.name +' (' + Math.floor(element.distance) + distance_unit + ')</h3>' +
|
||||
'<p>' + store_address + '</p>' +
|
||||
'</a>' +
|
||||
'</li>'))
|
||||
});
|
||||
|
||||
// display the list and refresh
|
||||
list.parent().show();
|
||||
list.listview('refresh');
|
||||
// scroll
|
||||
$('html, body').animate({scrollTop: list.parent().offset().top},'slow');
|
||||
}
|
||||
},
|
||||
error: function(XMLHttpRequest, status) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user