[-] FO: Fix PSCFV-4078

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17458 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
rGaillard
2012-09-21 13:06:53 +00:00
parent 2897c024ce
commit 4dac4d9609
4 changed files with 54 additions and 20 deletions
+4 -3
View File
@@ -781,8 +781,9 @@ class CartCore extends ObjectModel
$sql .= '
WHERE cp.`id_product` = '.(int)$id_product.'
AND cp.`id_product_attribute` = '.(int)$id_product_attribute.'
AND cp.`id_cart` = '.(int)$this->id.'
AND cp.`id_address_delivery` = '.(int)$id_address_delivery;
AND cp.`id_cart` = '.(int)$this->id;
if (Configuration::get('PS_ALLOW_MULTISHIPPING') && $this->isMultiAddressDelivery())
$sql .= ' AND cp.`id_address_delivery` = '.(int)$id_address_delivery;
if ($id_customization)
$sql .= ' AND c.`id_customization` = '.(int)$id_customization;
@@ -886,7 +887,7 @@ class CartCore extends ObjectModel
SET `quantity` = `quantity` '.$qty.', `date_add` = NOW()
WHERE `id_product` = '.(int)$id_product.
(!empty($id_product_attribute) ? ' AND `id_product_attribute` = '.(int)$id_product_attribute : '').'
AND `id_cart` = '.(int)$this->id.' AND `id_address_delivery` = '.(int)$id_address_delivery.'
AND `id_cart` = '.(int)$this->id.(Configuration::get('PS_ALLOW_MULTISHIPPING') && $this->isMultiAddressDelivery() ? ' AND `id_address_delivery` = '.(int)$id_address_delivery : '').'
LIMIT 1'
);
}
+31 -7
View File
@@ -72,12 +72,13 @@ class OrderOpcControllerCore extends ParentOrderController
if ($this->_processCarrier())
{
$carriers = $this->context->cart->simulateCarriersOutput();
$return = array(
'summary' => $this->context->cart->getSummaryDetails(),
$return = array_merge(array(
'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
'carrier_data' => $this->_getCarrierList(),
'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array('carriers' => $carriers))
),
$this->getFormatedSummaryDetail()
);
Cart::addExtraCarriers($return);
die(Tools::jsonEncode($return));
@@ -146,8 +147,7 @@ class OrderOpcControllerCore extends ParentOrderController
$wrapping_fees = (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
$wrapping_fees_tax = new Tax((int)(Configuration::get('PS_GIFT_WRAPPING_TAX')));
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
$return = array(
'summary' => $this->context->cart->getSummaryDetails(),
$return = array_merge(array(
'order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'),
'block_user_info' => (isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : ''),
'carrier_data' => $this->_getCarrierList(),
@@ -155,6 +155,8 @@ class OrderOpcControllerCore extends ParentOrderController
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
'no_address' => 0,
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)($this->context->cookie->id_currency))))
),
$this->getFormatedSummaryDetail()
);
die(Tools::jsonEncode($return));
}
@@ -208,12 +210,12 @@ class OrderOpcControllerCore extends ParentOrderController
$wrapping_fees_tax = new Tax((int)(Configuration::get('PS_GIFT_WRAPPING_TAX')));
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
$result = array_merge($result, array(
'summary' => $this->context->cart->getSummaryDetails(),
'HOOK_TOP_PAYMENT' => Hook::exec('displayPaymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)($this->context->cookie->id_currency)))),
'carrier_data' => $this->_getCarrierList()
));
'carrier_data' => $this->_getCarrierList()),
$this->getFormatedSummaryDetail()
);
die(Tools::jsonEncode($result));
}
}
@@ -575,5 +577,27 @@ class OrderOpcControllerCore extends ParentOrderController
$this->context->smarty->assign($adr_type.'_all_fields', ${$adr_type.'_all_fields'});
}
}
protected function getFormatedSummaryDetail()
{
$result = array('summary' => $this->context->cart->getSummaryDetails(),
'customizedDatas' => Product::getAllCustomizedDatas($this->context->cart->id, null, true)
);
foreach ($result['summary']['products'] as $key => &$product)
{
$product['quantity_without_customization'] = $product['quantity'];
if ($result['customizedDatas'])
{
foreach ($result['customizedDatas'][(int)$product['id_product']][(int)$product['id_product_attribute']] as $addresses)
foreach ($addresses as $customization)
$product['quantity_without_customization'] -= (int)$customization['quantity'];
}
}
if ($result['customizedDatas'])
Product::addCustomizationPrice($result['summary']['products'], $result['customizedDatas']);
return $result;
}
}
+3 -5
View File
@@ -538,12 +538,11 @@ function updateCartSummary(json)
return;
$('.cart_quantity_input').val(0);
product_list = {};
for (i=0;i<json.products.length;i++)
{
product_list[json.products[i].id_product+'_'+json.products[i].id_product_attribute+'_'+json.products[i].id_address_delivery] = json.products[i];
}
if (!$('.multishipping-cart:visible').length)
{
for (i=0;i<json.gift_products.length;i++)
@@ -560,7 +559,7 @@ function updateCartSummary(json)
product_list[json.gift_products[i].id_product+'_'+json.gift_products[i].id_product_attribute+'_'+json.gift_products[i].id_address_delivery] = json.gift_products[i];
}
}
for (i in product_list)
{
// if reduction, we need to show it in the cart by showing the initial price above the current one
@@ -598,7 +597,6 @@ function updateCartSummary(json)
}
nbrProducts += parseInt(product_list[i].quantity);
$('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_0_'+product_list[i].id_address_delivery+']').val(product_list[i].quantity_without_customization);
$('input[name=quantity_'+product_list[i].id_product+'_'+product_list[i].id_product_attribute+'_0_'+product_list[i].id_address_delivery+'_hidden]').val(product_list[i].quantity_without_customization);
+16 -5
View File
@@ -48,7 +48,7 @@ function updateAddressSelection()
{
var idAddress_delivery = ($('input#opc_id_address_delivery').length == 1 ? $('input#opc_id_address_delivery').val() : $('#id_address_delivery').val());
var idAddress_invoice = ($('input#opc_id_address_invoice').length == 1 ? $('input#opc_id_address_invoice').val() : ($('input[type=checkbox]#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('#id_address_invoice').length == 1 ? $('select#id_address_invoice').val() : idAddress_delivery)));
$('#opc_account-overlay').fadeIn('slow');
$('#opc_delivery_methods-overlay').fadeIn('slow');
$('#opc_payment_methods-overlay').fadeIn('slow');
@@ -78,7 +78,7 @@ function updateAddressSelection()
$(this)
.removeClass('address_'+deliveryAddress)
.addClass('address_'+idAddress_delivery);
$(this).attr('id', $(this).attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
if ($(this).find('.cart_unit span').length > 0 && $(this).find('.cart_unit span').attr('id').length > 0)
$(this).find('.cart_unit span').attr('id', $(this).find('.cart_unit span').attr('id').replace(/_\d+$/, '_'+idAddress_delivery));
@@ -88,10 +88,8 @@ function updateAddressSelection()
if ($(this).find('.cart_quantity_input').length > 0 && $(this).find('.cart_quantity_input').attr('name').length > 0)
{
name = $(this).find('.cart_quantity_input').attr('name')+'_hidden';
$(this).find('.cart_quantity_input').attr('name', $(this).find('.cart_quantity_input').attr('name').replace(/_\d+$/, '_'+idAddress_delivery));
if ($(this).find('[name='+name+']')> 0)
if ($(this).find('[name='+name+']').length > 0)
$(this).find('[name='+name+']').attr('name', name.replace(/_\d+_hidden$/, '_'+idAddress_delivery+'_hidden'));
}
@@ -100,6 +98,19 @@ function updateAddressSelection()
.attr('id', $(this).find('.cart_quantity_delete').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
.attr('href', $(this).find('.cart_quantity_delete').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'))
}
if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0) {
$(this).find('.cart_quantity_down')
.attr('id', $(this).find('.cart_quantity_down').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
.attr('href', $(this).find('.cart_quantity_down').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'))
}
if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0) {
$(this).find('.cart_quantity_up')
.attr('id', $(this).find('.cart_quantity_up').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
.attr('href', $(this).find('.cart_quantity_up').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'))
}
});
// Update global var deliveryAddress