// Normalize
This commit is contained in:
+47
-47
@@ -238,7 +238,7 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
protected static $_historyCache = array();
|
protected static $_historyCache = array();
|
||||||
|
|
||||||
public function __construct($id = NULL, $id_lang = NULL)
|
public function __construct($id = null, $id_lang = null)
|
||||||
{
|
{
|
||||||
parent::__construct($id, $id_lang);
|
parent::__construct($id, $id_lang);
|
||||||
if ($this->id_customer)
|
if ($this->id_customer)
|
||||||
@@ -334,7 +334,7 @@ class OrderCore extends ObjectModel
|
|||||||
$reduction_amount = $price * $orderDetail->reduction_percent / 100;
|
$reduction_amount = $price * $orderDetail->reduction_percent / 100;
|
||||||
elseif ($orderDetail->reduction_amount != '0.000000')
|
elseif ($orderDetail->reduction_amount != '0.000000')
|
||||||
$reduction_amount = Tools::ps_round($orderDetail->reduction_amount, 2);
|
$reduction_amount = Tools::ps_round($orderDetail->reduction_amount, 2);
|
||||||
if (isset($reduction_amount) AND $reduction_amount)
|
if (isset($reduction_amount) && $reduction_amount)
|
||||||
$price = Tools::ps_round($price - $reduction_amount, 2);
|
$price = Tools::ps_round($price - $reduction_amount, 2);
|
||||||
$productPriceWithoutTax = number_format($tax_calculator->removeTaxes($price), 2, '.', '');
|
$productPriceWithoutTax = number_format($tax_calculator->removeTaxes($price), 2, '.', '');
|
||||||
$price += Tools::ps_round($orderDetail->ecotax * (1 + $orderDetail->ecotax_tax_rate / 100), 2);
|
$price += Tools::ps_round($orderDetail->ecotax * (1 + $orderDetail->ecotax_tax_rate / 100), 2);
|
||||||
@@ -398,7 +398,7 @@ class OrderCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
return $this->update();
|
return $this->update();
|
||||||
}
|
}
|
||||||
return $orderDetail->update() AND $this->update();
|
return $orderDetail->update() && $this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteCustomization($id_customization, $quantity, $orderDetail)
|
public function deleteCustomization($id_customization, $quantity, $orderDetail)
|
||||||
@@ -429,7 +429,7 @@ class OrderCore extends ObjectModel
|
|||||||
if (!$id_order_state)
|
if (!$id_order_state)
|
||||||
$id_order_state = 0;
|
$id_order_state = 0;
|
||||||
|
|
||||||
if (!isset(self::$_historyCache[$this->id.'_'.$id_order_state]) OR $no_hidden)
|
if (!isset(self::$_historyCache[$this->id.'_'.$id_order_state]) || $no_hidden)
|
||||||
{
|
{
|
||||||
$id_lang = $id_lang ? (int)($id_lang) : 'o.`id_lang`';
|
$id_lang = $id_lang ? (int)($id_lang) : 'o.`id_lang`';
|
||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
@@ -488,7 +488,7 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
$group_reduction = 1;
|
$group_reduction = 1;
|
||||||
if ($row['group_reduction'] > 0)
|
if ($row['group_reduction'] > 0)
|
||||||
$group_reduction = 1 - $row['group_reduction'] / 100;
|
$group_reduction = 1 - $row['group_reduction'] / 100;
|
||||||
|
|
||||||
$row['product_price_wt_but_ecotax'] = $row['product_price_wt'] - $row['ecotax'];
|
$row['product_price_wt_but_ecotax'] = $row['product_price_wt'] - $row['ecotax'];
|
||||||
|
|
||||||
@@ -510,17 +510,17 @@ class OrderCore extends ObjectModel
|
|||||||
$customized_datas = Product::getAllCustomizedDatas($this->id_cart);
|
$customized_datas = Product::getAllCustomizedDatas($this->id_cart);
|
||||||
|
|
||||||
$resultArray = array();
|
$resultArray = array();
|
||||||
foreach ($products AS $row)
|
foreach ($products as $row)
|
||||||
{
|
{
|
||||||
// Change qty if selected
|
// Change qty if selected
|
||||||
if ($selectedQty)
|
if ($selectedQty)
|
||||||
{
|
{
|
||||||
$row['product_quantity'] = 0;
|
$row['product_quantity'] = 0;
|
||||||
foreach ($selectedProducts AS $key => $id_product)
|
foreach ($selectedProducts as $key => $id_product)
|
||||||
if ($row['id_order_detail'] == $id_product)
|
if ($row['id_order_detail'] == $id_product)
|
||||||
$row['producsvt_quantity'] = (int)($selectedQty[$key]);
|
$row['producsvt_quantity'] = (int)($selectedQty[$key]);
|
||||||
if (!$row['product_quantity'])
|
if (!$row['product_quantity'])
|
||||||
continue ;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setProductImageInformations($row);
|
$this->setProductImageInformations($row);
|
||||||
@@ -652,10 +652,10 @@ class OrderCore extends ObjectModel
|
|||||||
if (count($products) < 1)
|
if (count($products) < 1)
|
||||||
return false;
|
return false;
|
||||||
$virtual = true;
|
$virtual = true;
|
||||||
foreach ($products AS $product)
|
foreach ($products as $product)
|
||||||
{
|
{
|
||||||
$pd = ProductDownload::getIdFromIdProduct((int)($product['product_id']));
|
$pd = ProductDownload::getIdFromIdProduct((int)($product['product_id']));
|
||||||
if ($pd AND Validate::isUnsignedInt($pd) AND $product['download_hash'] AND $product['display_filename'] != '')
|
if ($pd && Validate::isUnsignedInt($pd) && $product['download_hash'] && $product['display_filename'] != '')
|
||||||
{
|
{
|
||||||
if ($strict === false)
|
if ($strict === false)
|
||||||
return true;
|
return true;
|
||||||
@@ -701,7 +701,7 @@ class OrderCore extends ObjectModel
|
|||||||
public function getCurrentState()
|
public function getCurrentState()
|
||||||
{
|
{
|
||||||
$orderHistory = OrderHistory::getLastOrderState($this->id);
|
$orderHistory = OrderHistory::getLastOrderState($this->id);
|
||||||
if (!isset($orderHistory) OR !$orderHistory)
|
if (!isset($orderHistory) || !$orderHistory)
|
||||||
return false;
|
return false;
|
||||||
return $orderHistory->id;
|
return $orderHistory->id;
|
||||||
}
|
}
|
||||||
@@ -714,32 +714,33 @@ class OrderCore extends ObjectModel
|
|||||||
public function getCurrentStateFull($id_lang)
|
public function getCurrentStateFull($id_lang)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->getRow('
|
return Db::getInstance()->getRow('
|
||||||
SELECT oh.`id_order_state`, osl.`name`, os.`logable`, os.`shipped`
|
SELECT oh.`id_order_state`, osl.`name`, os.`logable`, os.`shipped`
|
||||||
FROM `'._DB_PREFIX_.'order_history` oh
|
FROM `'._DB_PREFIX_.'order_history` oh
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (osl.`id_order_state` = oh.`id_order_state`)
|
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (osl.`id_order_state` = oh.`id_order_state`)
|
||||||
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
|
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`)
|
||||||
WHERE osl.`id_lang` = '.(int)($id_lang).' AND oh.`id_order` = '.(int)($this->id).'
|
WHERE osl.`id_lang` = '.(int)($id_lang).' AND oh.`id_order` = '.(int)($this->id).'
|
||||||
ORDER BY `date_add` DESC, `id_order_history` DESC');
|
ORDER BY `date_add` DESC, `id_order_history` DESC
|
||||||
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasBeenDelivered()
|
public function hasBeenDelivered()
|
||||||
{
|
{
|
||||||
return sizeof($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_DELIVERED')));
|
return count($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_DELIVERED')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasBeenPaid()
|
public function hasBeenPaid()
|
||||||
{
|
{
|
||||||
return sizeof($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PAYMENT')));
|
return count($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PAYMENT')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasBeenShipped()
|
public function hasBeenShipped()
|
||||||
{
|
{
|
||||||
return sizeof($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_SHIPPING')));
|
return count($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_SHIPPING')));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isInPreparation()
|
public function isInPreparation()
|
||||||
{
|
{
|
||||||
return sizeof($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PREPARATION')));
|
return count($this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PREPARATION')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -749,7 +750,7 @@ class OrderCore extends ObjectModel
|
|||||||
* @param boolean $showHiddenStatus Display or not hidden order statuses
|
* @param boolean $showHiddenStatus Display or not hidden order statuses
|
||||||
* @return array Customer orders
|
* @return array Customer orders
|
||||||
*/
|
*/
|
||||||
static public function getCustomerOrders($id_customer, $showHiddenStatus = false, Context $context = null)
|
public static function getCustomerOrders($id_customer, $showHiddenStatus = false, Context $context = null)
|
||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
@@ -763,7 +764,7 @@ class OrderCore extends ObjectModel
|
|||||||
if (!$res)
|
if (!$res)
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
foreach ($res AS $key => $val)
|
foreach ($res as $key => $val)
|
||||||
{
|
{
|
||||||
$res2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$res2 = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT os.`id_order_state`, osl.`name` AS order_state, os.`invoice`
|
SELECT os.`id_order_state`, osl.`name` AS order_state, os.`invoice`
|
||||||
@@ -781,7 +782,7 @@ class OrderCore extends ObjectModel
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOrdersIdByDate($date_from, $date_to, $id_customer = NULL, $type = NULL)
|
public static function getOrdersIdByDate($date_from, $date_to, $id_customer = null, $type = null)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT `id_order`
|
$sql = 'SELECT `id_order`
|
||||||
FROM `'._DB_PREFIX_.'orders`
|
FROM `'._DB_PREFIX_.'orders`
|
||||||
@@ -792,12 +793,12 @@ class OrderCore extends ObjectModel
|
|||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
|
|
||||||
$orders = array();
|
$orders = array();
|
||||||
foreach ($result AS $order)
|
foreach ($result as $order)
|
||||||
$orders[] = (int)($order['id_order']);
|
$orders[] = (int)($order['id_order']);
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getOrdersWithInformations($limit = NULL, Context $context = null)
|
public static function getOrdersWithInformations($limit = null, Context $context = null)
|
||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
@@ -831,7 +832,7 @@ class OrderCore extends ObjectModel
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getOrdersIdInvoiceByDate($date_from, $date_to, $id_customer = NULL, $type = NULL)
|
public static function getOrdersIdInvoiceByDate($date_from, $date_to, $id_customer = null, $type = null)
|
||||||
{
|
{
|
||||||
Tools::displayAsDeprecated();
|
Tools::displayAsDeprecated();
|
||||||
$sql = 'SELECT `id_order`
|
$sql = 'SELECT `id_order`
|
||||||
@@ -844,8 +845,8 @@ class OrderCore extends ObjectModel
|
|||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
|
|
||||||
$orders = array();
|
$orders = array();
|
||||||
foreach ($result AS $order)
|
foreach ($result as $order)
|
||||||
$orders[] = (int)($order['id_order']);
|
$orders[] = (int)$order['id_order'];
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,7 +874,7 @@ class OrderCore extends ObjectModel
|
|||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||||
|
|
||||||
$orders = array();
|
$orders = array();
|
||||||
foreach ($result AS $order)
|
foreach ($result as $order)
|
||||||
$orders[] = (int)($order['id_order']);
|
$orders[] = (int)($order['id_order']);
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
@@ -895,7 +896,7 @@ class OrderCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public function getTotalProductsWithTaxes($products = false)
|
public function getTotalProductsWithTaxes($products = false)
|
||||||
{
|
{
|
||||||
if ($this->total_products_wt != '0.00' AND !$products)
|
if ($this->total_products_wt != '0.00' && !$products)
|
||||||
return $this->total_products_wt;
|
return $this->total_products_wt;
|
||||||
/* Retro-compatibility (now set directly on the validateOrder() method) */
|
/* Retro-compatibility (now set directly on the validateOrder() method) */
|
||||||
|
|
||||||
@@ -904,7 +905,7 @@ class OrderCore extends ObjectModel
|
|||||||
|
|
||||||
$return = 0;
|
$return = 0;
|
||||||
|
|
||||||
foreach ($products AS $row)
|
foreach ($products as $row)
|
||||||
{
|
{
|
||||||
if (!isset($row['tax_rate']))
|
if (!isset($row['tax_rate']))
|
||||||
$row['tax_rate'] = 0;
|
$row['tax_rate'] = 0;
|
||||||
@@ -1013,10 +1014,10 @@ class OrderCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$payment = $this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PAYMENT'));
|
$payment = $this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_PAYMENT'));
|
||||||
$delivred = $this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_DELIVERED'));
|
$delivred = $this->getHistory((int)($this->id_lang), Configuration::get('PS_OS_DELIVERED'));
|
||||||
if ($payment AND $delivred AND strtotime($delivred[0]['date_add']) < strtotime($payment[0]['date_add']))
|
if ($payment && $delivred && strtotime($delivred[0]['date_add']) < strtotime($payment[0]['date_add']))
|
||||||
return ((int)(Configuration::get('PS_ORDER_RETURN')) == 1 AND $this->getNumberOfDays());
|
return ((int)(Configuration::get('PS_ORDER_RETURN')) == 1 && $this->getNumberOfDays());
|
||||||
else
|
else
|
||||||
return ((int)(Configuration::get('PS_ORDER_RETURN')) == 1 AND (int)($this->getCurrentState()) == Configuration::get('PS_OS_DELIVERED') AND $this->getNumberOfDays());
|
return ((int)Configuration::get('PS_ORDER_RETURN') == 1 && (int)$this->getCurrentState() == Configuration::get('PS_OS_DELIVERED') && $this->getNumberOfDays());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getLastInvoiceNumber()
|
public static function getLastInvoiceNumber()
|
||||||
@@ -1096,7 +1097,7 @@ class OrderCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
// Get all invoice
|
// Get all invoice
|
||||||
$order_invoice_collection = $this->getInvoicesCollection();
|
$order_invoice_collection = $this->getInvoicesCollection();
|
||||||
foreach($order_invoice_collection as $order_invoice)
|
foreach ($order_invoice_collection as $order_invoice)
|
||||||
{
|
{
|
||||||
$number = (int)Configuration::get('PS_DELIVERY_NUMBER');
|
$number = (int)Configuration::get('PS_DELIVERY_NUMBER');
|
||||||
if (!$number)
|
if (!$number)
|
||||||
@@ -1124,17 +1125,17 @@ class OrderCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$order = new Order($id_order);
|
$order = new Order($id_order);
|
||||||
$orderState = OrderHistory::getLastOrderState($id_order);
|
$orderState = OrderHistory::getLastOrderState($id_order);
|
||||||
if (!Validate::isLoadedObject($orderState) OR !Validate::isLoadedObject($order))
|
if (!Validate::isLoadedObject($orderState) || !Validate::isLoadedObject($order))
|
||||||
die(Tools::displayError('Invalid objects'));
|
die(Tools::displayError('Invalid objects'));
|
||||||
echo '<span style="width:20px; margin-right:5px;">';
|
echo '<span style="width:20px; margin-right:5px;">';
|
||||||
if (($orderState->invoice AND $order->invoice_number) AND (int)($tr['product_number']))
|
if (($orderState->invoice && $order->invoice_number) && (int)($tr['product_number']))
|
||||||
echo '<a target="_blank" href="pdf.php?id_order='.(int)($order->id).'&pdf"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>';
|
echo '<a target="_blank" href="pdf.php?id_order='.(int)$order->id.'&pdf"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>';
|
||||||
else
|
else
|
||||||
echo ' ';
|
echo ' ';
|
||||||
echo '</span>';
|
echo '</span>';
|
||||||
echo '<span style="width:20px;">';
|
echo '<span style="width:20px;">';
|
||||||
if ($orderState->delivery AND $order->delivery_number)
|
if ($orderState->delivery && $order->delivery_number)
|
||||||
echo '<a target="_blank" href="pdf.php?id_delivery='.(int)($order->delivery_number).'"><img src="../img/admin/delivery.gif" alt="delivery" /></a>';
|
echo '<a target="_blank" href="pdf.php?id_delivery='.(int)$order->delivery_number.'"><img src="../img/admin/delivery.gif" alt="delivery" /></a>';
|
||||||
else
|
else
|
||||||
echo ' ';
|
echo ' ';
|
||||||
echo '</span>';
|
echo '</span>';
|
||||||
@@ -1238,7 +1239,7 @@ class OrderCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$paymentModule = Module::getInstanceByName($this->module);
|
$paymentModule = Module::getInstanceByName($this->module);
|
||||||
$customer = new Customer($this->id_customer);
|
$customer = new Customer($this->id_customer);
|
||||||
$paymentModule->validateOrder($this->id_cart, Configuration::get('PS_OS_WS_PAYMENT'), $this->total_paid, $this->payment, NULL, array(), null, false, $customer->secure_key);
|
$paymentModule->validateOrder($this->id_cart, Configuration::get('PS_OS_WS_PAYMENT'), $this->total_paid, $this->payment, null, array(), null, false, $customer->secure_key);
|
||||||
$this->id = $paymentModule->currentOrder;
|
$this->id = $paymentModule->currentOrder;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1386,7 +1387,7 @@ class OrderCore extends ObjectModel
|
|||||||
$invoices = $this->getInvoicesCollection()->getResults();
|
$invoices = $this->getInvoicesCollection()->getResults();
|
||||||
$delivery_slips = $this->getDeliverySlipsCollection()->getResults();
|
$delivery_slips = $this->getDeliverySlipsCollection()->getResults();
|
||||||
// @TODO review
|
// @TODO review
|
||||||
foreach($delivery_slips as $delivery)
|
foreach ($delivery_slips as $delivery)
|
||||||
{
|
{
|
||||||
$delivery->is_delivery = true;
|
$delivery->is_delivery = true;
|
||||||
$delivery->date_add = $delivery->delivery_date;
|
$delivery->date_add = $delivery->delivery_date;
|
||||||
@@ -1402,7 +1403,7 @@ class OrderCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
$documents = array_merge($invoices, $order_slips, $delivery_slips);
|
$documents = array_merge($invoices, $order_slips, $delivery_slips);
|
||||||
usort($documents, "sortDocuments");
|
usort($documents, 'sortDocuments');
|
||||||
|
|
||||||
return $documents;
|
return $documents;
|
||||||
}
|
}
|
||||||
@@ -1501,7 +1502,7 @@ class OrderCore extends ObjectModel
|
|||||||
$total = 0;
|
$total = 0;
|
||||||
// Retrieve all payments
|
// Retrieve all payments
|
||||||
$payments = $this->getOrderPaymentCollection();
|
$payments = $this->getOrderPaymentCollection();
|
||||||
foreach($payments as $payment)
|
foreach ($payments as $payment)
|
||||||
{
|
{
|
||||||
if ($payment->id_currency == $currency->id)
|
if ($payment->id_currency == $currency->id)
|
||||||
$total += $payment->amount;
|
$total += $payment->amount;
|
||||||
@@ -1675,8 +1676,7 @@ class OrderCore extends ObjectModel
|
|||||||
if (Db::getInstance()->getRow('
|
if (Db::getInstance()->getRow('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'order_invoice`
|
FROM `'._DB_PREFIX_.'order_invoice`
|
||||||
WHERE `id_order` = '.(int)$this->id)
|
WHERE `id_order` = '.(int)$this->id))
|
||||||
)
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -402,17 +402,19 @@ class OrderDetailCore extends ObjectModel
|
|||||||
$this->reduction_percent = 0.00;
|
$this->reduction_percent = 0.00;
|
||||||
|
|
||||||
if ($this->specificPrice)
|
if ($this->specificPrice)
|
||||||
switch($this->specificPrice['reduction_type'])
|
switch ($this->specificPrice['reduction_type'])
|
||||||
{
|
{
|
||||||
case 'percentage':
|
case 'percentage':
|
||||||
$this->reduction_percent = (float)$this->specificPrice['reduction'] * 100;
|
$this->reduction_percent = (float)$this->specificPrice['reduction'] * 100;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'amount':
|
case 'amount':
|
||||||
$price = Tools::convertPrice($this->specificPrice['reduction'], $order->id_currency);
|
$price = Tools::convertPrice($this->specificPrice['reduction'], $order->id_currency);
|
||||||
$this->reduction_amount = (float)(!$this->specificPrice['id_currency'] ?
|
$this->reduction_amount = (float)(!$this->specificPrice['id_currency'] ?
|
||||||
$price : $this->specificPrice['reduction']);
|
$price : $this->specificPrice['reduction']);
|
||||||
$this->reduction_amount_tax_incl = $this->reduction_amount;
|
$this->reduction_amount_tax_incl = $this->reduction_amount;
|
||||||
$this->reduction_amount_tax_excl = Tools::ps_round($this->tax_calculator->removeTaxes($this->reduction_amount_tax_incl), 2);
|
$this->reduction_amount_tax_excl = Tools::ps_round($this->tax_calculator->removeTaxes($this->reduction_amount_tax_incl), 2);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,8 +573,8 @@ class OrderDetailCore extends ObjectModel
|
|||||||
if (isset($carrier) && Validate::isLoadedObject($carrier))
|
if (isset($carrier) && Validate::isLoadedObject($carrier))
|
||||||
$tax_rate = $carrier->getTaxesRate(new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
$tax_rate = $carrier->getTaxesRate(new Address((int)$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
|
||||||
|
|
||||||
$this->total_shipping_price_tax_excl = (float) $product['additional_shipping_cost'];
|
$this->total_shipping_price_tax_excl = (float)$product['additional_shipping_cost'];
|
||||||
$this->total_shipping_price_tax_incl = (float) ($this->total_shipping_price_tax_excl * (1 + ($tax_rate / 100)));
|
$this->total_shipping_price_tax_incl = (float)($this->total_shipping_price_tax_excl * (1 + ($tax_rate / 100)));
|
||||||
$this->total_shipping_price_tax_incl = Tools::ps_round($this->total_shipping_price_tax_incl, 2);
|
$this->total_shipping_price_tax_incl = Tools::ps_round($this->total_shipping_price_tax_incl, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,17 +129,17 @@ class OrderInvoiceCore extends ObjectModel
|
|||||||
$customized_datas = Product::getAllCustomizedDatas($order->id_cart);
|
$customized_datas = Product::getAllCustomizedDatas($order->id_cart);
|
||||||
|
|
||||||
$resultArray = array();
|
$resultArray = array();
|
||||||
foreach ($products AS $row)
|
foreach ($products as $row)
|
||||||
{
|
{
|
||||||
// Change qty if selected
|
// Change qty if selected
|
||||||
if ($selectedQty)
|
if ($selectedQty)
|
||||||
{
|
{
|
||||||
$row['product_quantity'] = 0;
|
$row['product_quantity'] = 0;
|
||||||
foreach ($selectedProducts AS $key => $id_product)
|
foreach ($selectedProducts as $key => $id_product)
|
||||||
if ($row['id_order_detail'] == $id_product)
|
if ($row['id_order_detail'] == $id_product)
|
||||||
$row['product_quantity'] = (int)($selectedQty[$key]);
|
$row['product_quantity'] = (int)($selectedQty[$key]);
|
||||||
if (!$row['product_quantity'])
|
if (!$row['product_quantity'])
|
||||||
continue ;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setProductImageInformations($row);
|
$this->setProductImageInformations($row);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class OrderMessageCore extends ObjectModel
|
|||||||
'primary' => 'id_order_message',
|
'primary' => 'id_order_message',
|
||||||
'multilang' => true,
|
'multilang' => true,
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
||||||
|
|
||||||
// Lang fields
|
// Lang fields
|
||||||
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
|
||||||
@@ -52,7 +52,6 @@ class OrderMessageCore extends ObjectModel
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
protected $webserviceParameters = array(
|
protected $webserviceParameters = array(
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'id' => array('sqlId' => 'id_discount_type', 'xlink_resource' => 'order_message_lang'),
|
'id' => array('sqlId' => 'id_discount_type', 'xlink_resource' => 'order_message_lang'),
|
||||||
|
|||||||
@@ -28,25 +28,25 @@
|
|||||||
class OrderReturnCore extends ObjectModel
|
class OrderReturnCore extends ObjectModel
|
||||||
{
|
{
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $id;
|
public $id;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $id_customer;
|
public $id_customer;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $id_order;
|
public $id_order;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $state;
|
public $state;
|
||||||
|
|
||||||
/** @var string message content */
|
/** @var string message content */
|
||||||
public $question;
|
public $question;
|
||||||
|
|
||||||
/** @var string Object creation date */
|
/** @var string Object creation date */
|
||||||
public $date_add;
|
public $date_add;
|
||||||
|
|
||||||
/** @var string Object last modification date */
|
/** @var string Object last modification date */
|
||||||
public $date_upd;
|
public $date_upd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ObjectModel::$definition
|
* @see ObjectModel::$definition
|
||||||
@@ -87,7 +87,7 @@ class OrderReturnCore extends ObjectModel
|
|||||||
$products = $order->getProducts();
|
$products = $order->getProducts();
|
||||||
/* Products already returned */
|
/* Products already returned */
|
||||||
$order_return = OrderReturn::getOrdersReturn($order->id_customer, $order->id, true);
|
$order_return = OrderReturn::getOrdersReturn($order->id_customer, $order->id, true);
|
||||||
foreach ($order_return AS $or)
|
foreach ($order_return as $or)
|
||||||
{
|
{
|
||||||
$order_return_products = OrderReturn::getOrdersReturnProducts($or['id_order_return'], $order);
|
$order_return_products = OrderReturn::getOrdersReturnProducts($or['id_order_return'], $order);
|
||||||
foreach ($order_return_products AS $key => $orp)
|
foreach ($order_return_products AS $key => $orp)
|
||||||
@@ -95,7 +95,7 @@ class OrderReturnCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
/* Quantity check */
|
/* Quantity check */
|
||||||
if ($orderDetailList)
|
if ($orderDetailList)
|
||||||
foreach (array_keys($orderDetailList) AS $key)
|
foreach (array_keys($orderDetailList) as $key)
|
||||||
if ($qty = (int)($productQtyList[$key]))
|
if ($qty = (int)($productQtyList[$key]))
|
||||||
if ($products[$key]['product_quantity'] - $qty < 0)
|
if ($products[$key]['product_quantity'] - $qty < 0)
|
||||||
return false;
|
return false;
|
||||||
@@ -103,10 +103,10 @@ class OrderReturnCore extends ObjectModel
|
|||||||
if ($customizationIds)
|
if ($customizationIds)
|
||||||
{
|
{
|
||||||
$orderedCustomizations = Customization::getOrderedCustomizations((int)($order->id_cart));
|
$orderedCustomizations = Customization::getOrderedCustomizations((int)($order->id_cart));
|
||||||
foreach ($customizationIds AS $customizations)
|
foreach ($customizationIds as $customizations)
|
||||||
foreach ($customizations AS $customizationId)
|
foreach ($customizations as $customizationId)
|
||||||
{
|
{
|
||||||
$customizationId = (int)($customizationId);
|
$customizationId = (int)$customizationId;
|
||||||
if (!isset($orderedCustomizations[$customizationId]))
|
if (!isset($orderedCustomizations[$customizationId]))
|
||||||
return false;
|
return false;
|
||||||
$quantity = (isset($customizationQtyInput[$customizationId]) ? (int)($customizationQtyInput[$customizationId]) : 0);
|
$quantity = (isset($customizationQtyInput[$customizationId]) ? (int)($customizationQtyInput[$customizationId]) : 0);
|
||||||
@@ -127,7 +127,7 @@ class OrderReturnCore extends ObjectModel
|
|||||||
return (int)($data['total']);
|
return (int)($data['total']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getOrdersReturn($customer_id, $order_id = false, $no_denied = false, Context $context = null)
|
public static function getOrdersReturn($customer_id, $order_id = false, $no_denied = false, Context $context = null)
|
||||||
{
|
{
|
||||||
if (!$context)
|
if (!$context)
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
@@ -162,13 +162,13 @@ class OrderReturnCore extends ObjectModel
|
|||||||
$productsRet = OrderReturn::getOrdersReturnDetail($orderReturnId);
|
$productsRet = OrderReturn::getOrdersReturnDetail($orderReturnId);
|
||||||
$products = $order->getProducts();
|
$products = $order->getProducts();
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
foreach ($productsRet AS $return_detail)
|
foreach ($productsRet as $return_detail)
|
||||||
{
|
{
|
||||||
$tmp[$return_detail['id_order_detail']]['quantity'] = isset($tmp[$return_detail['id_order_detail']]['quantity']) ? $tmp[$return_detail['id_order_detail']]['quantity'] + (int)($return_detail['product_quantity']) : (int)($return_detail['product_quantity']);
|
$tmp[$return_detail['id_order_detail']]['quantity'] = isset($tmp[$return_detail['id_order_detail']]['quantity']) ? $tmp[$return_detail['id_order_detail']]['quantity'] + (int)($return_detail['product_quantity']) : (int)($return_detail['product_quantity']);
|
||||||
$tmp[$return_detail['id_order_detail']]['customizations'] = (int)($return_detail['id_customization']);
|
$tmp[$return_detail['id_order_detail']]['customizations'] = (int)($return_detail['id_customization']);
|
||||||
}
|
}
|
||||||
$resTab = array();
|
$resTab = array();
|
||||||
foreach ($products AS $key => $product)
|
foreach ($products as $key => $product)
|
||||||
if (isset($tmp[$product['id_order_detail']]))
|
if (isset($tmp[$product['id_order_detail']]))
|
||||||
{
|
{
|
||||||
$resTab[$key] = $product;
|
$resTab[$key] = $product;
|
||||||
@@ -185,7 +185,7 @@ class OrderReturnCore extends ObjectModel
|
|||||||
if (!Validate::isLoadedObject($order))
|
if (!Validate::isLoadedObject($order))
|
||||||
die(Tools::displayError());
|
die(Tools::displayError());
|
||||||
$products = $order->getProducts();
|
$products = $order->getProducts();
|
||||||
foreach ($returns AS &$return)
|
foreach ($returns as &$return)
|
||||||
{
|
{
|
||||||
$return['product_id'] = (int)($products[(int)($return['id_order_detail'])]['product_id']);
|
$return['product_id'] = (int)($products[(int)($return['id_order_detail'])]['product_id']);
|
||||||
$return['product_attribute_id'] = (int)($products[(int)($return['id_order_detail'])]['product_attribute_id']);
|
$return['product_attribute_id'] = (int)($products[(int)($return['id_order_detail'])]['product_attribute_id']);
|
||||||
|
|||||||
+15
-15
@@ -28,34 +28,34 @@
|
|||||||
class OrderSlipCore extends ObjectModel
|
class OrderSlipCore extends ObjectModel
|
||||||
{
|
{
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $id;
|
public $id;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $id_customer;
|
public $id_customer;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $id_order;
|
public $id_order;
|
||||||
|
|
||||||
/** @var float */
|
/** @var float */
|
||||||
public $conversion_rate;
|
public $conversion_rate;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $amount;
|
public $amount;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $shipping_cost;
|
public $shipping_cost;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $shipping_cost_amount;
|
public $shipping_cost_amount;
|
||||||
|
|
||||||
/** @var integer */
|
/** @var integer */
|
||||||
public $partial;
|
public $partial;
|
||||||
|
|
||||||
/** @var string Object creation date */
|
/** @var string Object creation date */
|
||||||
public $date_add;
|
public $date_add;
|
||||||
|
|
||||||
/** @var string Object last modification date */
|
/** @var string Object last modification date */
|
||||||
public $date_upd;
|
public $date_upd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ObjectModel::$definition
|
* @see ObjectModel::$definition
|
||||||
@@ -124,7 +124,7 @@ class OrderSlipCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$resTab[$key] = $product;
|
$resTab[$key] = $product;
|
||||||
$resTab[$key]['product_quantity'] = $tmp[$product['id_order_detail']];
|
$resTab[$key]['product_quantity'] = $tmp[$product['id_order_detail']];
|
||||||
if (sizeof($cart_rules))
|
if (count($cart_rules))
|
||||||
{
|
{
|
||||||
$order->setProductPrices($product);
|
$order->setProductPrices($product);
|
||||||
$realProductPrice = $resTab[$key]['product_price'];
|
$realProductPrice = $resTab[$key]['product_price'];
|
||||||
@@ -152,7 +152,7 @@ class OrderSlipCore extends ObjectModel
|
|||||||
|
|
||||||
$order = new Order($this->id_order);
|
$order = new Order($this->id_order);
|
||||||
$products = array();
|
$products = array();
|
||||||
foreach ($result AS $row)
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
$order->setProductPrices($row);
|
$order->setProductPrices($row);
|
||||||
$products[] = $row;
|
$products[] = $row;
|
||||||
@@ -169,7 +169,7 @@ class OrderSlipCore extends ObjectModel
|
|||||||
ORDER BY `date_add` ASC');
|
ORDER BY `date_add` ASC');
|
||||||
|
|
||||||
$slips = array();
|
$slips = array();
|
||||||
foreach ($result AS $slip)
|
foreach ($result as $slip)
|
||||||
$slips[] = (int)$slip['id_order_slip'];
|
$slips[] = (int)$slip['id_order_slip'];
|
||||||
return $slips;
|
return $slips;
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ class OrderSlipCore extends ObjectModel
|
|||||||
public static function createOrderSlip($order, $productList, $qtyList, $shipping_cost = false)
|
public static function createOrderSlip($order, $productList, $qtyList, $shipping_cost = false)
|
||||||
{
|
{
|
||||||
$currency = new Currency($order->id_currency);
|
$currency = new Currency($order->id_currency);
|
||||||
$orderSlip = new OrderSlip();
|
$orderSlip = new OrderSlip();
|
||||||
$orderSlip->id_customer = (int)($order->id_customer);
|
$orderSlip->id_customer = (int)($order->id_customer);
|
||||||
$orderSlip->id_order = (int)($order->id);
|
$orderSlip->id_order = (int)($order->id);
|
||||||
$orderSlip->shipping_cost = (int)($shipping_cost);
|
$orderSlip->shipping_cost = (int)($shipping_cost);
|
||||||
@@ -193,7 +193,7 @@ class OrderSlipCore extends ObjectModel
|
|||||||
public static function createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)
|
public static function createPartialOrderSlip($order, $amount, $shipping_cost_amount, $order_detail_list)
|
||||||
{
|
{
|
||||||
$currency = new Currency($order->id_currency);
|
$currency = new Currency($order->id_currency);
|
||||||
$orderSlip = new OrderSlip();
|
$orderSlip = new OrderSlip();
|
||||||
$orderSlip->id_customer = (int)($order->id_customer);
|
$orderSlip->id_customer = (int)($order->id_customer);
|
||||||
$orderSlip->id_order = (int)($order->id);
|
$orderSlip->id_order = (int)($order->id);
|
||||||
$orderSlip->amount = (float)($amount);
|
$orderSlip->amount = (float)($amount);
|
||||||
|
|||||||
Reference in New Issue
Block a user