Skip to content

Commit

Permalink
add support for WC 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed Apr 5, 2017
1 parent 3b6163c commit 9747604
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@ Download here: https://wordpress.org/plugins/woolab-ic-dic/
## Description
= CZ =

* podpora WooCommerce 3.0
* přidává **políčka pro IČO a DIČ** do fakturační adresy WooCommerce
* pokud je IČO anebo DIČ zadáno a je fakturováno do ČR, tak **ověří jejich správnost** (algoritmem)
* **kompatibilita s pluginem [WooCommerce PDF Invoices & Packing Slips](https://cs.wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)**
* **kompatibilita s pluginy Vladislava Musílka (Toret)** - Woo Doprava, Woo GoPay apod.
* přístup k editaci IČO a DIČ v rámci frontendu "Můj účet"
* možnost editace IČO a DIČ i z administrace:
* `Uživatelé -> Jan Novák (Upravit) -> Fakturační adresa zákazníka`
* `E-shop-WooCommerce -> Objednávky -> Objednávka (zobrazit(upravit)) -> Fakturační údaje (editace)`

= EN =

* supports WooCommerce 3.0
* adds **Czech IČO - Company number, DIČ - VAT number** too WooCommerce
* **validates its value** if added and billing country is set to CZ
* **compatible with [WooCommerce PDF Invoices & Packing Slips](https://cs.wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)**
* **compatible with plugins of Vladislav Musilek (Toret)** - Woo Doprava, Woo GoPay etc.
* possible edit of IČO and DIČ at "My Account" page.
* support for editing IČO, DIČ in the administration (backend):
* `Users -> Joe Doe (Edit) -> Billing address of the customer`
* `E-shop-WooCommerce -> Orders-> Order (show(edit)) -> Billing Information (edit)`
Expand All @@ -41,6 +45,10 @@ Download here: https://wordpress.org/plugins/woolab-ic-dic/

## Changelog

= 1.1.0 = (2017-04-05) =
* CZ - Opraveno "Order properties should not be accessed directly." Podpora WooCommerce 3.0.
* EN - Fixed "Order properties should not be accessed directly." Added support for WooCommerce 3.0.

= 1.0.3 (2017-02-1) =
* CZ - Opraveno zobrazování polí v "Můj účet" (frontendová editace účtu zákazníkem).
* CZ - Podpora pro WooCommerce PDF Invoices & Packing Slips.
Expand Down
34 changes: 32 additions & 2 deletions includes/filters-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,19 @@ function woolab_icdic_formatted_address_replacements( $replace, $args) {
}

function woolab_icdic_order_formatted_billing_address($address, $order) {
return $address += array(

if ( version_compare( WC_VERSION, '2.7', '<' )) {
return $address += array(
'billing_ic' => $order->billing_ic,
'billing_dic' => $order->billing_dic);
'billing_dic' => $order->billing_dic
);
} else {
return $address += array(
'billing_ic' => $order->get_meta('_billing_ic'),
'billing_dic' => $order->get_meta('_billing_dic')
);
}

}

// admin
Expand Down Expand Up @@ -130,3 +140,23 @@ function woolab_icdic_admin_billing_fields ($fields) {
) );

}

// TO DO
// Fix edit fields in admin
// https://www.jnorton.co.uk/woocommerce-custom-fields
// Support for < 2.7
/* add_filter( 'woocommerce_found_customer_details', 'woolab_icdic_custom_fields_to_admin_order', 10, 1 );
function woolab_icdic_custom_fields_to_admin_order($customer_data){
$user_id = $_POST['user_id'];
$customer_data['billing_ic'] = get_user_meta( $user_id, 'billing_ic', true );
$customer_data['billing_dic'] = get_user_meta( $user_id, 'billing_dic', true );
return $customer_data;
}
// Doesnt work for 3.0
//apply_filters( 'woocommerce_ajax_get_customer_details', $data, $customer, $user_id );
add_filter( 'woocommerce_ajax_get_customer_details', 'woolab_icdic_ajax_get_customer_details', 10, 3 );
function woolab_icdic_ajax_get_customer_details($data, $customer, $user_id){
$data['billing_ic'] = get_user_meta( $user_id, '_billing_ic', true );
$data['billing_dic'] = get_user_meta( $user_id, '_billing_ic', true );
return $data;
}*/
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: vyskoczilova
Tags: woocommerce, DIČ, IČO, IČ, IČ DPH, česky, česká, české, cz, Czech, zobrazení, úprava, VAT, number, Company, identification, tax, eshop, e-shop, ecommerce, e-commerce, commerce, woothemes, wordpress woocommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, additional, fields, variable, download, downloadable, digital, inventory, fakturační, billing, shipping, adresa, address, woo commerce, order, objednávka, admin, backend
Requires at least: 4.0
Tested up to: 4.7.2
Tested up to: 4.7.3
Stable tag: /trunk
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -12,10 +12,12 @@ Přidá IČO a DIČ do formuláře s fakturační adresou ve WooCommerce a rovno
== Description ==
= CZ =

