Skip to content

Commit

Permalink
Merge branch 'wip/location-options'
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoyigi committed Aug 17, 2022
2 parents 05299e8 + 743cad1 commit 5d3053a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Igniter\PayRegister;

use Admin\Models\Payments_model;
use Admin\Requests\Location;
use Admin\Widgets\Form;
use Illuminate\Support\Facades\Event;
use System\Classes\BaseExtension;
Expand Down Expand Up @@ -81,5 +82,36 @@ public function boot()

$order->payment_method->updatePaymentIntentSession($order);
});

$this->extendLocationOptionsFields();
}

protected function extendLocationOptionsFields()
{
Event::listen('admin.locations.defineOptionsFormFields', function () {
return [
'payments' => [
'label' => 'lang:igniter.payregister::default.label_payments',
'accordion' => 'lang:admin::lang.locations.text_tab_general_options',
'type' => 'checkboxlist',
'options' => ['Admin\Models\Payments_model', 'listDropdownOptions'],
'commentAbove' => 'lang:igniter.payregister::default.help_payments',
'placeholder' => 'lang:igniter.payregister::default.help_no_payments',
],
];
});

Event::listen('system.formRequest.extendValidator', function ($formRequest, $dataHolder) {
if (!$formRequest instanceof Location)
return;

$dataHolder->attributes = array_merge($dataHolder->attributes, [
'options.payments.*' => lang('igniter.payregister::default.label_payments'),
]);

$dataHolder->rules = array_merge($dataHolder->rules, [
'options.payments.*' => ['string'],
]);
});
}
}
5 changes: 5 additions & 0 deletions language/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
'label_refund_type' => 'Refund Type',
'label_refund_amount' => 'Refund Partial Amount',

'label_payments' => 'Payments',

'button_delete_card' => 'Delete and use a different card.',
'button_refund' => 'Refund',

Expand All @@ -26,6 +28,9 @@
'help_order_fee' => 'Extra charge to the order total when this payment gateway becomes active',
'help_order_status' => 'Default order status when this payment method is used.',

'help_payments' => 'Select the payment(s) available at this location. Leave blank to use all enabled payments',
'help_no_payments' => 'No enabled payment was found.',

'cod' => [
'text_tab_general' => 'General',
'text_payment_title' => 'Cash On Delivery',
Expand Down

0 comments on commit 5d3053a

Please sign in to comment.