Skip to content

Commit 64771c8

Browse files
authored
Merge pull request #168 from paynl/feature/PLUG-4367-2
PLUG-4367 - Restock option upon refund
2 parents b3f0ee7 + f551e84 commit 64771c8

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

includes/classes/PPMFWC/Gateways.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,13 @@ public static function ppmfwc_addGlobalSettings()
512512
'desc' => esc_html(__("Process refunds in WooCommerce that are initiated in My.pay", PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),
513513
'id' => 'paynl_externalrefund',
514514
'default' => 'no',
515+
);
516+
$addedSettings[] = array(
517+
'name' => __('Stock', PPMFWC_WOOCOMMERCE_TEXTDOMAIN),
518+
'type' => 'checkbox',
519+
'desc' => esc_html(__("Exclude stock updates for refunds and retourpin transaction", PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),
520+
'id' => 'paynl_exclude_restock',
521+
'default' => 'no',
515522
);
516523
$addedSettings[] = array(
517524
'name' => esc_html(__('Auto capture', PPMFWC_WOOCOMMERCE_TEXTDOMAIN)),

includes/classes/PPMFWC/Helper/Transaction.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ public static function processTransaction($transactionId, $status = null, $metho
340340
if (get_option('paynl_externalrefund') == "yes") {
341341
PPMFWC_Helper_Data::ppmfwc_payLogger('Changing order state to `refunded`', $transactionId);
342342
$order->set_status('refunded');
343-
wc_increase_stock_levels($orderId);
343+
if (get_option('paynl_exclude_restock') != "yes") {
344+
wc_increase_stock_levels($orderId);
345+
}
344346
$order->save();
345347
}
346348
break;
@@ -352,7 +354,9 @@ public static function processTransaction($transactionId, $status = null, $metho
352354
}
353355
PPMFWC_Helper_Data::ppmfwc_payLogger('Changing order state to `chargeback`', $transactionId);
354356
$order->set_status($status, 'Pay. Chargeback. Reason: "' . PPMFWC_Helper_Data::getRequestArg('external_reason_description') . '".');
355-
wc_increase_stock_levels($orderId);
357+
if (get_option('paynl_exclude_restock') != "yes") {
358+
wc_increase_stock_levels($orderId);
359+
}
356360
$order->save();
357361
break;
358362

@@ -477,7 +481,9 @@ public static function processRefund($order, $amount)
477481
}
478482
if (PPMFWC_Helper_Data::getRequestArg('amount') == $order->get_remaining_refund_amount()) {
479483
$order->set_status('refunded');
480-
wc_increase_stock_levels($orderId);
484+
if (get_option('paynl_exclude_restock') != "yes") {
485+
wc_increase_stock_levels($orderId);
486+
}
481487
}
482488
$order->save();
483489
}

0 commit comments

Comments
 (0)