Skip to content

Commit

Permalink
Add AP to region selector (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
rheber authored Jul 10, 2024
1 parent d7b16d4 commit fca52f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
- 8888:80
environment:
SPIFF_API_BASE: 'http://host.docker.internal:8080'
SPIFF_API_AP_BASE: 'http://host.docker.internal:8080'
SPIFF_API_US_BASE: 'http://host.docker.internal:8080'
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
Expand Down
9 changes: 7 additions & 2 deletions replace-env-vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@
if (env == 'production'):
print('define("SPIFF_API_BASE", "https://api.spiff.com.au");')
else:
print('define("SPIFF_API_BASE", "https://api.app.dev.spiff.com.au");')
print('define("SPIFF_API_BASE", "https://api.aumelbdev.spiffcommerce.com");')
elif line.startswith('define("SPIFF_API_AP_BASE"'):
if (env == 'production'):
print('define("SPIFF_API_AP_BASE", "https://api.au.spiffcommerce.com");')
else:
print('define("SPIFF_API_AP_BASE", "https://api.aumelbdev.spiffcommerce.com");')
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");')
print('define("SPIFF_API_US_BASE", "https://api.aumelbdev.spiffcommerce.com");')
else:
print(line, end="")
9 changes: 7 additions & 2 deletions spiff-connect/spiff-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

require plugin_dir_path(__FILE__) . 'includes/spiff-connect-requests.php';

define("SPIFF_API_BASE", getenv("SPIFF_API_BASE"));
define("SPIFF_API_BASE", getenv("SPIFF_API_BASE")); // Legacy AU
define("SPIFF_API_AP_BASE", getenv("SPIFF_API_AP_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");
Expand All @@ -18,6 +19,9 @@

// Get base API URL based on infrastructure choice.
function spiff_get_base_api_url() {
if (get_option('spiff_infrastructure') === "AP") {
return SPIFF_API_AP_BASE;
}
if (get_option('spiff_infrastructure') === "US") {
return SPIFF_API_US_BASE;
}
Expand Down Expand Up @@ -145,7 +149,8 @@ function spiff_admin_menu_html() {
<tr valign="top">
<th scope="row">Infrastructure</th>
<td><select name="spiff_infrastructure">
<option value="AU" <?php echo selected("AU", get_option("spiff_infrastructure") ?? "AU", false); ?>>Australia</option>
<option value="AP" <?php echo selected("AP", get_option("spiff_infrastructure"), false); ?>>Australia</option>
<option value="AU" <?php echo selected("AU", get_option("spiff_infrastructure") ?? "AU", false); ?>>Australia (Legacy)</option>
<option value="US" <?php echo selected("US", get_option("spiff_infrastructure"), false); ?>>United States</option>
</select></td>
</tr>
Expand Down

0 comments on commit fca52f6

Please sign in to comment.