Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Commit

Permalink
fix eu vat fields
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofBorbis committed Jun 30, 2015
1 parent 0c676e9 commit b8fc4ff
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions admin/write-panels/order-data-save.php
Expand Up @@ -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',
Expand Down Expand Up @@ -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])) {
Expand Down
3 changes: 2 additions & 1 deletion assets/js/write-panels.js
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion classes/jigoshop_user.class.php
Expand Up @@ -128,6 +128,7 @@ public function getBillingAddress2()

/**
* @return string
*
*/
public function getBillingCity()
{
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions shortcodes/my_account.php
Expand Up @@ -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'),
Expand Down
1 change: 1 addition & 0 deletions templates/shortcode/my_account/my_account.php
Expand Up @@ -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),
Expand Down

0 comments on commit b8fc4ff

Please sign in to comment.