Detect if is a full refund
This commit is contained in:
parent
8c24fe9fc6
commit
7163d60447
@ -463,7 +463,7 @@ class AdminOrders extends AdminTab
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Change order state, add a new entry in order history and send an e-mail to the customer if needed */
|
||||
// Change order state, add a new entry in order history and send an e-mail to the customer if needed
|
||||
elseif (Tools::isSubmit('submitState') AND ($id_order = (int)(Tools::getValue('id_order'))) AND Validate::isLoadedObject($order = new Order($id_order)))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
@ -506,7 +506,7 @@ class AdminOrders extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
/* Add a new message for the current order and send an e-mail to the customer if needed */
|
||||
// Add a new message for the current order and send an e-mail to the customer if needed
|
||||
elseif (isset($_POST['submitMessage']))
|
||||
{
|
||||
$_GET['view'.$this->table] = true;
|
||||
@ -709,7 +709,7 @@ class AdminOrders extends AdminTab
|
||||
$params['{firstname}'] = $customer->firstname;
|
||||
$params['{id_order}'] = $order->id;
|
||||
|
||||
/* PRODUIT REMBOURSE */
|
||||
// Refund products
|
||||
$products_refund = "";
|
||||
$total_refund = 0;
|
||||
foreach ($productList as $key => $id_order_detail) {
|
||||
@ -717,12 +717,12 @@ class AdminOrders extends AdminTab
|
||||
$tprice = $details_refund->product_price * (1 - $details_refund->reduction_percent / 100) - $details_refund->reduction_amount;
|
||||
$tprice = $tprice * ( 1 + $details_refund->tax_rate / 100 );
|
||||
$products_refund .= "
|
||||
<tr>
|
||||
<td>". $details_refund->product_name . "</td>
|
||||
<td style='text-align:right;'>" . Tools::displayPrice($tprice) . " </td>
|
||||
<td style='text-align:right;'>". (int)$full_quantity_list[$id_order_detail] ."</td>
|
||||
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (int)$full_quantity_list[$id_order_detail])) . "</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>". $details_refund->product_name . "</td>
|
||||
<td style='text-align:right;'>" . Tools::displayPrice($tprice) . " </td>
|
||||
<td style='text-align:right;'>". (int)$full_quantity_list[$id_order_detail] ."</td>
|
||||
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (int)$full_quantity_list[$id_order_detail])) . "</td>
|
||||
</tr>
|
||||
";
|
||||
$total_refund = $total_refund + ($tprice * (int)$full_quantity_list[$id_order_detail]);
|
||||
}
|
||||
@ -734,16 +734,14 @@ class AdminOrders extends AdminTab
|
||||
if (isset($_POST['shippingBack'])) {
|
||||
$order = new Order($details_refund->id_order);
|
||||
$fraisport .= "
|
||||
<tr style='text-align:right;'>
|
||||
<td colspan='3' style='background-color:#e2e2e1; padding:0.6em 0.4em;'>Frais de port</td>
|
||||
<td style='background-color:#e2e2e1; padding:0.6em 0.4em;'>" . Tools::displayPrice($order->total_shipping) . "</td>
|
||||
</tr>
|
||||
<tr style='text-align:right;'>
|
||||
<td colspan='3' style='background-color:#e2e2e1; padding:0.6em 0.4em;'>Frais de port</td>
|
||||
<td style='background-color:#e2e2e1; padding:0.6em 0.4em;'>" . Tools::displayPrice($order->total_shipping) . "</td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
// Remboursement frais de port
|
||||
Module::hookExec('cancelShipping', array('order' => $order));
|
||||
}
|
||||
|
||||
$params['{fraisport}'] = $fraisport;
|
||||
}
|
||||
|
||||
@ -754,13 +752,6 @@ class AdminOrders extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
||||
}
|
||||
else {
|
||||
// $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
// $params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||
// $params['{voucher_num}'] = $voucher->name;
|
||||
// @Mail::Send((int)($order->id_lang), 'voucher', Mail::l('New voucher regarding your order'),
|
||||
// $params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
|
||||
// NULL, _PS_MAIL_DIR_, true);
|
||||
|
||||
// Modif ANTADIS
|
||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||
@ -807,6 +798,40 @@ class AdminOrders extends AdminTab
|
||||
_PS_MAIL_DIR_, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Auto refund state
|
||||
if ($order->getCurrentState() != (int)Configuration::get('PS_OS_REFUND')) {
|
||||
$refundIsFull = false;
|
||||
$orderSlip = OrderSlip::getOrdersSlip($order->id_customer, $order->id);
|
||||
if (count($orderSlip) > 0) {
|
||||
if ($orderSlip['shipping_cost'] == 1) {
|
||||
$orderSlipDetail = OrderSlip::getOrdersSlipDetail($orderSlip['id_order_slip']);
|
||||
if (count($orderSlipDetail) > 0) {
|
||||
foreach ($orderSlipDetail as $k => $v) {
|
||||
$refundDetail[$v['id_order_detail']] = $v;
|
||||
}
|
||||
$orderProducts = $order->getProductsDetail();
|
||||
// Check line
|
||||
$refundIsFull = false;
|
||||
if (count($orderProducts) == count($orderSlipDetail)) {
|
||||
$refundIsFull = true;
|
||||
foreach($orderProducts as $k => $line) {
|
||||
if ($line['product_quantity'] != $orderSlipDetail[$line['id_order_detail']]['product_quantity']) {
|
||||
$refundIsFull = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Change order state
|
||||
if ($refundIsFull === true) {
|
||||
$history = new OrderHistory();
|
||||
$history->id_order = (int)$order->id;
|
||||
$history->changeIdOrderState((int)Configuration::get('PS_OS_REFUND'), (int)($order->id));
|
||||
}
|
||||
}
|
||||
|
||||
// Update order state if it's partial
|
||||
if ($order->getCurrentState() == 17) {
|
||||
@ -821,7 +846,8 @@ class AdminOrders extends AdminTab
|
||||
|
||||
if (count($to_send) == 0) {
|
||||
$partial = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
|
||||
$quantities_sent = array();
|
||||
|
||||
@ -932,10 +958,14 @@ class AdminOrders extends AdminTab
|
||||
`date_upd` = NOW()
|
||||
');
|
||||
$newOS = new OrderState((int)(Configuration::get('PS_OS_SHIPPING')), $order->id_lang);
|
||||
Module::hookExec('updateOrderStatus', array('newOrderStatus' => $newOS, 'id_order' => (int)($order->id)));
|
||||
Module::hookExec('updateOrderStatus', array(
|
||||
'newOrderStatus' => $newOS,
|
||||
'id_order' => (int)$order->id
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$this->_errors[] = Tools::displayError('No product or quantity selected.');
|
||||
|
@ -120,15 +120,25 @@ class PayPal extends PaymentModule
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn') ||
|
||||
!$this->registerHook('shoppingCartExtra') || !$this->registerHook('backBeforePayment') || !$this->registerHook('rightColumn') ||
|
||||
!$this->registerHook('cancelProduct') || !$this->registerHook('productFooter') || !$this->registerHook('header') ||
|
||||
!$this->registerHook('adminOrder') || !$this->registerHook('backOfficeHeader'))
|
||||
return false;
|
||||
if (!parent::install()
|
||||
|| !$this->registerHook('payment')
|
||||
|| !$this->registerHook('paymentReturn')
|
||||
|| !$this->registerHook('shoppingCartExtra')
|
||||
|| !$this->registerHook('backBeforePayment')
|
||||
|| !$this->registerHook('rightColumn')
|
||||
|| !$this->registerHook('cancelProduct')
|
||||
|| !$this->registerHook('productFooter')
|
||||
|| !$this->registerHook('header')
|
||||
|| !$this->registerHook('adminOrder')
|
||||
|| !$this->registerHook('backOfficeHeader')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((_PS_VERSION_ >= '1.5') && (!$this->registerHook('displayMobileHeader') ||
|
||||
!$this->registerHook('displayMobileShoppingCartTop') || !$this->registerHook('displayMobileAddToCartTop')))
|
||||
return false;
|
||||
if ((_PS_VERSION_ >= '1.5') && (!$this->registerHook('displayMobileHeader')
|
||||
|| !$this->registerHook('displayMobileShoppingCartTop')
|
||||
|| !$this->registerHook('displayMobileAddToCartTop'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
include_once(_PS_MODULE_DIR_.'/'.$this->name.'/paypal_install.php');
|
||||
$paypal_install = new PayPalInstall();
|
||||
@ -733,9 +743,9 @@ class PayPal extends PaymentModule
|
||||
mail('karen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
||||
mail('doreen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
||||
mail('contact@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
||||
$message .= $this->l('Transaction error because of the amount of the shipping cost!').'<br>';
|
||||
} else {
|
||||
$this->refundSave($order->id, 0, $amount, $cookie->id_employee);
|
||||
$message .= $this->l('Transaction error because of the amount of the shipping cost!').'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user