Skip to content

Commit

Permalink
feat: Adding MultiPayments option to payment options #21
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhermeLinkNacional committed Mar 20, 2024
1 parent 84e0622 commit 8b5ab3c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
48 changes: 25 additions & 23 deletions admin/class-wc-invoice-payment-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class="wcip-form-wrap"
name="lkn_wcip_payment_global_template"
id="lkn_wcip_payment_global_template"
class="regular-text"
>
>
<?php echo $html_templates_list; ?>
</select>
</div>
Expand Down Expand Up @@ -428,13 +428,14 @@ class="regular-text"
class="regular-text"
>
<?php
foreach ($enabled_gateways as $key => $gateway) {
if ($order->get_payment_method() === $gateway->id) {
echo '<option value="' . esc_attr($gateway->id) . '" selected>' . esc_attr($gateway->title) . '</option>';
} else {
echo '<option value="' . esc_attr($gateway->id) . '">' . esc_attr($gateway->title) . '</option>';
}
} ?>
echo '<option value="multiplePayment" selected>Multiple payment</option>';
foreach ($enabled_gateways as $key => $gateway) {
if ($order->get_payment_method() === $gateway->id) {
echo '<option value="' . esc_attr($gateway->id) . '" selected>' . esc_attr($gateway->title) . '</option>';
} else {
echo '<option value="' . esc_attr($gateway->id) . '">' . esc_attr($gateway->title) . '</option>';
}
} ?>
</select>
</div>
<div class="input-row-wrap">
Expand All @@ -446,13 +447,13 @@ class="regular-text"
class="regular-text"
>
<?php
foreach ($currencies as $code => $currency) {
if ($order->get_currency() === $code) {
echo '<option value="' . esc_attr($code) . '" selected>' . esc_attr($currency) . ' - ' . esc_attr($code) . '</option>';
} else {
echo '<option value="' . esc_attr($code) . '">' . esc_attr($currency) . ' - ' . esc_attr($code) . '</option>';
}
} ?>
foreach ($currencies as $code => $currency) {
if ($order->get_currency() === $code) {
echo '<option value="' . esc_attr($code) . '" selected>' . esc_attr($currency) . ' - ' . esc_attr($code) . '</option>';
} else {
echo '<option value="' . esc_attr($code) . '">' . esc_attr($currency) . ' - ' . esc_attr($code) . '</option>';
}
} ?>
</select>
</div>
<div class="input-row-wrap">
Expand Down Expand Up @@ -852,6 +853,7 @@ class="regular-text"
class="regular-text"
>
<?php
echo '<option value="multiplePayment" selected>Multiple payment</option>';
foreach ($enabled_gateways as $key => $gateway) {
echo '<option value="' . esc_attr($gateway->id) . '">' . esc_html($gateway->title) . '</option>';
} ?>
Expand All @@ -866,13 +868,13 @@ class="regular-text"
class="regular-text"
>
<?php
foreach ($currencies as $code => $currency) {
if ($active_currency === $code) {
echo '<option value="' . esc_attr($code) . '" selected>' . esc_html($currency . ' - ' . $code) . '</option>';
} else {
echo '<option value="' . esc_attr($code) . '">' . esc_html($currency . ' - ' . $code) . '</option>';
}
} ?>
foreach ($currencies as $code => $currency) {
if ($active_currency === $code) {
echo '<option value="' . esc_attr($code) . '" selected>' . esc_html($currency . ' - ' . $code) . '</option>';
} else {
echo '<option value="' . esc_attr($code) . '">' . esc_html($currency . ' - ' . $code) . '</option>';
}
} ?>
</select>
</div>
<div class="input-row-wrap">
Expand Down Expand Up @@ -1300,4 +1302,4 @@ public function edit_invoice_form_submit_handle(): void {
}
}
}
?>
?>
2 changes: 2 additions & 0 deletions public/js/wc-invoice-payment-public.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ document.addEventListener('DOMContentLoaded', function () {
if (defaultPaymethod) {
defaultPaymethod = defaultPaymethod.value

if(defaultPaymethod == "multiplePayment") return ''

const inputPaymethod = document.getElementById('payment_method_' + defaultPaymethod)

const listPaymethods = document.getElementsByClassName('wc_payment_method')
Expand Down

0 comments on commit 8b5ab3c

Please sign in to comment.