api_client = $api_client;
add_filter( 'woocommerce_debug_tools', array( $this, 'woocommerce_debug_tools' ) );
}
function woocommerce_debug_tools( $tools ) {
$tools['test_wcc_connection'] = array(
'name' => __( 'Test your WooCommerce Tax connection', 'woocommerce-services' ),
'button' => __( 'Test Connection', 'woocommerce-services' ),
'desc' => __( 'This will test your WooCommerce Tax connection to ensure everything is working correctly', 'woocommerce-services' ),
'callback' => array( $this, 'test_connection' ),
);
/**
* Only show this tool for stores not based in California
*/
if ( 'CA' !== WC()->countries->get_base_state() ) {
$tools['delete_ca_taxes'] = array(
'name' => __( 'Delete California tax rates', 'woocommerce-services' ),
'button' => __( 'Delete CA tax rates', 'woocommerce-services' ),
'desc' => sprintf( '%1$s %2$s %3$s %4$s %5$s', __( 'Note:', 'woocommerce-services' ), __( 'This option will delete ALL of your "CA" tax rates where the tax name ends with " Tax" (case insensitive).', 'woocommerce-services' ), '
', __( 'A backup CSV of all existing tax rates will be made before the deletion process runs.', 'woocommerce-services' ), __( 'Additional information.', 'woocommerce-services' ) ),
'callback' => array( $this, 'delete_california_tax_rates' ),
);
}
/**
* Only show when object cache is disabled - the tool doesn't work when object cache is enabled.
*/
if ( ! wp_using_ext_object_cache() ) {
$tools['delete_cached_tax_server_responses'] = array(
'name' => __( 'Delete WooCommerce Tax cached tax rate responses', 'woocommerce-services' ),
'button' => __( 'Delete cached Tax transients', 'woocommerce-services' ),
'desc' => __( 'Deletes the all the transients in your database that represent cached Tax Rates responses', 'woocommerce-services' ),
'callback' => array( $this, 'delete_cached_tax_server_responses' ),
);
}
return $tools;
}
function test_connection() {
$test_request = $this->api_client->auth_test();
if ( $test_request && ! is_wp_error( $test_request ) && $test_request->authorized ) {
echo '
' . esc_html__( 'Your site is successfully communicating to the WooCommerce Tax API.', 'woocommerce-services' ) . '
' . esc_html__( 'ERROR: Your site has a problem connecting to the WooCommerce Tax API. Please make sure your WordPress.com connection is working.', 'woocommerce-services' ) . '
'; echo esc_html__( 'ERROR: The "CA" tax rate deletion process was cancelled because the existing tax rates could not be backed up.', 'woocommerce-services' ); echo '
'; echo esc_html__( 'No "CA" tax rates were found.', 'woocommerce-services' ); echo '
'; printf( esc_html__( 'Successfully deleted %1$d rows from the database.', 'woocommerce-services' ), intval( $deleted_count ) ); echo '
'; printf( esc_html__( 'Successfully deleted %1$d transients from the database.', 'woocommerce-services' ), intval( $deleted_count ) ); echo '