Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
})
.done(function (resp) {
if (resp.success) {
if (resp.data.connection_id) {
jQuery('#woocommerce_wootax_tc_connection_id').val(resp.data.connection_id);
jQuery('.tc-connection-link').attr('href', 'https://app.taxcloud.com/go/integrations/' + resp.data.connection_id + '#settings');
}
alert(data.strings.settings_valid);
} else {
alert(data.strings.verify_failed + ' ' + resp.data + '.');
Expand Down Expand Up @@ -96,6 +100,10 @@
if (resp.success) {
var integrationMode = resp.data.integration_mode;
jQuery('#woocommerce_wootax_integration_mode').val(integrationMode);
if (resp.data.connection_id) {
jQuery('#woocommerce_wootax_tc_connection_id').val(resp.data.connection_id);
jQuery('.tc-connection-link').attr('href', 'https://app.taxcloud.com/go/integrations/' + resp.data.connection_id + '#settings');
}
alert(data.strings.mode_refreshed + integrationMode);
} else {
alert(data.strings.went_wrong);
Expand Down
19 changes: 15 additions & 4 deletions includes/admin/class-sst-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,14 @@ class="wc-enhanced-select origin-address-select" multiple="multiple"
<div class="notice notice-warning inline sst-settings-notice">
<p>
<?php
$locations_url = 'https://app.taxcloud.com/go/locations';
echo wp_kses_post(
__(
'Oops! It appears there are no addresses in your TaxCloud account. Please add at least one address on the <a href="https://app.taxcloud.com/go/locations" target="_blank">Locations</a> page in TaxCloud and then save your settings to refresh the address list.',
'simple-sales-tax'
sprintf(
__(
'Oops! It appears there are no addresses in your TaxCloud account. Please add at least one address on the <a href="%s" target="_blank" class="tc-locations-link">Locations</a> page in TaxCloud and then save your settings to refresh the address list.',
'simple-sales-tax'
),
esc_url( $locations_url )
)
);
?>
Expand Down Expand Up @@ -459,7 +463,14 @@ public function generate_integration_mode_html( $key, $data ) {
</div>
<div class="description">
<p>
<a href="https://app.taxcloud.com/go/integrations" target="_blank">
<?php
$connection_id = SST_Settings::get( 'tc_connection_id' );
$integration_url = 'https://app.taxcloud.com/go/integrations';
if ( ! empty( $connection_id ) ) {
$integration_url .= '/' . $connection_id . '#settings';
}
?>
<a href="<?php echo esc_url( $integration_url ); ?>" target="_blank" class="tc-connection-link">
<?php echo wp_kses_post( __( 'Configure in TaxCloud', 'simple-sales-tax' ) ); ?>
</a>
</p>
Expand Down
14 changes: 10 additions & 4 deletions includes/class-sst-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ public static function verify_taxcloud() {
TaxCloud()->Ping( new TaxCloud\Request\Ping( $taxcloud_id, $taxcloud_key ) );

// Ping successful, update data mover settings
$data_mover_settings = SST_TaxCloud_V3_API::update_data_mover_settings( $taxcloud_id, $taxcloud_key );
SST_TaxCloud_V3_API::update_data_mover_settings( $taxcloud_id, $taxcloud_key );

wp_send_json_success();
wp_send_json_success( array(
'connection_id' => SST_Settings::get( 'tc_connection_id' ),
) );
} catch ( Exception $ex ) {
wp_send_json_error( $ex->getMessage() );
}
Expand Down Expand Up @@ -370,11 +372,15 @@ public static function update_data_mover() {
SST_TaxCloud_V3_API::update_data_mover_settings();

// Get data mover settings
$data_mover = SST_Settings::get( 'data_mover', false );
$data_mover = SST_Settings::get( 'data_mover', false );
$integration_mode = $data_mover == false ? __( 'Real Time', 'simple-sales-tax' ) : __( 'Data Import', 'simple-sales-tax' );

// Response
wp_send_json_success( [ 'integration_mode' => $integration_mode, 'data_mover' => $data_mover ] );
wp_send_json_success( [
'integration_mode' => $integration_mode,
'data_mover' => $data_mover,
'connection_id' => SST_Settings::get( 'tc_connection_id' ),
] );
}

}
Expand Down
14 changes: 14 additions & 0 deletions includes/class-sst-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ public static function get_form_fields() {
'desc_tip' => true,
'default' => '',
),
// 'tc_connection_id' => array(
// 'title' => __( 'TaxCloud Connection ID', 'simple-sales-tax' ),
// 'type' => 'text',
// 'description' => __(
// 'TaxCloud Connection ID (URL ID). Automatically retrieved.',
// 'simple-sales-tax'
// ),
// 'desc_tip' => true,
// 'default' => '',
// 'class' => 'hidden',
// 'custom_attributes' => array(
// 'readonly' => 'readonly',
// ),
// ),
'verify_settings' => array(
'title' => __( 'Verify TaxCloud Settings', 'simple-sales-tax' ),
'label' => __( 'Verify Settings', 'simple-sales-tax' ),
Expand Down
4 changes: 4 additions & 0 deletions includes/class-sst-taxcloud-v3-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ public static function get_auth_token( $api_login_id, $api_key ) {
return new WP_Error( 'sst_v3_auth_error', 'No access token received from TaxCloud v3 API.' );
}

if ( ! empty( $data['connection_id'] ) ) {
SST_Settings::set( 'tc_connection_id', $data['connection_id'] );
}

return $data['access_token'];
}

Expand Down
4 changes: 4 additions & 0 deletions includes/v3/RequestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public function get_auth_token( $api_login_id = null, $api_key = null ) {
return new WP_Error( 'sst_v3_auth_error', 'No access token received from TaxCloud v3 API.' );
}

if ( ! empty( $data['connection_id'] ) ) {
SST_Settings::set( 'tc_connection_id', $data['connection_id'] );
}

return $data['access_token'];
}

Expand Down
Loading