V1.5.0 released: API, Refund procress improvement, Order data management

This commit is contained in:
Rohit Jain
2020-09-14 13:51:36 +05:30
parent 0d274a6044
commit afa200c90f
1143 changed files with 13582 additions and 32539 deletions

View File

@@ -31,59 +31,6 @@ class OrderFollowControllerCore extends FrontController
public $authRedirection = 'order-follow';
public $ssl = true;
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('submitReturnMerchandise')) {
$customizationQtyInput = Tools::getValue('customization_qty_input');
$order_qte_input = Tools::getValue('order_qte_input');
$customizationIds = Tools::getValue('customization_ids');
if (!$id_order = (int)Tools::getValue('id_order')) {
Tools::redirect('index.php?controller=history');
}
if (!$order_qte_input && !$customizationQtyInput && !$customizationIds) {
Tools::redirect('index.php?controller=order-follow&errorDetail1');
}
if (!$customizationIds && !$ids_order_detail = Tools::getValue('ids_order_detail')) {
Tools::redirect('index.php?controller=order-follow&errorDetail2');
}
$order = new Order((int)$id_order);
if (!$order->isReturnable()) {
Tools::redirect('index.php?controller=order-follow&errorNotReturnable');
}
if ($order->id_customer != $this->context->customer->id) {
die(Tools::displayError());
}
$orderReturn = new OrderReturn();
$orderReturn->id_customer = (int)$this->context->customer->id;
$orderReturn->id_order = $id_order;
$orderReturn->question = htmlspecialchars(Tools::getValue('returnText'));
if (empty($orderReturn->question)) {
Tools::redirect('index.php?controller=order-follow&errorMsg&'.
http_build_query(array(
'ids_order_detail' => $ids_order_detail,
'order_qte_input' => $order_qte_input,
'id_order' => Tools::getValue('id_order'),
)));
}
if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput)) {
Tools::redirect('index.php?controller=order-follow&errorQuantity');
}
$orderReturn->state = 1;
$orderReturn->add();
$orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput);
Hook::exec('actionOrderReturn', array('orderReturn' => $orderReturn));
Tools::redirect('index.php?controller=order-follow');
}
}
/**
* Assign template vars related to page content
* @see FrontController::initContent()
@@ -91,42 +38,16 @@ class OrderFollowControllerCore extends FrontController
public function initContent()
{
parent::initContent();
$this->show_breadcrump = true;
if (isset($this->context->customer->id) && $this->context->customer->id) {
$ordersReturns = OrderReturn::getOrdersReturn($this->context->customer->id, Tools::getValue('id_order'));
$this->context->smarty->assign('ordersReturns', $ordersReturns);
$ordersReturn = OrderReturn::getOrdersReturn($this->context->customer->id);
if (Tools::isSubmit('errorQuantity')) {
$this->context->smarty->assign('errorQuantity', true);
} elseif (Tools::isSubmit('errorMsg')) {
$this->context->smarty->assign(
array(
'errorMsg' => true,
'ids_order_detail' => Tools::getValue('ids_order_detail', array()),
'order_qte_input' => Tools::getValue('order_qte_input', array()),
'id_order' => (int)Tools::getValue('id_order'),
)
$this->setTemplate(_PS_THEME_DIR_.'order-follow.tpl');
} else {
Tools::redirect(
'index.php?controller=authentication&back='.urlencode($this->context->link->getpageLink('my-account'))
);
} elseif (Tools::isSubmit('errorDetail1')) {
$this->context->smarty->assign('errorDetail1', true);
} elseif (Tools::isSubmit('errorDetail2')) {
$this->context->smarty->assign('errorDetail2', true);
} elseif (Tools::isSubmit('errorNotReturnable')) {
$this->context->smarty->assign('errorNotReturnable', true);
}
$this->context->smarty->assign('ordersReturn', $ordersReturn);
$this->setTemplate(_PS_THEME_DIR_.'order-follow.tpl');
}
public function setMedia()
{
parent::setMedia();
$this->addCSS(array(_THEME_CSS_DIR_.'history.css', _THEME_CSS_DIR_.'addresses.css'));
$this->addJqueryPlugin('scrollTo');
$this->addJS(array(
_THEME_JS_DIR_.'history.js',
_THEME_JS_DIR_.'tools.js') // retro compat themes 1.5
);
$this->addjqueryPlugin('footable');
$this->addJqueryPlugin('footable-sort');
}
}