// saving customization improved
This commit is contained in:
@@ -487,15 +487,16 @@ class ProductControllerCore extends FrontController
|
|||||||
|
|
||||||
$product_picture_width = (int)Configuration::get('PS_PRODUCT_PICTURE_WIDTH');
|
$product_picture_width = (int)Configuration::get('PS_PRODUCT_PICTURE_WIDTH');
|
||||||
$product_picture_height = (int)Configuration::get('PS_PRODUCT_PICTURE_HEIGHT');
|
$product_picture_height = (int)Configuration::get('PS_PRODUCT_PICTURE_HEIGHT');
|
||||||
if ($error || (!$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($file['tmp_name'], $tmp_name)))
|
$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
|
||||||
|
if ($error || (!$tmp_name || !move_uploaded_file($file['tmp_name'], $tmp_name)))
|
||||||
return false;
|
return false;
|
||||||
/* Original file */
|
/* Original file */
|
||||||
else if (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name))
|
if (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name))
|
||||||
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
||||||
/* A smaller one */
|
/* A smaller one */
|
||||||
else if (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name.'_small', $product_picture_width, $product_picture_height))
|
elseif (!ImageManager::resize($tmp_name, _PS_UPLOAD_DIR_.$file_name.'_small', $product_picture_width, $product_picture_height))
|
||||||
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
||||||
else if (!chmod(_PS_UPLOAD_DIR_.$file_name, 0777) || !chmod(_PS_UPLOAD_DIR_.$file_name.'_small', 0777))
|
elseif (!chmod(_PS_UPLOAD_DIR_.$file_name, 0777) || !chmod(_PS_UPLOAD_DIR_.$file_name.'_small', 0777))
|
||||||
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -575,22 +576,5 @@ class ProductControllerCore extends FrontController
|
|||||||
}
|
}
|
||||||
return $specific_prices;
|
return $specific_prices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postProcess()
|
|
||||||
{
|
|
||||||
if ($this->ajax)
|
|
||||||
{
|
|
||||||
if (Tools::isSubmit('submitCustomizedDatas'))
|
|
||||||
{
|
|
||||||
$this->pictureUpload($this->product, $this->context->cart);
|
|
||||||
$this->textRecord($this->product, $this->context->cart);
|
|
||||||
$this->formTargetFormat();
|
|
||||||
}
|
|
||||||
if (count($this->errors))
|
|
||||||
die(Tools::jsonEncode(array('hasErrors' => true, 'errors' => $this->errors)));
|
|
||||||
else
|
|
||||||
die(Tools::jsonEncode(array('hasErrors' => false, 'conf' => Tools::displayError('Customization saved successfully.'))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ var combinations = new Array();
|
|||||||
var selectedCombination = new Array();
|
var selectedCombination = new Array();
|
||||||
var globalQuantity = new Number;
|
var globalQuantity = new Number;
|
||||||
var colors = new Array();
|
var colors = new Array();
|
||||||
var input_save_customized_datas = '';
|
|
||||||
|
|
||||||
//check if a function exists
|
//check if a function exists
|
||||||
function function_exists(function_name)
|
function function_exists(function_name)
|
||||||
@@ -119,13 +118,13 @@ function findCombination(firstTime)
|
|||||||
else
|
else
|
||||||
selectedCombination['ecotax'] = default_eco_tax;
|
selectedCombination['ecotax'] = default_eco_tax;
|
||||||
|
|
||||||
//show the large image in relation to the selected combination
|
//show the large image in relation to the selected combination
|
||||||
if (typeof(firstTime) != 'undefined' && !firstTime && combinations[combination]['image'] && combinations[combination]['image'] != -1)
|
if (combinations[combination]['image'] && combinations[combination]['image'] != -1)
|
||||||
displayImage($('#thumb_'+combinations[combination]['image']).parent(), firstTime);
|
displayImage( $('#thumb_'+combinations[combination]['image']).parent() );
|
||||||
|
|
||||||
//show discounts values according to the selected combination
|
//show discounts values according to the selected combination
|
||||||
if (combinations[combination]['idCombination'] && combinations[combination]['idCombination'] > 0)
|
if (combinations[combination]['idCombination'] && combinations[combination]['idCombination'] > 0)
|
||||||
displayDiscounts(combinations[combination]['idCombination']);
|
displayDiscounts(combinations[combination]['idCombination']);
|
||||||
|
|
||||||
//get available_date for combination product
|
//get available_date for combination product
|
||||||
selectedCombination['available_date'] = combinations[combination]['available_date'];
|
selectedCombination['available_date'] = combinations[combination]['available_date'];
|
||||||
@@ -394,7 +393,6 @@ function updateDisplay()
|
|||||||
else
|
else
|
||||||
$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank));
|
$('#our_price_display').text(formatCurrency(0, currencyFormat, currencySign, currencyBlank));
|
||||||
|
|
||||||
|
|
||||||
$('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
|
$('#old_price_display').text(formatCurrency(productPriceWithoutReduction, currencyFormat, currencySign, currencyBlank));
|
||||||
if (productPriceWithoutReduction > productPrice)
|
if (productPriceWithoutReduction > productPrice)
|
||||||
$('#old_price,#old_price_display,#old_price_display_taxes').show();
|
$('#old_price,#old_price_display,#old_price_display_taxes').show();
|
||||||
@@ -552,7 +550,6 @@ $(document).ready(function()
|
|||||||
|
|
||||||
// Hide the customization submit button and display some message
|
// Hide the customization submit button and display some message
|
||||||
$('p#customizedDatas input').click(function() {
|
$('p#customizedDatas input').click(function() {
|
||||||
input_save_customized_datas = $('p#customizedDatas').html();
|
|
||||||
$('p#customizedDatas input').hide();
|
$('p#customizedDatas input').hide();
|
||||||
$('#ajax-loader').fadeIn();
|
$('#ajax-loader').fadeIn();
|
||||||
$('p#customizedDatas').append(uploading_in_progress);
|
$('p#customizedDatas').append(uploading_in_progress);
|
||||||
@@ -561,7 +558,6 @@ $(document).ready(function()
|
|||||||
//init the price in relation of the selected attributes
|
//init the price in relation of the selected attributes
|
||||||
if (typeof productHasAttributes != 'undefined' && productHasAttributes)
|
if (typeof productHasAttributes != 'undefined' && productHasAttributes)
|
||||||
findCombination(true);
|
findCombination(true);
|
||||||
|
|
||||||
else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
|
else if (typeof productHasAttributes != 'undefined' && !productHasAttributes)
|
||||||
refreshProductImages(0);
|
refreshProductImages(0);
|
||||||
|
|
||||||
@@ -589,50 +585,8 @@ function saveCustomization()
|
|||||||
$('body select[id^="group_"]').each(function() {
|
$('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);
|
||||||
$.ajax({
|
$('#customizationForm').submit();
|
||||||
type: 'POST',
|
|
||||||
url: customAction,
|
|
||||||
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 submitPublishProduct(url, redirect)
|
function submitPublishProduct(url, redirect)
|
||||||
@@ -706,6 +660,9 @@ function getProductAttribute()
|
|||||||
// redirection
|
// redirection
|
||||||
if (url.indexOf('#') != -1)
|
if (url.indexOf('#') != -1)
|
||||||
url = url.substring(0, url.indexOf('#'));
|
url = url.substring(0, url.indexOf('#'));
|
||||||
|
|
||||||
|
// set ipa to the customization form
|
||||||
|
$('#customizationForm').attr('action', $('#customizationForm').attr('action')+request)
|
||||||
window.location = url+request;
|
window.location = url+request;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,4 +716,4 @@ function checkUrl()
|
|||||||
window.location = url.substring(0, url.indexOf('#'));
|
window.location = url.substring(0, url.indexOf('#'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user