Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop
This commit is contained in:
commit
46f02fd0cf
@ -674,6 +674,7 @@ class AdminOrders extends AdminTab
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion of the product.').' <span class="bold">'.$orderDetail->product_name.'</span>';
|
||||
Module::hookExec('cancelProduct', array('order' => $order, 'id_order_detail' => $id_order_detail));
|
||||
}
|
||||
|
||||
if (!sizeof($this->_errors) AND $customizationList)
|
||||
foreach ($customizationList AS $id_customization => $id_order_detail)
|
||||
{
|
||||
@ -682,6 +683,7 @@ class AdminOrders extends AdminTab
|
||||
if (!$order->deleteCustomization($id_customization, $qtyCancelProduct, $orderDetail))
|
||||
$this->_errors[] = Tools::displayError('An error occurred during deletion of product customization.').' '.$id_customization;
|
||||
}
|
||||
|
||||
// E-mail params
|
||||
if ((isset($_POST['generateCreditSlip']) OR isset($_POST['generateDiscount']) OR isset($_POST['generateDiscount2'])) AND !sizeof($this->_errors))
|
||||
{
|
||||
@ -776,14 +778,19 @@ class AdminOrders extends AdminTab
|
||||
// Generate credit slip
|
||||
if (isset($_POST['generateCreditSlip']) AND !sizeof($this->_errors))
|
||||
{
|
||||
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack'])))
|
||||
if (!OrderSlip::createOrderSlip($order, $full_product_list, $full_quantity_list, isset($_POST['shippingBack']))) {
|
||||
$this->_errors[] = Tools::displayError('Cannot generate credit slip');
|
||||
else
|
||||
{
|
||||
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $full_product_list, 'qtyList' => $full_quantity_list));
|
||||
}
|
||||
else {
|
||||
Module::hookExec('orderSlip', array(
|
||||
'order' => $order,
|
||||
'productList' => $full_product_list,
|
||||
'qtyList' => $full_quantity_list,
|
||||
'shippingBack' => isset($_POST['shippingBack']) ? true : false,
|
||||
));
|
||||
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
|
148
modules/ant_refund_discount/ant_refund_discount.php
Normal file
148
modules/ant_refund_discount/ant_refund_discount.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Ant_Refund_Discount extends Module
|
||||
{
|
||||
protected $debuglog = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'ant_refund_discount';
|
||||
$this->tab = 'administration';
|
||||
$this->author = 'Antadis';
|
||||
$this->version = '1.0';
|
||||
$this->need_instance = 0;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('Refund discount');
|
||||
$this->description = $this->l('Re-create discount when an order is refund');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
// Register hooks
|
||||
if(!(parent::install() && $this->registerHook('orderSlip'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public function hookOrderSlip($params)
|
||||
{
|
||||
$orderParams = $params['order'];
|
||||
$productList = $params['productList'];
|
||||
$qtyList = $params['qtyList'];
|
||||
$shippingBack = isset($params['shippingBack']) ? $params['shippingBack'] : false;
|
||||
|
||||
if ($this->debuglog) file_put_contents(_PS_ROOT_DIR_.'/log/ant_refund_discount.log', 'Discount : '.$orderParams->total_discounts."\n");
|
||||
if ($this->debuglog) file_put_contents(_PS_ROOT_DIR_.'/log/ant_refund_discount.log', print_r($params, 1), FILE_APPEND);
|
||||
|
||||
// If we have no discount
|
||||
if ($orderParams->total_discounts == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If "full" value is set to true, never check the order details
|
||||
$full = false;
|
||||
if (isset($params['full']) && $params['full'] === true) {
|
||||
$full = true;
|
||||
}
|
||||
|
||||
// shippingBack
|
||||
if (!$full && !$shippingBack) {
|
||||
return;
|
||||
}
|
||||
|
||||
$order = new Order($orderParams->id);
|
||||
|
||||
// Product qty
|
||||
if ($full === false) {
|
||||
$orderProducts = $order->getProductsDetail();
|
||||
|
||||
if ($this->debuglog) file_put_contents(_PS_ROOT_DIR_.'/log/ant_refund_discount.log', count($orderProducts).' != '.count($productList)."\n", FILE_APPEND);
|
||||
|
||||
// Check product line difference
|
||||
if (count($orderProducts) != count($productList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->debuglog) file_put_contents(_PS_ROOT_DIR_.'/log/ant_refund_discount.log', print_r($orderProducts, 1), FILE_APPEND);
|
||||
|
||||
// Check product quantity
|
||||
foreach ($orderProducts as $p) {
|
||||
if ($p['product_quantity'] != $qtyList[$p['id_order_detail']]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Discount
|
||||
$discountUse = $order->getDiscounts();
|
||||
if (count($discountUse) > 0) {
|
||||
foreach($discountUse as $d) {
|
||||
$this->copyDiscountAfterRefund($order, $d);
|
||||
}
|
||||
}
|
||||
if ($this->debuglog) file_put_contents(_PS_ROOT_DIR_.'/log/ant_refund_discount.log', 'FIN', FILE_APPEND);
|
||||
}
|
||||
|
||||
protected function copyDiscountAfterRefund($order, $discount)
|
||||
{
|
||||
$languages = Language::getLanguages();
|
||||
|
||||
$item = new Discount($discount['id_discount']);
|
||||
|
||||
if ($this->debuglog) file_put_contents(_PS_ROOT_DIR_.'/log/ant_refund_discount.log', print_r($item, 1), FILE_APPEND);
|
||||
|
||||
// Re Create discount
|
||||
$voucher = new Discount();
|
||||
$voucher->id_discount_type = $item->id_discount_type;
|
||||
foreach ($languages as $language) {
|
||||
$voucher->description[$language['id_lang']] = $item->description[$language['id_lang']];
|
||||
}
|
||||
$voucher->value = (float) $item->value;
|
||||
$voucher->name = 'R-'.(int)($order->id);
|
||||
$voucher->id_customer = (int)($order->id_customer);
|
||||
$voucher->id_currency = (int)($order->id_currency);
|
||||
$voucher->quantity = 1;
|
||||
$voucher->quantity_per_user = 1;
|
||||
$voucher->cumulable = $item->cumulable;
|
||||
$voucher->cumulable_reduction = $item->cumulable_reduction;
|
||||
$voucher->minimal = (float) $voucher->value;
|
||||
$voucher->active = 1;
|
||||
$voucher->cart_display = $item->cart_display;
|
||||
|
||||
$now = time();
|
||||
$start = new DateTime($item->date_from);
|
||||
$end = new DateTime($item->date_to);
|
||||
$interval = $start->diff($end);
|
||||
$voucher->date_from = date('Y-m-d H:i:s', $now);
|
||||
$voucher->date_to = date('Y-m-d H:i:s', $now + $interval);
|
||||
|
||||
if (!$voucher->validateFieldsLang(false) OR !$voucher->add()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ok discount created, send mail
|
||||
$customer = new Customer($order->id_customer);
|
||||
|
||||
// Vars
|
||||
$params = array(
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{voucher_num}' => $voucher->name,
|
||||
);
|
||||
|
||||
Mail::Send((int)$order->id_lang, 'voucher_after_refund', Mail::l('New voucher after refund', $order->id_lang),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
|
||||
_PS_MAIL_DIR_, true);
|
||||
|
||||
return $voucher;
|
||||
}
|
||||
|
||||
}
|
36
modules/ant_refund_discount/index.php
Executable file
36
modules/ant_refund_discount/index.php
Executable file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 7233 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Message de {shop_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<table style="font-family: tahoma,arial,sans-serif; font-size: 12px; color:#000000; width: 550px;">
|
||||
<tr>
|
||||
<td align="left">
|
||||
<a href="{shop_url}" title="{shop_name}"><img alt="{shop_name}" src="{shop_logo}" style="border:none;" ></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left">Bonjour <strong>{firstname} {lastname}</strong>,</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
Nous venons de procéder au remboursement de votre commande. Vous aviez utilisé, au moment de passer votre commande, un bon de réduction.
|
||||
<br>Nous vous informons qu'un nouveau bon de réduction vous a été attribué {voucher_num}.
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
Cordialement,<br />
|
||||
Le service client
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="center" style="font-size: 12px; border-top: 1px solid #cccccc; padding-top: 5px;">
|
||||
{shop_name} - <a href="{shop_url}" style="color: #e26ea2;">{shop_url}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,7 @@
|
||||
Bonjour {firstname} {lastname},
|
||||
|
||||
Nous venons de procéder au remboursement de votre commande. Vous aviez utilisé, au moment de passer votre commande, un bon de réduction.
|
||||
Nous vous informons qu'un nouveau bon de réduction vous a été attribué {voucher_num}.
|
||||
|
||||
Cordialement,
|
||||
Le service client
|
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Message de {shop_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<table style="font-family: tahoma,arial,sans-serif; font-size: 12px; color:#000000; width: 550px;">
|
||||
<tr>
|
||||
<td align="left">
|
||||
<a href="{shop_url}" title="{shop_name}"><img alt="{shop_name}" src="{shop_logo}" style="border:none;" ></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left">Bonjour <strong>{firstname} {lastname}</strong>,</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
Nous venons de procéder au remboursement de votre commande. Vous aviez utilisé, au moment de passer votre commande, un bon de réduction.
|
||||
<br>Nous vous informons qu'un nouveau bon de réduction vous a été attribué {voucher_num}.
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="left">
|
||||
Cordialement,<br />
|
||||
Le service client
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td> </td></tr>
|
||||
<tr>
|
||||
<td align="center" style="font-size: 12px; border-top: 1px solid #cccccc; padding-top: 5px;">
|
||||
{shop_name} - <a href="{shop_url}" style="color: #e26ea2;">{shop_url}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,7 @@
|
||||
Bonjour {firstname} {lastname},
|
||||
|
||||
Nous venons de procéder au remboursement de votre commande. Vous aviez utilisé, au moment de passer votre commande, un bon de réduction.
|
||||
Nous vous informons qu'un nouveau bon de réduction vous a été attribué {voucher_num}.
|
||||
|
||||
Cordialement,
|
||||
Le service client
|
40
modules/ant_refund_discount/mails/fr/voucher_after_refund.html
Executable file
40
modules/ant_refund_discount/mails/fr/voucher_after_refund.html
Executable file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Message de {shop_name}</title>
|
||||
</head>
|
||||
<body>
|
||||
<table style="font-family: tahoma,arial,sans-serif; font-size: 12px; color: #000000; width: 550px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left"><a title="{shop_name}" href="{shop_url}"><img style="border: none;" src="{shop_logo}" alt="{shop_name}" /></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">Bonjour <strong>{firstname} {lastname}</strong>,</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">Nous venons de procéder au remboursement de votre commande. Vous aviez utilisé, au moment de passer votre commande, un bon de réduction. <br />Nous vous informons qu'un nouveau bon de réduction vous a été attribué {voucher_num}.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left">Cordialement,<br /> Le service client</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="font-size: 12px; border-top: 1px solid #cccccc; padding-top: 5px;" align="center">{shop_name} - <a style="color: #e26ea2;" href="{shop_url}">{shop_url}</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
7
modules/ant_refund_discount/mails/fr/voucher_after_refund.txt
Executable file
7
modules/ant_refund_discount/mails/fr/voucher_after_refund.txt
Executable file
@ -0,0 +1,7 @@
|
||||
Bonjour {firstname} {lastname},
|
||||
|
||||
Nous venons de procéder au remboursement de votre commande. Vous aviez utilisé, au moment de passer votre commande, un bon de réduction.
|
||||
Nous vous informons qu'un nouveau bon de réduction vous a été attribué {voucher_num}.
|
||||
|
||||
Cordialement,
|
||||
Le service client
|
@ -545,7 +545,12 @@ class AdminAntReturnprocess extends AdminTab
|
||||
HelperFormBootstrap::displayErrors(Tools::displayError('Cannot generate credit slip'));
|
||||
$errors++;
|
||||
} else {
|
||||
Module::hookExec('orderSlip', array('order' => $order, 'productList' => $id_order_details, 'qtyList' => $refund_quantities));
|
||||
Module::hookExec('orderSlip', array(
|
||||
'order' => $order,
|
||||
'productList' => $id_order_details,
|
||||
'qtyList' => $refund_quantities,
|
||||
'shippingBack' => isset($_POST['shippingBack']) ? true : false,
|
||||
));
|
||||
|
||||
@Mail::Send((int)$order->id_lang, 'credit_slip', Mail::l('New credit slip regarding your order', $order->id_lang),
|
||||
$params, $customer->email, $customer->firstname.' '.$customer->lastname, NULL, NULL, NULL, NULL,
|
||||
|
@ -1280,7 +1280,10 @@ class soflexibilite extends CarrierModule
|
||||
}
|
||||
|
||||
if (in_array($params['order']->id_carrier, $this->id_carrier_so)) {
|
||||
if (!in_array($params['order']->id_carrier, array($this->id_carrier_so['SOFLEXIBILITE_DOM_ID'], $this->id_carrier_so['SOFLEXIBILITE_DOS_ID']))) {
|
||||
if (!in_array($params['order']->id_carrier, array(
|
||||
$this->id_carrier_so['SOFLEXIBILITE_DOM_ID'],
|
||||
$this->id_carrier_so['SOFLEXIBILITE_DOS_ID']))) {
|
||||
|
||||
$soDelivery = new SoFlexibiliteDelivery((int)$params['cart']->id, (int)$params['cart']->id_customer);
|
||||
$soDelivery->loadDelivery();
|
||||
|
||||
@ -1328,17 +1331,24 @@ class soflexibilite extends CarrierModule
|
||||
$address_delivery = new Address($id_address_new);
|
||||
|
||||
if (Validate::isLoadedObject($address_delivery)) {
|
||||
// Change lastname according to the address
|
||||
$soDelivery->lastname = $address->lastname;
|
||||
|
||||
// If type = BPR, change firstname according to the address
|
||||
if ($soDelivery->type == 'BPR') {
|
||||
$soDelivery->firstname = $address_delivery->firstname;
|
||||
}
|
||||
}
|
||||
$soDelivery->saveDelivery();
|
||||
|
||||
if (Validate::isLoadedObject($address)) {
|
||||
if (is_null($soDelivery->telephone) || empty($soDelivery->telephone) || Tools::strlen($soDelivery->telephone) < 7) {
|
||||
$soDelivery->telephone = $address->phone_mobile ? $address->phone_mobile : ($address->phone ? $address->phone : '');
|
||||
}
|
||||
}
|
||||
|
||||
$soDelivery->saveDelivery();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$soDelivery = new SoFlexibiliteDelivery((int)$params['cart']->id, (int)$params['cart']->id_customer);
|
||||
$soDelivery->loadDelivery();
|
||||
|
||||
@ -1392,7 +1402,8 @@ class soflexibilite extends CarrierModule
|
||||
|
||||
$soDelivery->saveDelivery();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$soDelivery = new SoFlexibiliteDelivery();
|
||||
$soDelivery->removeDelivery((int)$params['cart']->id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user