Skip to content

Commit

Permalink
Merge pull request #20 from LinkNacional/dev
Browse files Browse the repository at this point in the history
1.1.3 Correção do bug de métodos de pagamento
  • Loading branch information
emanuellopess authored Mar 16, 2023
2 parents 7fb9424 + 3cdfecf commit aff75b4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v1.1.3
- Payment methods bug correction;

### v1.1.2
- Bug corrections;

Expand Down
5 changes: 4 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://www.linknacional.com/wordpress/plugins/
Tags: woocommerce, invoice, payment
Requires at least: 5.7
Tested up to: 6.1
Stable tag: 1.1.2
Stable tag: 1.1.3
Requires PHP: 7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -64,6 +64,9 @@ The Invoice Payment for WooCommerce plugin is now live and working.

== Changelog ==

= 1.1.3 =
* Payment methods bug correction;

= 1.1.2 =
* Bug corrections;

Expand Down
37 changes: 36 additions & 1 deletion public/js/wc-invoice-payment-public.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,47 @@
document.addEventListener('DOMContentLoaded', function () {
// Select default paymethod
let defaultPaymethod = document.getElementById('lkn_wcip_default_paymethod')

if (defaultPaymethod) {
defaultPaymethod = defaultPaymethod.value

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

const listPaymethods = document.getElementsByClassName('wc_payment_method')

let uniquePaymethod

let otherPaymethods = []

for (let i = 0; i < listPaymethods.length; i++) {
const temp = (listPaymethods[i].getElementsByTagName('input'))[0].value
otherPaymethods.push(temp)
}

let difPaymethod

for (let i = 0; i < otherPaymethods.length; i++) {
if (defaultPaymethod === (otherPaymethods[i])) {
otherPaymethods = otherPaymethods.filter(Paymethods => Paymethods !== (String(defaultPaymethod)))
difPaymethod = false
break
} else if (defaultPaymethod !== (otherPaymethods[i])) {
difPaymethod = true
}
}

if (difPaymethod) {
uniquePaymethod = (listPaymethods[0].getElementsByTagName('input'))[0].value
otherPaymethods = otherPaymethods.filter(Paymethods => Paymethods !== (String(uniquePaymethod)))
}

for (let i = 0; i < otherPaymethods.length; i++) {
otherPaymethods[i] = document.getElementsByClassName('wc_payment_method payment_method_' + otherPaymethods[i])
}

for (let i = 0; i < otherPaymethods.length; i++) {
otherPaymethods[i][0].remove()
}

if (inputPaymethod) {
inputPaymethod.click()
}
Expand Down
4 changes: 2 additions & 2 deletions wc-invoice-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* Plugin Name: Invoice Payment for WooCommerce
* Plugin URI: https://www.linknacional.com/wordpress/plugins/
* Description: Invoice payment generation and management for WooCommerce.
* Version: 1.1.2
* Version: 1.1.3
* Author: Link Nacional
* Author URI: https://www.linknacional.com/
* License: GPL-2.0+
Expand All @@ -34,7 +34,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define('WC_PAYMENT_INVOICE_VERSION', '1.1.2');
define('WC_PAYMENT_INVOICE_VERSION', '1.1.3');
define('WC_PAYMENT_INVOICE_TRANSLATION_PATH', plugin_dir_path(__FILE__) . 'languages/');

/**
Expand Down

0 comments on commit aff75b4

Please sign in to comment.