Skip to content

Commit

Permalink
Merge branch 'master' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed Jun 28, 2024
2 parents cec00e9 + 3254567 commit 8baf2bd
Show file tree
Hide file tree
Showing 66 changed files with 3,998 additions and 6,094 deletions.
7 changes: 6 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
/package-lock.json
/package.json
/gulpfile.js
.DS_Store
.DS_Store
phpunit.cache
/tests
DOCKER_ENV
docker_tag
output.log
40 changes: 40 additions & 0 deletions .github/workflows/create-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create build
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- name: Install composer
uses: php-actions/composer@v6
with:
php_extensions: json
version: 2
dev: no
- run: composer global config --no-plugins allow-plugins.wpify/scoper true
- run: composer global require wpify/scoper
- run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE/vendor
- run: composer install --no-dev --optimize-autoloader

- name: Archive plugin artifacts
uses: actions/upload-artifact@v2
with:
name: woolab-ic-dic
path: |
${{ github.workspace }}
!git/**/*
!github/**/*
!tests/**/*
!DOCKER_ENV
!docker_tag
!output.log
44 changes: 43 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,54 @@ on:
release:
types: [published]
jobs:
build-test:
name: Run tests.
runs-on: ubuntu-latest

## todo later - run deploy.

steps:
- uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- uses: php-actions/composer@v6

- uses: php-actions/phpunit@v3
with:
version: 7.5.20
php_version: 7.3
bootstrap: tests/bootstrap.php
configuration: phpunit.xml

tag:
name: New release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- name: Install composer
uses: php-actions/composer@v6
with:
php_extensions: json
version: 2
dev: no
- run: composer global config --no-plugins allow-plugins.wpify/scoper true
- run: composer global require wpify/scoper
- run: sudo chown -R $USER:$USER $GITHUB_WORKSPACE/vendor
- run: composer install --no-dev --optimize-autoloader

- name: WordPress Plugin Deploy
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on: [push]

jobs:
build-test:
runs-on: ubuntu-latest

## todo later - run deploy.

steps:
- uses: actions/checkout@v3

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- uses: php-actions/composer@v6

- uses: php-actions/phpunit@v3
with:
version: 7.5.20
php_version: 7.3
bootstrap: tests/bootstrap.php
configuration: phpunit.xml
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
node_modules
working_data
.vscode
.DS_Store
.DS_Store
vendor
.phpunit.cache
deps
.phpunit.result.cache
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Kybernaut IC DIC (WordPress plugin)

