Merge branch 'ticket/r15587-refund-paypal' into develop
This commit is contained in:
commit
3497ca7675
@ -463,7 +463,7 @@ class AdminOrders extends AdminTab
|
|||||||
exit;
|
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)))
|
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')
|
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.');
|
$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']))
|
elseif (isset($_POST['submitMessage']))
|
||||||
{
|
{
|
||||||
$_GET['view'.$this->table] = true;
|
$_GET['view'.$this->table] = true;
|
||||||
@ -709,7 +709,7 @@ class AdminOrders extends AdminTab
|
|||||||
$params['{firstname}'] = $customer->firstname;
|
$params['{firstname}'] = $customer->firstname;
|
||||||
$params['{id_order}'] = $order->id;
|
$params['{id_order}'] = $order->id;
|
||||||
|
|
||||||
/* PRODUIT REMBOURSE */
|
// Refund products
|
||||||
$products_refund = "";
|
$products_refund = "";
|
||||||
$total_refund = 0;
|
$total_refund = 0;
|
||||||
foreach ($productList as $key => $id_order_detail) {
|
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 = $details_refund->product_price * (1 - $details_refund->reduction_percent / 100) - $details_refund->reduction_amount;
|
||||||
$tprice = $tprice * ( 1 + $details_refund->tax_rate / 100 );
|
$tprice = $tprice * ( 1 + $details_refund->tax_rate / 100 );
|
||||||
$products_refund .= "
|
$products_refund .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td>". $details_refund->product_name . "</td>
|
<td>". $details_refund->product_name . "</td>
|
||||||
<td style='text-align:right;'>" . Tools::displayPrice($tprice) . " </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;'>". (int)$full_quantity_list[$id_order_detail] ."</td>
|
||||||
<td style='text-align:right;'>" . Tools::displayPrice(($tprice * (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>
|
||||||
";
|
";
|
||||||
$total_refund = $total_refund + ($tprice * (int)$full_quantity_list[$id_order_detail]);
|
$total_refund = $total_refund + ($tprice * (int)$full_quantity_list[$id_order_detail]);
|
||||||
}
|
}
|
||||||
@ -734,16 +734,14 @@ class AdminOrders extends AdminTab
|
|||||||
if (isset($_POST['shippingBack'])) {
|
if (isset($_POST['shippingBack'])) {
|
||||||
$order = new Order($details_refund->id_order);
|
$order = new Order($details_refund->id_order);
|
||||||
$fraisport .= "
|
$fraisport .= "
|
||||||
<tr style='text-align:right;'>
|
<tr style='text-align:right;'>
|
||||||
<td colspan='3' style='background-color:#e2e2e1; padding:0.6em 0.4em;'>Frais de port</td>
|
<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>
|
<td style='background-color:#e2e2e1; padding:0.6em 0.4em;'>" . Tools::displayPrice($order->total_shipping) . "</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
|
|
||||||
// Remboursement frais de port
|
// Remboursement frais de port
|
||||||
Module::hookExec('cancelShipping', array('order' => $order));
|
Module::hookExec('cancelShipping', array('order' => $order));
|
||||||
}
|
}
|
||||||
|
|
||||||
$params['{fraisport}'] = $fraisport;
|
$params['{fraisport}'] = $fraisport;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,13 +752,6 @@ class AdminOrders extends AdminTab
|
|||||||
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
$this->_errors[] = Tools::displayError('Cannot generate voucher');
|
||||||
}
|
}
|
||||||
else {
|
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
|
// Modif ANTADIS
|
||||||
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
|
||||||
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
|
||||||
@ -808,6 +799,40 @@ class AdminOrders extends AdminTab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Update order state if it's partial
|
||||||
if ($order->getCurrentState() == 17) {
|
if ($order->getCurrentState() == 17) {
|
||||||
$partial = true;
|
$partial = true;
|
||||||
@ -821,7 +846,8 @@ class AdminOrders extends AdminTab
|
|||||||
|
|
||||||
if (count($to_send) == 0) {
|
if (count($to_send) == 0) {
|
||||||
$partial = false;
|
$partial = false;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
|
include_once dirname(__FILE__).'/../../modules/privatesales/Sale.php';
|
||||||
$quantities_sent = array();
|
$quantities_sent = array();
|
||||||
|
|
||||||
@ -932,10 +958,14 @@ class AdminOrders extends AdminTab
|
|||||||
`date_upd` = NOW()
|
`date_upd` = NOW()
|
||||||
');
|
');
|
||||||
$newOS = new OrderState((int)(Configuration::get('PS_OS_SHIPPING')), $order->id_lang);
|
$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 {
|
else {
|
||||||
$this->_errors[] = Tools::displayError('No product or quantity selected.');
|
$this->_errors[] = Tools::displayError('No product or quantity selected.');
|
||||||
|
@ -120,15 +120,25 @@ class PayPal extends PaymentModule
|
|||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
{
|
{
|
||||||
if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn') ||
|
if (!parent::install()
|
||||||
!$this->registerHook('shoppingCartExtra') || !$this->registerHook('backBeforePayment') || !$this->registerHook('rightColumn') ||
|
|| !$this->registerHook('payment')
|
||||||
!$this->registerHook('cancelProduct') || !$this->registerHook('productFooter') || !$this->registerHook('header') ||
|
|| !$this->registerHook('paymentReturn')
|
||||||
!$this->registerHook('adminOrder') || !$this->registerHook('backOfficeHeader'))
|
|| !$this->registerHook('shoppingCartExtra')
|
||||||
return false;
|
|| !$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') ||
|
if ((_PS_VERSION_ >= '1.5') && (!$this->registerHook('displayMobileHeader')
|
||||||
!$this->registerHook('displayMobileShoppingCartTop') || !$this->registerHook('displayMobileAddToCartTop')))
|
|| !$this->registerHook('displayMobileShoppingCartTop')
|
||||||
return false;
|
|| !$this->registerHook('displayMobileAddToCartTop'))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
include_once(_PS_MODULE_DIR_.'/'.$this->name.'/paypal_install.php');
|
include_once(_PS_MODULE_DIR_.'/'.$this->name.'/paypal_install.php');
|
||||||
$paypal_install = new PayPalInstall();
|
$paypal_install = new PayPalInstall();
|
||||||
@ -749,9 +759,9 @@ class PayPal extends PaymentModule
|
|||||||
mail('karen@bebeboutik.com', 'Erreur dans le remboursement', 'Erreur remboursement échoué pour la commande ' . $order_detail->id_order);
|
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('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);
|
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 {
|
} else {
|
||||||
$this->refundSave($order->id, 0, $amount, $cookie->id_employee);
|
$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