File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,15 @@ public function _log( $message ) {
181
181
$ this ->logger ->log ( $ formatted_message , 'WCS Tax ' );
182
182
}
183
183
184
+ /**
185
+ * @param $message
186
+ */
187
+ public function _error ( $ message ) {
188
+ $ formatted_message = is_scalar ( $ message ) ? $ message : json_encode ( $ message );
189
+
190
+ $ this ->logger ->error ( $ formatted_message , 'WCS Tax ' );
191
+ }
192
+
184
193
/**
185
194
* Wrapper to avoid calling calculate_totals() for admin carts.
186
195
*
@@ -685,11 +694,11 @@ public function smartcalcs_request( $json ) {
685
694
) );
686
695
687
696
if ( is_wp_error ( $ response ) ) {
688
- return new WP_Error ( 'request ' , __ ( ' There was an error retrieving the tax rates. Please check your server configuration. ' ) );
697
+ $ this -> _error ( 'Error retrieving the tax rates. Received ( ' . $ response -> get_error_code () . ' ): ' . $ response -> get_error_message ( ) );
689
698
} elseif ( 200 == $ response ['response ' ]['code ' ] ) {
690
699
return $ response ;
691
700
} else {
692
- $ this ->_log ( 'Received ( ' . $ response ['response ' ]['code ' ] . '): ' . $ response ['body ' ] );
701
+ $ this ->_error ( 'Error retrieving the tax rates. Received ( ' . $ response ['response ' ]['code ' ] . '): ' . $ response ['body ' ] );
693
702
}
694
703
}
695
704
@@ -847,4 +856,4 @@ public function backup_existing_tax_rates() {
847
856
$ wpdb ->query ( 'TRUNCATE ' . $ wpdb ->prefix . 'woocommerce_tax_rates ' );
848
857
$ wpdb ->query ( 'TRUNCATE ' . $ wpdb ->prefix . 'woocommerce_tax_rate_locations ' );
849
858
}
850
- }
859
+ }
You can’t perform that action at this time.
0 commit comments