// Merging multishipping branche on 1.5
This commit is contained in:
@@ -214,6 +214,14 @@ class AdminCarriersControllerCore extends AdminController
|
||||
'maxlength' => 128,
|
||||
'p' => $this->l('Time taken for product delivery; displayed during checkout')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Grade:'),
|
||||
'name' => 'grade',
|
||||
'required' => false,
|
||||
'size' => 1,
|
||||
'p' => $this->l('"0" for a longest shipping delay,"9" for the shortest shipping delay.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('URL:'),
|
||||
@@ -360,6 +368,38 @@ class AdminCarriersControllerCore extends AdminController
|
||||
),
|
||||
'p' => $this->l('Out-of-range behavior when none is defined (e.g., when a customer\'s cart weight is greater than the highest range limit)')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package height:'),
|
||||
'name' => 'max_height',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'p' => $this->l('Maximum height managed by this carrier. Set "0" or nothing, to ignore this field.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package width:'),
|
||||
'name' => 'max_width',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'p' => $this->l('Maximum width managed by this carrier. Set "0" or nothing, to ignore this field.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package deep:'),
|
||||
'name' => 'max_deep',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'p' => $this->l('Maximum deep managed by this carrier. Set "0" or nothing, to ignore this field.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package weigth:'),
|
||||
'name' => 'max_weight',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'p' => $this->l('Maximum weight managed by this carrier. Set "0" or nothing, to ignore this field.')
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'is_module'
|
||||
@@ -375,7 +415,7 @@ class AdminCarriersControllerCore extends AdminController
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'need_range'
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -30,25 +30,25 @@ class AdminOrdersControllerCore extends AdminController
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order';
|
||||
$this->className = 'Order';
|
||||
$this->lang = false;
|
||||
$this->className = 'Order';
|
||||
$this->lang = false;
|
||||
$this->edit = true;
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('view');
|
||||
|
||||
$this->deleted = false;
|
||||
$this->colorOnBackground = true;
|
||||
$this->requiredDatabase = false;
|
||||
$this->context = Context::getContext();
|
||||
$this->deleted = false;
|
||||
$this->colorOnBackground = true;
|
||||
$this->requiredDatabase = false;
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = '
|
||||
$this->_select = '
|
||||
a.id_order AS id_pdf,
|
||||
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
|
||||
osl.`name` AS `osname`,
|
||||
os.`color`,
|
||||
IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
|
||||
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
$this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)';
|
||||
@@ -62,6 +62,7 @@ class AdminOrdersControllerCore extends AdminController
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
|
||||
'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 65),
|
||||
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
|
||||
'customer' => array('title' => $this->l('Customer'), 'filter_key' => 'customer', 'tmpTableFilter' => true),
|
||||
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'type' => 'price', 'currency' => true),
|
||||
@@ -70,8 +71,8 @@ class AdminOrdersControllerCore extends AdminController
|
||||
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
|
||||
'id_pdf' => array('title' => $this->l('PDF'), 'width' => 35, 'align' => 'center', 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
|
||||
|
||||
$this->shopLinkType = 'shop';
|
||||
$this->shopShareDatas = Shop::SHARE_ORDER;
|
||||
$this->shopLinkType = 'shop';
|
||||
$this->shopShareDatas = Shop::SHARE_ORDER;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class AdminProductsController extends AdminController
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = a.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (a.`id_tax_rules_group` = tr.`id_tax_rules_group`
|
||||
AND tr.`id_country` = '.(int)$this->context->country->id.' AND tr.`id_state` = 0)
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)';
|
||||
LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)';
|
||||
$this->_filter = 'AND cp.`id_category` = '.(int)$this->_category->id;
|
||||
$this->_select = 'cl.name `name_category`, cp.`position`, i.`id_image`, (a.`price` * ((100 + (t.`rate`))/100)) AS price_final';
|
||||
|
||||
@@ -1195,6 +1195,7 @@ if (false)
|
||||
$this->copyFromPost($object, $this->table);
|
||||
if ($object->update())
|
||||
{
|
||||
$this->addCarriers();
|
||||
if ($id_reason = (int)Tools::getValue('id_mvt_reason') && Tools::getValue('mvt_quantity') > 0 && $id_reason > 0)
|
||||
{
|
||||
if (!$object->addStockMvt(Tools::getValue('mvt_quantity'), $id_reason, null, null, $this->context->employee->id))
|
||||
@@ -1258,6 +1259,7 @@ if (false)
|
||||
$this->copyFromPost($object, $this->table);
|
||||
if ($object->add())
|
||||
{
|
||||
$this->addCarriers();
|
||||
$this->updateAssoShop((int)$object->id);
|
||||
$this->updateAccessories($object);
|
||||
if (!$this->updatePackItems($object))
|
||||
@@ -1305,19 +1307,30 @@ if (false)
|
||||
$this->_errors[] = Tools::displayError('An error occurred while creating object.').' <b>'.$this->table.'</b>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function addCarriers()
|
||||
{
|
||||
if (Tools::getValue('carriers'))
|
||||
{
|
||||
if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product')))))
|
||||
{
|
||||
if (Tools::getValue('carriers'))
|
||||
$product->setCarriers(Tools::getValue('carriers'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _removeTaxFromEcotax()
|
||||
{
|
||||
$ecotaxTaxRate = Tax::getProductEcotaxRate();
|
||||
$ecotaxTaxRate = Tax::getProductEcotaxRate();
|
||||
if ($ecotax = Tools::getValue('ecotax'))
|
||||
$_POST['ecotax'] = Tools::ps_round(Tools::getValue('ecotax') / (1 + $ecotaxTaxRate / 100), 6);
|
||||
}
|
||||
|
||||
private function _applyTaxToEcotax($product)
|
||||
{
|
||||
$ecotaxTaxRate = Tax::getProductEcotaxRate();
|
||||
$ecotaxTaxRate = Tax::getProductEcotaxRate();
|
||||
if ($product->ecotax)
|
||||
$product->ecotax = Tools::ps_round($product->ecotax * (1 + $ecotaxTaxRate / 100), 2);
|
||||
}
|
||||
@@ -2353,6 +2366,8 @@ if (false)
|
||||
$cache_default_attribute = (int) $this->getFieldValue($product, 'cache_default_attribute');
|
||||
$data->assign('feature_shop_active', Shop::isFeatureActive());
|
||||
$data->assign('displayAssoShop', $this->displayAssoShop());
|
||||
$data->assign('carrier_list', $this->getCarrierList());
|
||||
|
||||
|
||||
$product_props = array();
|
||||
// global informations
|
||||
@@ -3199,6 +3214,23 @@ if (false)
|
||||
$data->assign('default_form_language', $this->default_form_language);
|
||||
$this->tpl_form_vars['custom_form'] = $this->context->smarty->createTemplate($this->tpl_form, $data)->fetch();
|
||||
}
|
||||
|
||||
protected function getCarrierList()
|
||||
{
|
||||
$carrier_list = Carrier::getCarriers($this->context->language->id);
|
||||
if ($product = $this->loadObject(true))
|
||||
{
|
||||
$carrier_selected_list = $product->getCarriers();
|
||||
foreach ($carrier_list as &$carrier)
|
||||
foreach ($carrier_selected_list as $carrier_selected)
|
||||
if ($carrier_selected['id_reference'] == $carrier['id_reference'])
|
||||
{
|
||||
$carrier['selected'] = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return $carrier_list;
|
||||
}
|
||||
|
||||
public function ajaxProcessProductQuantity()
|
||||
{
|
||||
|
||||
@@ -246,7 +246,6 @@ class AddressControllerCore extends FrontController
|
||||
}
|
||||
else
|
||||
Tools::redirect('index.php?controller=addresses');
|
||||
Tools::redirect($mod ? $back.'&back='.$mod : $back);
|
||||
}
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating your address.');
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class CartControllerCore extends FrontController
|
||||
|
||||
protected $id_product;
|
||||
protected $id_product_attribute;
|
||||
protected $id_address_delivery;
|
||||
protected $customization_id;
|
||||
protected $qty;
|
||||
|
||||
@@ -54,6 +55,7 @@ class CartControllerCore extends FrontController
|
||||
$this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
|
||||
$this->customization_id = (int)Tools::getValue('id_customization');
|
||||
$this->qty = abs(Tools::getValue('qty', 1));
|
||||
$this->id_address_delivery = (int)Tools::getValue('id_address_delivery');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
@@ -68,6 +70,10 @@ class CartControllerCore extends FrontController
|
||||
$this->processChangeProductInCart();
|
||||
else if (Tools::getIsset('delete'))
|
||||
$this->processDeleteProductInCart();
|
||||
else if(Tools::getIsset('changeAddressDelivery'))
|
||||
$this->processChangeProductAddressDelivery();
|
||||
else if(Tools::getIsset('duplicate'))
|
||||
$this->processDuplicateProduct();
|
||||
|
||||
// Make redirection
|
||||
if (!$this->errors && !$this->ajax)
|
||||
@@ -94,7 +100,8 @@ class CartControllerCore extends FrontController
|
||||
*/
|
||||
protected function processDeleteProductInCart()
|
||||
{
|
||||
if ($this->context->cart->deleteProduct($this->id_product, $this->id_product_attribute, $this->customization_id))
|
||||
if ($this->context->cart->deleteProduct($this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery))
|
||||
{
|
||||
if (!Cart::getNbProducts((int)($this->context->cart->id)))
|
||||
{
|
||||
$this->context->cart->id_carrier = 0;
|
||||
@@ -102,8 +109,40 @@ class CartControllerCore extends FrontController
|
||||
$this->context->cart->gift_message = '';
|
||||
$this->context->cart->update();
|
||||
}
|
||||
}
|
||||
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 (
|
||||
!$this->context->cart->duplicateProduct(
|
||||
$this->id_product,
|
||||
$this->id_product_attribute,
|
||||
$this->id_address_delivery,
|
||||
(int)Tools::getValue('new_id_address_delivery'),
|
||||
1,
|
||||
true
|
||||
)
|
||||
)
|
||||
{
|
||||
//$error_message = $this->l('Error durring product duplication');
|
||||
// For the moment no translations
|
||||
$error_message = 'Error durring product duplication';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This process add or update a product in the cart
|
||||
@@ -160,7 +199,7 @@ class CartControllerCore extends FrontController
|
||||
|
||||
if (!$this->errors)
|
||||
{
|
||||
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'));
|
||||
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery, Tools::getValue('op', 'up'));
|
||||
if ($updateQuantity < 0)
|
||||
{
|
||||
// If product has attribute, minimal quantity is set with minimal quantity of attribute
|
||||
|
||||
@@ -64,6 +64,16 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,11 +94,17 @@ 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();
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
|
||||
if (Tools::getValue('multi-shipping') == 1)
|
||||
{
|
||||
$this->_assignSummaryInformations();
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address-multishipping.tpl');
|
||||
}
|
||||
else
|
||||
$this->setTemplate(_PS_THEME_DIR_.'order-address.tpl');
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -183,6 +199,11 @@ class OrderControllerCore extends ParentOrderController
|
||||
*/
|
||||
public function processAddress()
|
||||
{
|
||||
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
|
||||
@@ -213,7 +234,6 @@ class OrderControllerCore extends ParentOrderController
|
||||
protected function processCarrier()
|
||||
{
|
||||
global $orderTotal;
|
||||
|
||||
parent::_processCarrier();
|
||||
|
||||
if (count($this->errors))
|
||||
@@ -227,7 +247,7 @@ class OrderControllerCore extends ParentOrderController
|
||||
}
|
||||
$orderTotal = $this->context->cart->getOrderTotal();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Address step
|
||||
*/
|
||||
@@ -235,6 +255,9 @@ class OrderControllerCore extends ParentOrderController
|
||||
{
|
||||
parent::_assignAddress();
|
||||
|
||||
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');
|
||||
|
||||
@@ -217,10 +217,8 @@ class ParentOrderControllerCore extends FrontController
|
||||
else
|
||||
$id_zone = Country::getIdZone((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
if (Validate::isInt(Tools::getValue('id_carrier')) && count(Carrier::checkCarrierZone((int)(Tools::getValue('id_carrier')), (int)($id_zone))))
|
||||
$this->context->cart->id_carrier = (int)(Tools::getValue('id_carrier'));
|
||||
else if (!$this->context->cart->isVirtualCart() && (int)(Tools::getValue('id_carrier')) == 0)
|
||||
$this->errors[] = Tools::displayError('Invalid carrier or no carrier selected');
|
||||
if (Tools::getIsset('delivery_option') && $this->validateDeliveryOption(Tools::getValue('delivery_option')))
|
||||
$this->context->cart->delivery_option = serialize(Tools::getValue('delivery_option'));
|
||||
|
||||
Hook::exec('processCarrier', array('cart' => $this->context->cart));
|
||||
|
||||
@@ -230,6 +228,22 @@ class ParentOrderControllerCore extends FrontController
|
||||
// Carrier has changed, so we check if the cart rules still apply
|
||||
CartRule::autoRemoveFromCart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate get/post param delivery option
|
||||
* @param array $delivery_option
|
||||
*/
|
||||
protected function validateDeliveryOption($delivery_option)
|
||||
{
|
||||
if (!is_array($delivery_option))
|
||||
return false;
|
||||
|
||||
foreach ($delivery_option as $option)
|
||||
if (!preg_match('/(\d+,)?\d+/', $option))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _assignSummaryInformations()
|
||||
{
|
||||
@@ -364,10 +378,14 @@ class ParentOrderControllerCore extends FrontController
|
||||
$address = new Address($this->context->cart->id_address_delivery);
|
||||
$id_zone = Address::getZoneById($address->id);
|
||||
$carriers = Carrier::getCarriersForOrder($id_zone, $this->context->customer->getGroups());
|
||||
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'checked' => $this->setDefaultCarrierSelection($carriers),
|
||||
'carriers' => $carriers,
|
||||
'address_collection' => $this->context->cart->getAddressCollection(),
|
||||
'delivery_option_list' => $this->context->cart->getDeliveryOptionList(),
|
||||
'delivery_option' => $this->context->cart->getDeliveryOption(),
|
||||
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT'))
|
||||
));
|
||||
$this->context->smarty->assign(array(
|
||||
|
||||
Reference in New Issue
Block a user