Add hookCancelShipping

This commit is contained in:
Michael RICOIS 2018-01-29 16:47:51 +01:00
parent b907ac0e66
commit 3aca7c4e2e
3 changed files with 58 additions and 12 deletions

View File

@ -462,8 +462,7 @@ class AdminOrders extends AdminTab
header('Location: '.$_SERVER['REQUEST_URI']);
exit;
}
/* 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)))
{
@ -700,7 +699,7 @@ class AdminOrders extends AdminTab
}
}
// Préparation
// Remboursement, Bon de réduction
if (!sizeof($this->_errors) && (isset($_POST['generateCreditSlip'])
|| isset($_POST['generateDiscount'])
|| isset($_POST['generateDiscount2']))) {
@ -734,13 +733,15 @@ class AdminOrders extends AdminTab
$fraisport = "";
if (isset($_POST['shippingBack'])) {
$order = new Order($details_refund->id_order);
Module::hookExec('cancelShipping', array('order' => $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>
";
// Remboursement frais de port
Module::hookExec('cancelShipping', array('order' => $order));
}
$params['{fraisport}'] = $fraisport;
@ -760,15 +761,14 @@ class AdminOrders extends AdminTab
// $params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
// NULL, _PS_MAIL_DIR_, true);
/* MODIF MAIL ANTADIS */
// Modif ANTADIS
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$params['{voucher_amount}'] = Tools::displayPrice($voucher->value, $currency, false);
$params['{voucher_num}'] = $voucher->name;
$params['{voucher_value}'] = $voucher->value;
@Mail::Send((int)($order->id_lang), 'refundorder', Mail::l('New voucher regarding your order'),
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
NULL, _PS_MAIL_DIR_, true);
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
NULL, _PS_MAIL_DIR_, true);
}
}
@ -784,8 +784,8 @@ class AdminOrders extends AdminTab
$params['{voucher_num}'] = $voucher->name;
$params['{voucher_value}'] = $voucher->value;
@Mail::Send((int)($order->id_lang), 'refundorder', Mail::l('New voucher regarding your order'),
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
NULL, _PS_MAIL_DIR_, true);
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL,
NULL, _PS_MAIL_DIR_, true);
}
}

View File

@ -537,7 +537,7 @@ class Paybox extends PaymentModule
* @param array $params
* @return void|boolean
*/
public function hookcancelShipping($params)
public function hookCancelShipping($params)
{
global $cookie;
@ -548,6 +548,7 @@ class Paybox extends PaymentModule
if ($params['order']->module != $this->name) {
return false;
}
if (!($order = $params['order']) OR !Validate::isLoadedObject($order)) {
return false;
}
@ -559,7 +560,7 @@ class Paybox extends PaymentModule
mail('doreen@bebeboutik.com', 'Erreur remboursement', 'Erreur de remboursement sur la commande ' . $order_detail->id_order . ' la commande n\'a pas été payée.');
mail('contact@bebeboutik.com', 'Erreur remboursement', 'Erreur de remboursement sur la commande ' . $order_detail->id_order . ' la commande n\'a pas été payée.');
} else {
if ($order->payment == "Paybox") {
if (strtolower($order->payment) == "paybox") {
$this->refundShipping($order);
}
}

View File

@ -677,6 +677,51 @@ class PayPal extends PaymentModule
}
}
/**
* Refund shipping
* @param array $params
* @return void|boolean
*/
public function hookCancelShipping($params)
{
global $cookie;
if (Tools::getValue('noCancelHook')) {
return;
}
if (!$this->isPayPalAPIAvailable()) {
return false;
}
elseif ($params['order']->module != $this->name
|| !($order = $params['order']) || !Validate::isLoadedObject($order)) {
return false;
}
elseif (!$order->hasBeenPaid()) {
return false;
}
$paypal_order = PayPalOrder::getOrderById((int)$order->id);
if (!$paypal_order) {
return false;
}
if (in_array($cookie->profile, array(1,7,14,11))) {
if (!$order->hasBeenPaid()) {
mail('karen@bebeboutik.com', 'Erreur remboursement', 'Erreur de remboursement sur la commande ' . $order_detail->id_order . ' la commande n\'a pas été payée.');
mail('doreen@bebeboutik.com', 'Erreur remboursement', 'Erreur de remboursement sur la commande ' . $order_detail->id_order . ' la commande n\'a pas été payée.');
mail('contact@bebeboutik.com', 'Erreur remboursement', 'Erreur de remboursement sur la commande ' . $order_detail->id_order . ' la commande n\'a pas été payée.');
} else {
if (strtolower($order->payment) == "paypal") {
// Refund shipping
//$refund = $this->_makeRefund($paypal_order['id_transaction'], (int)$order->id, $amount);
}
}
}
}
public function hookCancelProduct($params)
{
if (!$this->isPayPalAPIAvailable()) {