* podpora WooCommerce 3.0
* přidává **políčka pro IČO a DIČ** do fakturační adresy WooCommerce
* pokud je IČO anebo DIČ zadáno a je fakturováno do ČR, tak **ověří jejich správnost** (algoritmem)
* **kompatibilita s pluginem [WooCommerce PDF Invoices & Packing Slips](https://cs.wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)**
* **kompatibilita s pluginy Vladislava Musílka (Toret)** - Woo Doprava, Woo GoPay apod.
* přístup k editaci IČO a DIČ v rámci frontendu "Můj účet"
* možnost editace IČO a DIČ i z administrace:
* `Uživatelé -> Jan Novák (Upravit) -> Fakturační adresa zákazníka`
* `E-shop-WooCommerce -> Objednávky -> Objednávka (zobrazit(upravit)) -> Fakturační údaje (editace)`
Expand All @@ -24,10 +26,12 @@ Pokud mi chcete pomoci, přidejte se na [GitHubu](https://github.com/vyskoczilov

= EN =

* supports WooCommerce 3.0
* adds **Czech IČO - Company number, DIČ - VAT number** too WooCommerce
* **validates its value** if added and billing country is set to CZ
* **compatible with [WooCommerce PDF Invoices & Packing Slips](https://cs.wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/)**
* **compatible with plugins of Vladislav Musilek (Toret)** - Woo Doprava, Woo GoPay etc.
* possible edit of IČO and DIČ at "My Account" page.
* support for editing IČO, DIČ in the administration (backend):
* `Users -> Joe Doe (Edit) -> Billing address of the customer`
* `E-shop-WooCommerce -> Orders-> Order (show(edit)) -> Billing Information (edit)`
Expand All @@ -53,6 +57,10 @@ If you want to help, join the [Github](https://github.com/vyskoczilova/kybernaut

== Changelog ==

= 1.1.0 = (2017-04-05) =
* CZ - Opraveno "Order properties should not be accessed directly." Podpora WooCommerce 3.0.
* EN - Fixed "Order properties should not be accessed directly." Added support for WooCommerce 3.0.

= 1.0.3 (2017-02-1) =
* CZ - Opraveno zobrazování polí v "Můj účet" (frontendová editace účtu zákazníkem).
* CZ - Podpora pro WooCommerce PDF Invoices & Packing Slips.
Expand Down
9 changes: 4 additions & 5 deletions woolab-ic-dic.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Kybernaut IC DIC
* Plugin URI: http://kybernaut.cz/pluginy/kybernaut-ic-dic
* Description: Přidá IČO a DIČ do formuláře s fakturační adresou ve WooCommerce a rovnou ověří, jestli jsou zadané hodnoty skutečné.
* Version: 1.0.3
* Version: 1.1.0
* Author: Karolína Vyskočilová
* Author URI: http://www.kybernaut.cz
* Text Domain: woolab-ic-dic
Expand All @@ -12,8 +12,6 @@
* Domain Path: /languages
*/



// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
Expand Down Expand Up @@ -64,7 +62,8 @@ function woolab_icdic_plugin_admin_notice() {
add_filter( 'woocommerce_customer_meta_fields', 'woolab_icdic_customer_meta_fields' );
add_filter( 'woocommerce_admin_billing_fields', 'woolab_icdic_admin_billing_fields' );
add_filter( 'plugin_action_links_woolab_ic_dic', 'woolab_icdic_plugin_action_links' );

//add_filter( 'woocommerce_billing_fields' , 'woolab_icdic_checkout_fields' , 10, 2 );?
}
}
add_action( 'plugins_loaded', 'woolab_icdic_init' );
add_action( 'plugins_loaded', 'woolab_icdic_init' );

0 comments on commit 9747604

Please sign in to comment.