diff --git a/docker-compose.yml b/docker-compose.yml index 3001874..fa18833 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: - 8888:80 environment: SPIFF_API_BASE: 'http://host.docker.internal:8080' + SPIFF_API_US_BASE: 'http://host.docker.internal:8080' WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: exampleuser WORDPRESS_DB_PASSWORD: examplepass diff --git a/replace-env-vars.py b/replace-env-vars.py index ebcc8d7..5801e55 100644 --- a/replace-env-vars.py +++ b/replace-env-vars.py @@ -10,5 +10,10 @@ print('define("SPIFF_API_BASE", "https://api.spiff.com.au");') else: print('define("SPIFF_API_BASE", "https://api.app.dev.spiff.com.au");') + elif line.startswith('define("SPIFF_API_US_BASE"'): + if (env == 'production'): + print('define("SPIFF_API_US_BASE", "https://api.us.spiffcommerce.com");') + else: + print('define("SPIFF_API_US_BASE", "https://api.app.dev.spiff.com.au");') else: print(line, end="") diff --git a/spiff-connect/spiff-connect.php b/spiff-connect/spiff-connect.php index 33813bb..c7ca820 100644 --- a/spiff-connect/spiff-connect.php +++ b/spiff-connect/spiff-connect.php @@ -2,7 +2,6 @@ /* Plugin Name: Spiff Connect Plugin URI: http://spiff3d.com -Version: 2.0.67 Description: Connect your WooCommerce store to Spiff and allow customers access to Spiff Workflows to personalize their products. Author: Spiff Pty. Ltd. License: GPL3 @@ -11,11 +10,20 @@ require plugin_dir_path(__FILE__) . 'includes/spiff-connect-requests.php'; define("SPIFF_API_BASE", getenv("SPIFF_API_BASE")); +define("SPIFF_API_US_BASE", getenv("SPIFF_API_US_BASE")); define("SPIFF_API_INSTALLS_PATH", "/api/installs"); define("SPIFF_API_ORDERS_PATH", "/api/v2/orders"); define("SPIFF_API_TRANSACTIONS_PATH", "/api/transactions"); define("SPIFF_GRAPHQL_PATH", "/graphql"); +// Get base API URL based on infrastructure choice. +function spiff_get_base_api_url() { + if (get_option('spiff_infrastructure') === "US") { + return SPIFF_API_US_BASE; + } + return SPIFF_API_BASE; +} + /** * Activation hook. */ @@ -49,7 +57,8 @@ function spiff_activation_hook() { $headers = array( 'Content-Type' => 'application/json', ); - wp_remote_post(SPIFF_API_BASE . SPIFF_API_INSTALLS_PATH, array( + // This is expected to always be Australia because the value hasn't been set yet. + wp_remote_post(spiff_get_base_api_url() . SPIFF_API_INSTALLS_PATH, array( 'body' => $body, 'headers' => $headers )); @@ -72,6 +81,7 @@ function spiff_register_admin_settings() { register_setting('spiff-settings-group', 'spiff_api_key'); register_setting('spiff-settings-group', 'spiff_api_secret'); register_setting('spiff-settings-group', 'spiff_application_key'); + register_setting('spiff-settings-group', 'spiff_infrastructure'); register_setting('spiff-settings-group', 'spiff_show_customer_selections_in_cart'); register_setting('spiff-settings-group', 'spiff_show_preview_images_in_cart'); @@ -130,6 +140,16 @@ function spiff_admin_menu_html() {
Ensure that you are using the Spiff infrastructure that your account was created against.
+Infrastructure | ++ |
---|