// Merge -> 10309
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10333 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -262,6 +262,7 @@ class AuthControllerCore extends FrontController
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->context->cookie->id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: CompareProduct::getIdCompareByIdCustomer($customer->id);
|
||||
$this->context->cookie->id_customer = (int)($customer->id);
|
||||
$this->context->cookie->customer_lastname = $customer->lastname;
|
||||
$this->context->cookie->customer_firstname = $customer->firstname;
|
||||
@@ -278,10 +279,10 @@ class AuthControllerCore extends FrontController
|
||||
$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
|
||||
$this->context->cart->update();
|
||||
Hook::exec('authentication');
|
||||
|
||||
|
||||
// Login information have changed, so we check if the cart rules still apply
|
||||
CartRule::autoRemoveFromCart();
|
||||
|
||||
|
||||
if (!$this->ajax)
|
||||
{
|
||||
if ($back = Tools::getValue('back'))
|
||||
@@ -618,15 +619,15 @@ class AuthControllerCore extends FrontController
|
||||
protected function sendConfirmationMail(Customer $customer)
|
||||
{
|
||||
return Mail::Send(
|
||||
$this->context->language->id,
|
||||
'account',
|
||||
$this->context->language->id,
|
||||
'account',
|
||||
Mail::l('Welcome!'),
|
||||
array(
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{email}' => $customer->email,
|
||||
'{passwd}' => Tools::getValue('passwd')),
|
||||
$customer->email,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{email}' => $customer->email,
|
||||
'{passwd}' => Tools::getValue('passwd')),
|
||||
$customer->email,
|
||||
$customer->firstname.' '.$customer->lastname
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,19 +112,19 @@ class CartControllerCore extends FrontController
|
||||
}
|
||||
CartRule::autoRemoveFromCart();
|
||||
}
|
||||
|
||||
|
||||
protected function processChangeProductAddressDelivery()
|
||||
{
|
||||
$old_id_address_delivery = (int)Tools::getValue('old_id_address_delivery');
|
||||
$new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery');
|
||||
|
||||
|
||||
$this->context->cart->setProductAddressDelivery(
|
||||
$this->id_product,
|
||||
$this->id_product_attribute,
|
||||
$old_id_address_delivery,
|
||||
$new_id_address_delivery);
|
||||
}
|
||||
|
||||
|
||||
protected function processDuplicateProduct()
|
||||
{
|
||||
if (
|
||||
@@ -249,6 +249,7 @@ class CartControllerCore extends FrontController
|
||||
$id_country = (isset($deliveryAddress) && $deliveryAddress->id) ? $deliveryAddress->id_country : Configuration::get('PS_COUNTRY_DEFAULT');
|
||||
$result['carriers'] = Carrier::getCarriersForOrder(Country::getIdZone($id_country), $groups);
|
||||
//$result['checked'] = Carrier::getDefaultCarrierSelection($result['carriers'], (int)$this->cart->id_carrier);
|
||||
$result['HOOK_EXTRACARRIER'] = Module::hookExec('extraCarrier', array('address' => (isset($deliveryAddress) && (int)$deliveryAddress->id) ? $deliveryAddress : null));
|
||||
}
|
||||
$result['summary'] = $this->context->cart->getSummaryDetails();
|
||||
$result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true);
|
||||
|
||||
@@ -83,15 +83,14 @@ class CategoryControllerCore extends FrontController
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
if (isset($this->context->customer->id))
|
||||
$this->context->smarty->assign('compareProducts', CompareProduct::getCustomerCompareProducts($this->context->customer->id));
|
||||
else if (isset($this->context->customer->id_guest))
|
||||
$this->context->smarty->assign('compareProducts', CompareProduct::getGuestCompareProducts($this->context->customer->id_guest));
|
||||
if (isset($this->context->cookie->id_compare))
|
||||
$this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare));
|
||||
|
||||
|
||||
$this->assignScenes();
|
||||
if ($this->category->id != 1)
|
||||
$this->assignProductList();
|
||||
|
||||
|
||||
$this->productSort();
|
||||
$this->context->smarty->assign(array(
|
||||
'category' => $this->category,
|
||||
|
||||
@@ -43,32 +43,21 @@ class CompareControllerCore extends FrontController
|
||||
*/
|
||||
public function displayAjax()
|
||||
{
|
||||
//Add or remove product with Ajax
|
||||
if (Tools::getValue('id_product') && Tools::getValue('action'))
|
||||
// Add or remove product with Ajax
|
||||
if (Tools::getValue('ajax') && Tools::getValue('id_product') && Tools::getValue('action'))
|
||||
{
|
||||
if (Tools::getValue('action') == 'add')
|
||||
{
|
||||
if (isset($this->context->customer->id))
|
||||
{
|
||||
if (CompareProduct::getCustomerNumberProducts($this->context->customer->id) < Configuration::get('PS_COMPARATOR_MAX_ITEM'))
|
||||
CompareProduct::addCustomerCompareProduct((int)$this->context->customer->id, (int)Tools::getValue('id_product'));
|
||||
else
|
||||
die('0');
|
||||
}
|
||||
$id_compare = isset($this->context->cookie->id_compare) ? $this->context->cookie->id_compare: false;
|
||||
if (CompareProduct::getNumberProducts($id_compare) < Configuration::get('PS_COMPARATOR_MAX_ITEM'))
|
||||
CompareProduct::addCompareProduct($id_compare, (int)Tools::getValue('id_product'));
|
||||
else
|
||||
{
|
||||
if ((isset($this->context->customer->id_guest) && CompareProduct::getGuestNumberProducts($this->context->customer->id_guest) < Configuration::get('PS_COMPARATOR_MAX_ITEM')))
|
||||
CompareProduct::addGuestCompareProduct((int)$this->context->customer->id_guest, (int)Tools::getValue('id_product'));
|
||||
else
|
||||
die('0');
|
||||
}
|
||||
die('0');
|
||||
}
|
||||
else if (Tools::getValue('action') == 'remove')
|
||||
{
|
||||
if (isset($this->context->customer->id))
|
||||
CompareProduct::removeCustomerCompareProduct((int)$this->context->customer->id, (int)Tools::getValue('id_product'));
|
||||
else if (isset($this->context->customer->id_guest))
|
||||
CompareProduct::removeGuestCompareProduct((int)$this->context->customer->id_guest, (int)Tools::getValue('id_product'));
|
||||
if (isset(self::$cookie->id_compare))
|
||||
CompareProduct::removeCompareProduct((int)$this->context->cookie->id_compare, (int)Tools::getValue('id_product'));
|
||||
else
|
||||
die('0');
|
||||
}
|
||||
@@ -95,10 +84,8 @@ class CompareControllerCore extends FrontController
|
||||
|
||||
if ($product_list = Tools::getValue('compare_product_list') && ($postProducts = (isset($product_list) ? rtrim($product_list, '|') : '')))
|
||||
$ids = array_unique(explode('|', $postProducts));
|
||||
else if (isset($this->context->customer->id))
|
||||
$ids = CompareProduct::getCustomerCompareProducts($this->context->customer->id);
|
||||
else if (isset($this->context->customer->id_guest))
|
||||
$ids = CompareProduct::getGuestCompareProducts($this->context->customer->id_guest);
|
||||
else if (isset(self::$cookie->id_compare))
|
||||
$ids = CompareProduct::getCompareProducts($this->context->cookie->id_compare);
|
||||
else
|
||||
$ids = null;
|
||||
|
||||
|
||||
@@ -64,18 +64,26 @@ class OrderControllerCore extends ParentOrderController
|
||||
|
||||
if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3)))
|
||||
Tools::redirect('index.php?controller=authentication&back='.urlencode('order.php&step='.$this->step));
|
||||
|
||||
|
||||
if (Tools::getValue('multi-shipping') == 1)
|
||||
$this->context->smarty->assign('multi_shipping', true);
|
||||
else
|
||||
$this->context->smarty->assign('multi_shipping', false);
|
||||
|
||||
|
||||
if ($this->context->customer->id)
|
||||
$this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
|
||||
else
|
||||
$this->context->smarty->assign('address_list', array());
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
// Update carrier selected on preProccess in order to fix a bug of
|
||||
// block cart when it's hooked on leftcolumn
|
||||
if ($this->step == 3 && Tools::isSubmit('processCarrier'))
|
||||
$this->processCarrier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign template vars related to page content
|
||||
* @see FrontController::initContent()
|
||||
@@ -94,7 +102,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
$this->context->smarty->assign('empty', 1);
|
||||
$this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');
|
||||
break;
|
||||
|
||||
|
||||
case 1:
|
||||
$this->_assignAddress();
|
||||
$this->processAddressFormat();
|
||||
@@ -118,11 +126,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
case 3:
|
||||
// Test that the conditions (so active) were accepted by the customer
|
||||
$cgv = Tools::getValue('cgv');
|
||||
if (Configuration::get('PS_CONDITIONS') && (!Validate::isBool($cgv)))
|
||||
if (Configuration::get('PS_CONDITIONS') && (!Validate::isBool($cgv) || $cgv == false))
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
|
||||
if (Tools::isSubmit('processCarrier'))
|
||||
$this->processCarrier();
|
||||
$this->autoStep();
|
||||
|
||||
// Bypass payment step if total is 0
|
||||
@@ -201,9 +207,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
{
|
||||
if (!Tools::getValue('multi-shipping'))
|
||||
$this->context->cart->setNoMultishipping();
|
||||
|
||||
|
||||
// Add checking for all addresses
|
||||
|
||||
|
||||
if (!Tools::isSubmit('id_address_delivery') || !Address::isCountryActiveById((int)Tools::getValue('id_address_delivery')))
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
else
|
||||
@@ -247,7 +253,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
}
|
||||
$orderTotal = $this->context->cart->getOrderTotal();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Address step
|
||||
*/
|
||||
@@ -257,7 +263,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
|
||||
if (Tools::getValue('multi-shipping'))
|
||||
$this->context->cart->autosetProductAddress();
|
||||
|
||||
|
||||
$this->context->smarty->assign('cart', $this->context->cart);
|
||||
if ($this->context->customer->is_guest)
|
||||
Tools::redirect('index.php?controller=order&step=2');
|
||||
|
||||
@@ -207,10 +207,13 @@ class ProductControllerCore extends FrontController
|
||||
protected function assignPriceAndTax()
|
||||
{
|
||||
$id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0);
|
||||
$group_reduction = (100 - Group::getReduction($id_customer)) / 100;
|
||||
$id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
|
||||
$id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT');
|
||||
|
||||
$group_reduction = GroupReduction::getValueForProduct($this->product->id, $id_group);
|
||||
if ($group_reduction == 0)
|
||||
$group_reduction = Group::getReduction((int)$this->context->cookie->id_customer) / 100;
|
||||
|
||||
// Tax
|
||||
$tax = (float)$this->product->getTaxesRate(new Address((int)$this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||
$this->context->smarty->assign('tax_rate', $tax);
|
||||
@@ -228,7 +231,7 @@ class ProductControllerCore extends FrontController
|
||||
$id_currency = (int)$this->context->cookie->id_currency;
|
||||
$id_product = (int)$this->product->id;
|
||||
$id_shop = $this->context->shop->getID(true);
|
||||
|
||||
|
||||
$quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group, null, true);
|
||||
foreach($quantity_discounts as &$quantity_discount)
|
||||
if ($quantity_discount['id_product_attribute'])
|
||||
@@ -239,7 +242,7 @@ class ProductControllerCore extends FrontController
|
||||
$quantity_discount['attributes'] = $attribute['name'].' - ';
|
||||
$quantity_discount['attributes'] = rtrim($quantity_discount['attributes'], ' - ');
|
||||
}
|
||||
|
||||
|
||||
$product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
|
||||
$address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
|
||||
$this->context->smarty->assign(array(
|
||||
@@ -248,7 +251,7 @@ class ProductControllerCore extends FrontController
|
||||
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2),
|
||||
'ecotaxTax_rate' => $ecotax_rate,
|
||||
'productPriceWithoutEcoTax' => (float)$product_price_without_eco_tax,
|
||||
'group_reduction' => $group_reduction,
|
||||
'group_reduction' => (1 - $group_reduction),,
|
||||
'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address),
|
||||
'ecotax' => (!count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((float)$this->product->ecotax) : 0),
|
||||
'tax_enabled' => Configuration::get('PS_TAX')
|
||||
@@ -295,13 +298,13 @@ class ProductControllerCore extends FrontController
|
||||
{
|
||||
$colors = array();
|
||||
$groups = array();
|
||||
|
||||
|
||||
// @todo (RM) should only get groups and not all declination ?
|
||||
$attributes_groups = $this->product->getAttributesGroups($this->context->language->id);
|
||||
if (is_array($attributes_groups) && $attributes_groups)
|
||||
{
|
||||
$combination_images = $this->product->getCombinationImages($this->context->language->id);
|
||||
|
||||
|
||||
foreach ($attributes_groups as $k => $row)
|
||||
{
|
||||
// Color management
|
||||
@@ -319,7 +322,7 @@ class ProductControllerCore extends FrontController
|
||||
'group_type' => $row['group_type'],
|
||||
'default' => -1,
|
||||
);
|
||||
|
||||
|
||||
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
|
||||
if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1)
|
||||
$groups[$row['id_attribute_group']]['default'] = (int)$row['id_attribute'];
|
||||
@@ -344,7 +347,7 @@ class ProductControllerCore extends FrontController
|
||||
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
|
||||
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
|
||||
$combinations[$row['id_product_attribute']]['available_date'] = $available_date;
|
||||
|
||||
|
||||
if (isset($combination_images[$row['id_product_attribute']][0]['id_image']))
|
||||
$combinations[$row['id_product_attribute']]['id_image'] = $combination_images[$row['id_product_attribute']][0]['id_image'];
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user