Skip to content

Commit

Permalink
Add refund state configuration keys
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-webkul committed Jan 19, 2023
1 parent 2244496 commit 8a05bf9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/admin/AdminOrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ public function postProcess()
$objOrderReturn = new OrderReturn();
$objOrderReturn->id_customer = $order->id_customer;
$objOrderReturn->id_order = $order->id;
$objOrderReturn->state = OrderReturnState::ORDER_RETRUN_FIRST_STATUS;
$objOrderReturn->state = Configuration::get('PS_ORS_PENDING');
$objOrderReturn->by_admin = 1;
$objOrderReturn->question = $refundReason;
$objOrderReturn->save();
Expand Down
9 changes: 9 additions & 0 deletions install/data/xml/configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,15 @@
<configuration id="PS_OS_PARTIAL_PAYMENT" name="PS_OS_PARTIAL_PAYMENT">
<value>14</value>
</configuration>
<configuration id="PS_ORS_PENDING" name="PS_ORS_PENDING">
<value>1</value>
</configuration>
<configuration id="PS_ORS_DENIED" name="PS_ORS_DENIED">
<value>2</value>
</configuration>
<configuration id="PS_ORS_REFUNDED" name="PS_ORS_REFUNDED">
<value>3</value>
</configuration>
<configuration id="PS_LEGACY_IMAGES" name="PS_LEGACY_IMAGES">
<value>0</value>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct()
$this->list_no_link = true;
$this->context = Context::getContext();

$this->_select = ' COUNT(IF(a.`state` = '.(int) OrderReturnState::ORDER_RETRUN_FIRST_STATUS.', 1, NULL)) AS total_pending_requests,
$this->_select = ' COUNT(IF(a.`state` = '.(int) Configuration::get('PS_ORS_PENDING').', 1, NULL)) AS total_pending_requests,
ord.`id_currency`, ord.`total_paid_tax_incl` AS total_order, SUM(a.`refunded_amount`) AS refunded_amount, CONCAT(firstname, " ", lastname) AS cust_name, os.`color`, os.`id_order_state`';
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'orders` ord ON (a.`id_order` = ord.`id_order`)';
$this->_join .= 'LEFT JOIN '._DB_PREFIX_.'order_state os ON (os.`id_order_state` = ord.`current_state`)';
Expand Down Expand Up @@ -517,11 +517,11 @@ public function postProcess()
}

// redirect with success if process completed successfully
$confirmation = '4';
if ($idRefundState == 2) {
$confirmation = '101';
} elseif ($idRefundState == 3) {
$confirmation = '102';
$confirmation = 4;
if ($objRefundState->denied) {
$confirmation = 101;
} elseif ($objRefundState->refunded) {
$confirmation = 102;
}
Tools::redirectAdmin(
self::$currentIndex.'&conf='.$confirmation.'&id_order_return='.$idOrderReturn.
Expand Down

0 comments on commit 8a05bf9

Please sign in to comment.