From b8fc4ffd2930fe7174cdb31413ebaff959b90221 Mon Sep 17 00:00:00 2001 From: KrzysztofBorbis Date: Tue, 30 Jun 2015 09:41:18 +0200 Subject: [PATCH] fix eu vat fields --- admin/write-panels/order-data-save.php | 6 ++++++ assets/js/write-panels.js | 3 ++- classes/jigoshop_user.class.php | 3 ++- shortcodes/my_account.php | 7 +++++++ templates/shortcode/my_account/my_account.php | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/admin/write-panels/order-data-save.php b/admin/write-panels/order-data-save.php index a818c458..e5389555 100755 --- a/admin/write-panels/order-data-save.php +++ b/admin/write-panels/order-data-save.php @@ -35,6 +35,7 @@ function jigoshop_process_shop_order_meta($post_id) 'billing_first_name', 'billing_last_name', 'billing_company', + 'billing_euvatno', 'billing_address_1', 'billing_address_2', 'billing_city', @@ -79,6 +80,11 @@ function jigoshop_process_shop_order_meta($post_id) } } + //Check EUVAT Field + if (!empty($data['billing_euvatno']) && !empty($data['billing_country'])) { + $data['billing_euvatno'] = str_replace(' ', '', $data['billing_euvatno']); + } + //run stripslashes on all valid fields foreach ($order_fields as $field_name) { if (isset($_POST[$field_name])) { diff --git a/assets/js/write-panels.js b/assets/js/write-panels.js index 55d3f767..967b4cf1 100755 --- a/assets/js/write-panels.js +++ b/assets/js/write-panels.js @@ -266,13 +266,14 @@ jQuery(function($) { $("#order_product_select").css('border-color', 'red'); } }); - + $( "#customer_user" ).change(function() { if($(this).val() > 0) { $.getJSON("?post_type=shop_order&load_address=" + $(this).val(), function(data) { $("#billing_first_name").val(data.billing_first_name); $("#billing_last_name").val(data.billing_last_name); $("#billing_company").val(data.billing_company); + $("#billing_euvatno").val(data.billing_euvatno); $("#billing_address_1").val(data.billing_address_1); $("#billing_address_2").val(data.billing_address_2); $("#billing_city").val(data.billing_city); diff --git a/classes/jigoshop_user.class.php b/classes/jigoshop_user.class.php index d2caed60..9fae8563 100644 --- a/classes/jigoshop_user.class.php +++ b/classes/jigoshop_user.class.php @@ -128,6 +128,7 @@ public function getBillingAddress2() /** * @return string + * */ public function getBillingCity() { @@ -294,7 +295,7 @@ public function save() update_user_meta($this->id, 'billing_first_name', $this->billing_first_name); update_user_meta($this->id, 'billing_last_name', $this->billing_last_name); update_user_meta($this->id, 'billing_company', $this->billing_company); - update_user_meta($this->id, 'billing_euvatno', $this->billing_euvatno); + update_user_meta($this->id, 'billing_euvatno', str_replace(' ', '', $this->billing_euvatno)); update_user_meta($this->id, 'billing_address_1', $this->billing_address_1); update_user_meta($this->id, 'billing_address_2', $this->billing_address_2); update_user_meta($this->id, 'billing_city', $this->billing_city); diff --git a/shortcodes/my_account.php b/shortcodes/my_account.php index b7f20f93..792d25ba 100755 --- a/shortcodes/my_account.php +++ b/shortcodes/my_account.php @@ -78,6 +78,13 @@ function jigoshop_get_address_fields($load_address, $user_id) 'class' => array('columned full-row clear'), 'value' => get_user_meta($user_id, $load_address.'_company_name', true) ), + array( + 'name' => $load_address.'_euvatno', + 'label' => __('EU VAT Number', 'jigoshop'), + 'placeholder' => __('EU VAT Number', 'jigoshop'), + 'class' => array('columned full-row clear'), + 'value' => get_user_meta($user_id, $load_address.'_euvatno', true) + ), array( 'name' => $load_address.'_address_1', 'label' => __('Address', 'jigoshop'), diff --git a/templates/shortcode/my_account/my_account.php b/templates/shortcode/my_account/my_account.php index f68a5d9f..7071e6e4 100755 --- a/templates/shortcode/my_account/my_account.php +++ b/templates/shortcode/my_account/my_account.php @@ -88,6 +88,7 @@ $address = array( get_user_meta(get_current_user_id(), 'billing_first_name', true).' '.get_user_meta(get_current_user_id(), 'billing_last_name', true), get_user_meta(get_current_user_id(), 'billing_company', true), + get_user_meta(get_current_user_id(), 'billing_euvatno', true), get_user_meta(get_current_user_id(), 'billing_address_1', true), get_user_meta(get_current_user_id(), 'billing_address_2', true), get_user_meta(get_current_user_id(), 'billing_city', true),