[![plugin version](https://img.shields.io/wordpress/plugin/v/woolab-ic-dic.svg)](https://wordpress.org/plugins/woolab-ic-dic)
[![plugin version](https://img.shields.io/wordpress/plugin/v/woolab-ic-dic.svg)](https://wordpress.org/plugins/woolab-ic-dic) [![CI](https://github.com/vyskoczilova/kybernaut-ic-dic/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/vyskoczilova/kybernaut-ic-dic/actions/workflows/phpunit.yml)

Adds Czech Company & VAT numbers (IČO & DIČ) to WooCommerce billing fields and verifies if data are correct.
Download here: https://wordpress.org/plugins/woolab-ic-dic/

**Note:** `vendor` folder is tracked because off PHP 7.1 compatibility which is unoficially still working on ibericode/vat package, but the minimum requirement was bumped in December 2020. Plan to bump accordingly soon.

## Unreleased changes

* none
Expand Down Expand Up @@ -46,6 +44,8 @@ If you need to set it up in your theme or plugin, you can use following filters

add_filter( 'woolab_icdic_vies_check', '__return_true' );

add_filter( 'woolab_icdic_ignore_check_fail', '__return_true' );

add_filter( 'woolab_icdic_vat_exempt_enabled', function(){
return "no"; // or "yes"
} );
Expand All @@ -69,3 +69,4 @@ By default, if you edit order details, user profile is not touched. If you want
## Credits

* 10up and their [WordPress.org Plugin Deploy](https://github.com/10up/action-wordpress-plugin-deploy) and [WordPress.org Plugin Readme/Assets Update](https://github.com/10up/action-wordpress-plugin-asset-update) Github Actions
* [ibericode/vat](https://github.com/ibericode/vat)
25 changes: 22 additions & 3 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@
var vies_check = $('#woolab_icdic_vies_check');

if (ares_check.length) {
enableActive(ares_check);
enableAresActive(ares_check);
enableIgnoreCheckFailActive(ares_check, vies_check);
ares_check.change(function () {
enableActive(ares_check);
enableAresActive(ares_check);
enableIgnoreCheckFailActive(ares_check, vies_check);
});
}

if (vies_check.length) {
enableIgnoreCheckFailActive(ares_check, vies_check);
vies_check.change(function () {
enableIgnoreCheckFailActive(ares_check, vies_check);
});
}

Expand All @@ -31,7 +40,7 @@
}
});

function enableActive(ares_check) {
function enableAresActive(ares_check) {
var active = $('#woolab_icdic_ares_fill');

if (ares_check.prop("checked") == true) {
Expand All @@ -40,4 +49,14 @@
active.prop("disabled", true).prop("checked", false);
}
}

function enableIgnoreCheckFailActive(ares_check, vies_check) {
var checkbox = $('#woolab_icdic_ignore_check_fail');

if (ares_check.prop('checked') || vies_check.prop('checked')) {
checkbox.prop('disabled', false);
} else {
checkbox.prop('disabled', true).prop('checked', false);
}
}
})(jQuery);
2 changes: 1 addition & 1 deletion assets/js/admin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 49 additions & 7 deletions assets/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,44 @@

if (woolab.ares_fill) {
// Compatibility with Fluid Checkout for WooCommerce – Lite
// https://wordpress.org/support/topic/compatibility-with-kybernaut-ico-dic-plugin/
if ($('#billing_same_as_shipping') && $('#billing_same_as_shipping').is(':checked')) {
$('#billing_same_as_shipping').click();
// Check whether the CollapsibleBlock library is available
if (window.CollapsibleBlock) {
// Set billing address as different from shipping address
var fc_billing_same_as_shipping_field = document.querySelector('#billing_same_as_shipping');
fc_billing_same_as_shipping_field.checked = false; // Expand the billing address fields

var fc_billing_address_fields_wrapper = document.querySelector('#woocommerce-billing-fields__field-wrapper');

if (fc_billing_address_fields_wrapper) {
CollapsibleBlock.expand(fc_billing_address_fields_wrapper);
} // Get company field toggle and content elements


var fc_billing_company_toggle = document.querySelector('#fc-expansible-form-section__toggle-plus--billing_company');
var fc_billing_company_content = document.querySelector('#fc-expansible-form-section__content--billing_company'); // Expand the billing company field

if (fc_billing_company_toggle) {
CollapsibleBlock.collapse(fc_billing_company_toggle);
}

if (fc_billing_company_content) {
CollapsibleBlock.expand(fc_billing_company_content);
} // Get dic field toggle and content elements


var fc_billing_dic_toggle = document.querySelector('#fc-expansible-form-section__toggle-plus--billing_dic');
var fc_billing_dic_content = document.querySelector('#fc-expansible-form-section__content--billing_dic'); // Expand the billing dic field

if (fc_billing_dic_toggle) {
CollapsibleBlock.collapse(fc_billing_dic_toggle);
}

if (fc_billing_dic_content) {
CollapsibleBlock.expand(fc_billing_dic_content);
}
}
} // Update values


Expand All @@ -255,7 +291,10 @@
}

ares_remove_disabled_from_input();
ico_class.append('<span role="alert" class="woolab-ic-dic-tip error">' + data.error + '</span>');

if (!data.internal_error || !woolab.ignore_check_fail) {
ico_class.append('<span role="alert" class="woolab-ic-dic-tip error">' + data.error + '</span>');
}
}
} else {
ares_error(ico_class);
Expand Down Expand Up @@ -290,11 +329,14 @@

function ares_error(ico_class) {
if (woolab.ares_fill) {
$('#billing_company').val('');
$('#billing_dic').val('');
$('#billing_postcode').val('');
$('#billing_city').val('');
$('#billing_address_1').val('');
if (!woolab.ignore_check_fail) {
$('#billing_company').val('');
$('#billing_dic').val('');
$('#billing_postcode').val('');
$('#billing_city').val('');
$('#billing_address_1').val('');
}

ares_remove_disabled_from_input();
}

Expand Down
Loading

0 comments on commit 8baf2bd

Please sign in to comment.