Skip to content

Instantly share code, notes, and snippets.

@Yame-
Last active January 21, 2017 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yame-/5b3d8c265e6d70f7dd4a0545d5439e09 to your computer and use it in GitHub Desktop.
Save Yame-/5b3d8c265e6d70f7dd4a0545d5439e09 to your computer and use it in GitHub Desktop.
WooCommerce EU VAT plugin relies on the Europa VIES service. But when it's down your customers get an annoying error and the order cannot be completed. This snippet provides a fix.
<?pp
/*
!!! Just a quick warning, if WooCommerce updates its plugin these changes will be gone !!!
1) Find class-wc-eu-vat-number.php, it's located under wp-contents/plugins/woocommerce-eu-vat-number/includes
2) Skim trough until you find line 160
3) Do the following
*/
/* On line 160 you'll find this line of code */
return new WP_Error( 'api', sprintf( __( 'VAT API Error: %s', 'woocommerce-eu-vat-number' ), $response->get_error_message() ) );
/* Replace line 160 with the following */
if( strstr($response->get_error_message(), 'cURL error 28') !== false ){
// fail silently and let order go through
return true;
} else {
return new WP_Error( 'api', sprintf( __( 'VAT API Error: %s', 'woocommerce-eu-vat-number' ), $response->get_error_message() ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment