Plugin Directory

Changeset 3808150


Ignore:
Timestamp:
11/17/2026 09:11:18 PM (less than one hour ago)
Author:
artdotedmonton
Message:

Release 1.10.1: preserve regional Canvas account endpoints and document connection setup

Location:
canvas-prints-ltd-print-on-demand-for-woocommerce
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • canvas-prints-ltd-print-on-demand-for-woocommerce/tags/1.10.1/canvas-printing-fulfillment.php

    r3667824 r3808150  
    44 * Plugin URI: https://www.canvasprintscalgary.com/art-dropshipping
    55 * Description: Create and fulfill custom canvas print-on-demand products in WooCommerce with automated orders, shipping, and tracking.
    6  * Version: 1.10.0
     6 * Version: 1.10.1
    77 * Requires at least: 6.2
    88 * Requires PHP: 8.1
    … …  
    141141        register_setting('cplpod_print_on_demand_settings', self::OPTION_API_URL, [
    142142            'sanitize_callback' => static function ($value): string {
    143                 $host = strtolower((string) wp_parse_url(esc_url_raw((string) $value), PHP_URL_HOST));
    144 
    145                 return in_array($host, ['canvasprintsusa.com', 'www.canvasprintsusa.com'], true)
    146                     ? self::OPTION_API_URL_US
    147                     : self::OPTION_API_URL_DEFAULT;
     143                return self::canonical_api_url((string) $value) ?: self::OPTION_API_URL_DEFAULT;
    148144            },
    149145        ]);
    … …  
    160156            : ['status' => __('Not connected. Choose the pricing market and paste the API key supplied by Canvas Prints.', 'canvas-prints-ltd-print-on-demand-for-woocommerce')];
    161157        $market = $this->market();
    162         $accountUrl = $market === 'US'
    163             ? 'https://www.canvasprintsusa.com/customer/dropshipping'
    164             : 'https://www.canvasprintscalgary.com/customer/dropshipping';
     158        $accountUrl = str_replace('/api/partner/v1', '/customer/dropshipping', $this->api_url());
    165159        ?>
    166160        <div class="wrap">
    … …  
    194188                    </tr>
    195189                    <tr>
     190                        <th scope="row"><label for="cplpod_api_url"><?php esc_html_e('Canvas account site', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></label></th>
     191                        <td><select id="cplpod_api_url" name="<?php echo esc_attr(self::OPTION_API_URL); ?>">
     192                        <?php foreach (['canvasprintscalgary.com' => __('Calgary (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintsedmonton.com' => __('Edmonton (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintstoronto.ca' => __('Toronto (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintsvancouver.ca' => __('Vancouver (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintsusa.com' => __('USA', 'canvas-prints-ltd-print-on-demand-for-woocommerce')] as $site => $label): $endpoint = 'https://www.' . $site . '/api/partner/v1'; ?>
     193                            <option value="<?php echo esc_attr($endpoint); ?>" <?php selected($this->api_url(), $endpoint); ?>><?php echo esc_html($label); ?></option>
     194                        <?php endforeach; ?>
     195                        </select><p class="description"><?php esc_html_e('Choose the same Canvas Prints site where you created this store API key. An Edmonton key needs the Edmonton site.', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></p></td>
     196                    </tr>
     197                    <tr>
    196198                        <th scope="row"><label for="cplpod_api_key"><?php esc_html_e('API Key', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></label></th>
    197199                        <td><input id="cplpod_api_key" name="<?php echo esc_attr(self::OPTION_API_KEY); ?>" type="password" class="regular-text" value="<?php echo esc_attr($this->api_key()); ?>"></td>
    … …  
    204206                </p>
    205207                <p class="description"><?php esc_html_e('This is your account home market. Buyer delivery country does not switch your Canvas price list. To move the business to another market later, disconnect and create a new connection on the matching Canvas Prints site.', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></p>
     208                <script>
     209                document.addEventListener('DOMContentLoaded', function () {
     210                    var market = document.getElementById('cplpod_market');
     211                    var site = document.getElementById('cplpod_api_url');
     212                    if (!market || !site) return;
     213                    function syncMarket() { market.value = site.value.indexOf('canvasprintsusa.com') !== -1 ? 'US' : 'CA'; }
     214                    syncMarket();
     215                    site.addEventListener('change', syncMarket);
     216                    market.addEventListener('change', function () {
     217                        if (market.value === 'US') site.value = 'https://www.canvasprintsusa.com/api/partner/v1';
     218                        else if (site.value.indexOf('canvasprintsusa.com') !== -1) site.value = 'https://www.canvasprintscalgary.com/api/partner/v1';
     219                    });
     220                });
     221                </script>
    206222                <?php submit_button(__('Save connection', 'canvas-prints-ltd-print-on-demand-for-woocommerce')); ?>
    207223            </form>
    … …  
    350366        }
    351367
    352         wp_register_style('cplpod-print-on-demand-preview', false, [], '1.10.0');
     368        wp_register_style('cplpod-print-on-demand-preview', false, [], '1.10.1');
    353369        wp_enqueue_style('cplpod-print-on-demand-preview');
    354370        wp_add_inline_style('cplpod-print-on-demand-preview', $this->preview_css());
    355371
    356         wp_register_script('cplpod-print-on-demand-preview', false, [], '1.10.0', true);
     372        wp_register_script('cplpod-print-on-demand-preview', false, [], '1.10.1', true);
    357373        wp_enqueue_script('cplpod-print-on-demand-preview');
    358374        wp_add_inline_script('cplpod-print-on-demand-preview', $this->preview_js());
    … …  
    10771093            );
    10781094        }
    1079         $host = strtolower((string) wp_parse_url($url, PHP_URL_HOST));
    1080         if (!in_array($host, ['canvasprintscalgary.com', 'www.canvasprintscalgary.com', 'canvasprintsusa.com', 'www.canvasprintsusa.com'], true)) {
    1081             return $this->market() === 'US' ? self::OPTION_API_URL_US : self::OPTION_API_URL_DEFAULT;
    1082         }
    1083 
    1084         return in_array($host, ['canvasprintsusa.com', 'www.canvasprintsusa.com'], true)
    1085             ? self::OPTION_API_URL_US
    1086             : self::OPTION_API_URL_DEFAULT;
     1095        return self::canonical_api_url($url)
     1096            ?: ($this->market() === 'US' ? self::OPTION_API_URL_US : self::OPTION_API_URL_DEFAULT);
     1097    }
     1098
     1099    private static function canonical_api_url(string $url): string
     1100    {
     1101        $parts = wp_parse_url(trim($url));
     1102        if (!is_array($parts) || strtolower((string) ($parts['scheme'] ?? '')) !== 'https'
     1103            || isset($parts['user']) || isset($parts['pass']) || isset($parts['port'])) return '';
     1104        $host = preg_replace('/^www\./', '', strtolower((string) ($parts['host'] ?? '')));
     1105        if (!in_array($host, ['canvasprintscalgary.com', 'canvasprintsedmonton.com', 'canvasprintstoronto.ca', 'canvasprintsvancouver.ca', 'canvasprintsusa.com'], true)) return '';
     1106        return 'https://www.' . $host . '/api/partner/v1';
    10871107    }
    10881108
  • canvas-prints-ltd-print-on-demand-for-woocommerce/tags/1.10.1/readme.txt

    r3667824 r3808150  
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 1.10.0
     7Stable tag: 1.10.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    50504. Create and immediately copy the store API key.
    51515. In WordPress, open WooCommerce > Canvas Print-on-Demand.
    52 6. Confirm the automatically detected Canada or United States pricing market, paste the matching key and save.
     526. Select the exact Canvas account site where the key was created (Calgary, Edmonton, Toronto, Vancouver or USA), paste the current store key and save. Canada alone does not identify which site owns the connection.
    53537. Confirm the Connection section reports an active connection.
    5454
    5555== Frequently Asked Questions ==
     56
     57= I have an Edmonton key but the connection says unauthorized. What should I do? =
     58
     59Update to version 1.10.1 or later. In WooCommerce > Canvas Print-on-Demand, select Edmonton under Canvas account site, paste the current key from your Edmonton Dropshipping account and save. Previous versions routed all Canadian keys to Calgary. You do not need to disconnect or move the store to another Canvas account.
     60
    5661
    5762= Can one account connect multiple WooCommerce stores? =
    … …  
    8186== External services ==
    8287
    83 This plugin connects to the Canadian Canvas Prints fulfillment API at https://www.canvasprintscalgary.com/api/partner/v1 or the U.S. Canvas Prints fulfillment API at https://www.canvasprintsusa.com/api/partner/v1 according to the merchant-selected fulfillment pricing market. It sends the connected store URL, paid-order identifiers, canvas configuration, production image URL, delivery contact and address, and fulfillment totals needed to validate, charge and produce the order. It receives connection, catalog, validation, order, billing and fulfillment status responses.
     88This plugin connects only to the selected Canvas account site: https://www.canvasprintscalgary.com/api/partner/v1, https://www.canvasprintsedmonton.com/api/partner/v1, https://www.canvasprintstoronto.ca/api/partner/v1, https://www.canvasprintsvancouver.ca/api/partner/v1 or https://www.canvasprintsusa.com/api/partner/v1. Select the same site where the store API key was created; Canadian sites use CAD and the USA site uses USD. It sends the connected store URL, paid-order identifiers, canvas configuration, production image URL, delivery contact and address, and fulfillment totals needed to validate, charge and produce the order. It receives connection, catalog, validation, order, billing and fulfillment status responses.
    8489
    8590The service is provided by Canvas Prints Ltd. Review the service privacy policy at https://www.canvasprintscalgary.com/canvas-prints-privacy-policy and terms at https://www.canvasprintscalgary.com/canvas-prints-terms before connecting a store.
    8691
    8792== Changelog ==
     93
     94= 1.10.1 =
     95* Select the exact Canvas account site, including Edmonton, Toronto and Vancouver, without silently switching its API key to Calgary.
    8896
    8997= 1.10.0 =
  • canvas-prints-ltd-print-on-demand-for-woocommerce/trunk/canvas-printing-fulfillment.php

    r3667824 r3808150  
    44 * Plugin URI: https://www.canvasprintscalgary.com/art-dropshipping
    55 * Description: Create and fulfill custom canvas print-on-demand products in WooCommerce with automated orders, shipping, and tracking.
    6  * Version: 1.10.0
     6 * Version: 1.10.1
    77 * Requires at least: 6.2
    88 * Requires PHP: 8.1
    … …  
    141141        register_setting('cplpod_print_on_demand_settings', self::OPTION_API_URL, [
    142142            'sanitize_callback' => static function ($value): string {
    143                 $host = strtolower((string) wp_parse_url(esc_url_raw((string) $value), PHP_URL_HOST));
    144 
    145                 return in_array($host, ['canvasprintsusa.com', 'www.canvasprintsusa.com'], true)
    146                     ? self::OPTION_API_URL_US
    147                     : self::OPTION_API_URL_DEFAULT;
     143                return self::canonical_api_url((string) $value) ?: self::OPTION_API_URL_DEFAULT;
    148144            },
    149145        ]);
    … …  
    160156            : ['status' => __('Not connected. Choose the pricing market and paste the API key supplied by Canvas Prints.', 'canvas-prints-ltd-print-on-demand-for-woocommerce')];
    161157        $market = $this->market();
    162         $accountUrl = $market === 'US'
    163             ? 'https://www.canvasprintsusa.com/customer/dropshipping'
    164             : 'https://www.canvasprintscalgary.com/customer/dropshipping';
     158        $accountUrl = str_replace('/api/partner/v1', '/customer/dropshipping', $this->api_url());
    165159        ?>
    166160        <div class="wrap">
    … …  
    194188                    </tr>
    195189                    <tr>
     190                        <th scope="row"><label for="cplpod_api_url"><?php esc_html_e('Canvas account site', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></label></th>
     191                        <td><select id="cplpod_api_url" name="<?php echo esc_attr(self::OPTION_API_URL); ?>">
     192                        <?php foreach (['canvasprintscalgary.com' => __('Calgary (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintsedmonton.com' => __('Edmonton (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintstoronto.ca' => __('Toronto (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintsvancouver.ca' => __('Vancouver (Canada)', 'canvas-prints-ltd-print-on-demand-for-woocommerce'), 'canvasprintsusa.com' => __('USA', 'canvas-prints-ltd-print-on-demand-for-woocommerce')] as $site => $label): $endpoint = 'https://www.' . $site . '/api/partner/v1'; ?>
     193                            <option value="<?php echo esc_attr($endpoint); ?>" <?php selected($this->api_url(), $endpoint); ?>><?php echo esc_html($label); ?></option>
     194                        <?php endforeach; ?>
     195                        </select><p class="description"><?php esc_html_e('Choose the same Canvas Prints site where you created this store API key. An Edmonton key needs the Edmonton site.', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></p></td>
     196                    </tr>
     197                    <tr>
    196198                        <th scope="row"><label for="cplpod_api_key"><?php esc_html_e('API Key', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></label></th>
    197199                        <td><input id="cplpod_api_key" name="<?php echo esc_attr(self::OPTION_API_KEY); ?>" type="password" class="regular-text" value="<?php echo esc_attr($this->api_key()); ?>"></td>
    … …  
    204206                </p>
    205207                <p class="description"><?php esc_html_e('This is your account home market. Buyer delivery country does not switch your Canvas price list. To move the business to another market later, disconnect and create a new connection on the matching Canvas Prints site.', 'canvas-prints-ltd-print-on-demand-for-woocommerce'); ?></p>
     208                <script>
     209                document.addEventListener('DOMContentLoaded', function () {
     210                    var market = document.getElementById('cplpod_market');
     211                    var site = document.getElementById('cplpod_api_url');
     212                    if (!market || !site) return;
     213                    function syncMarket() { market.value = site.value.indexOf('canvasprintsusa.com') !== -1 ? 'US' : 'CA'; }
     214                    syncMarket();
     215                    site.addEventListener('change', syncMarket);
     216                    market.addEventListener('change', function () {
     217                        if (market.value === 'US') site.value = 'https://www.canvasprintsusa.com/api/partner/v1';
     218                        else if (site.value.indexOf('canvasprintsusa.com') !== -1) site.value = 'https://www.canvasprintscalgary.com/api/partner/v1';
     219                    });
     220                });
     221                </script>
    206222                <?php submit_button(__('Save connection', 'canvas-prints-ltd-print-on-demand-for-woocommerce')); ?>
    207223            </form>
    … …  
    350366        }
    351367
    352         wp_register_style('cplpod-print-on-demand-preview', false, [], '1.10.0');
     368        wp_register_style('cplpod-print-on-demand-preview', false, [], '1.10.1');
    353369        wp_enqueue_style('cplpod-print-on-demand-preview');
    354370        wp_add_inline_style('cplpod-print-on-demand-preview', $this->preview_css());
    355371
    356         wp_register_script('cplpod-print-on-demand-preview', false, [], '1.10.0', true);
     372        wp_register_script('cplpod-print-on-demand-preview', false, [], '1.10.1', true);
    357373        wp_enqueue_script('cplpod-print-on-demand-preview');
    358374        wp_add_inline_script('cplpod-print-on-demand-preview', $this->preview_js());
    … …  
    10771093            );
    10781094        }
    1079         $host = strtolower((string) wp_parse_url($url, PHP_URL_HOST));
    1080         if (!in_array($host, ['canvasprintscalgary.com', 'www.canvasprintscalgary.com', 'canvasprintsusa.com', 'www.canvasprintsusa.com'], true)) {
    1081             return $this->market() === 'US' ? self::OPTION_API_URL_US : self::OPTION_API_URL_DEFAULT;
    1082         }
    1083 
    1084         return in_array($host, ['canvasprintsusa.com', 'www.canvasprintsusa.com'], true)
    1085             ? self::OPTION_API_URL_US
    1086             : self::OPTION_API_URL_DEFAULT;
     1095        return self::canonical_api_url($url)
     1096            ?: ($this->market() === 'US' ? self::OPTION_API_URL_US : self::OPTION_API_URL_DEFAULT);
     1097    }
     1098
     1099    private static function canonical_api_url(string $url): string
     1100    {
     1101        $parts = wp_parse_url(trim($url));
     1102        if (!is_array($parts) || strtolower((string) ($parts['scheme'] ?? '')) !== 'https'
     1103            || isset($parts['user']) || isset($parts['pass']) || isset($parts['port'])) return '';
     1104        $host = preg_replace('/^www\./', '', strtolower((string) ($parts['host'] ?? '')));
     1105        if (!in_array($host, ['canvasprintscalgary.com', 'canvasprintsedmonton.com', 'canvasprintstoronto.ca', 'canvasprintsvancouver.ca', 'canvasprintsusa.com'], true)) return '';
     1106        return 'https://www.' . $host . '/api/partner/v1';
    10871107    }
    10881108
  • canvas-prints-ltd-print-on-demand-for-woocommerce/trunk/readme.txt

    r3667824 r3808150  
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 1.10.0
     7Stable tag: 1.10.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    50504. Create and immediately copy the store API key.
    51515. In WordPress, open WooCommerce > Canvas Print-on-Demand.
    52 6. Confirm the automatically detected Canada or United States pricing market, paste the matching key and save.
     526. Select the exact Canvas account site where the key was created (Calgary, Edmonton, Toronto, Vancouver or USA), paste the current store key and save. Canada alone does not identify which site owns the connection.
    53537. Confirm the Connection section reports an active connection.
    5454
    5555== Frequently Asked Questions ==
     56
     57= I have an Edmonton key but the connection says unauthorized. What should I do? =
     58
     59Update to version 1.10.1 or later. In WooCommerce > Canvas Print-on-Demand, select Edmonton under Canvas account site, paste the current key from your Edmonton Dropshipping account and save. Previous versions routed all Canadian keys to Calgary. You do not need to disconnect or move the store to another Canvas account.
     60
    5661
    5762= Can one account connect multiple WooCommerce stores? =
    … …  
    8186== External services ==
    8287
    83 This plugin connects to the Canadian Canvas Prints fulfillment API at https://www.canvasprintscalgary.com/api/partner/v1 or the U.S. Canvas Prints fulfillment API at https://www.canvasprintsusa.com/api/partner/v1 according to the merchant-selected fulfillment pricing market. It sends the connected store URL, paid-order identifiers, canvas configuration, production image URL, delivery contact and address, and fulfillment totals needed to validate, charge and produce the order. It receives connection, catalog, validation, order, billing and fulfillment status responses.
     88This plugin connects only to the selected Canvas account site: https://www.canvasprintscalgary.com/api/partner/v1, https://www.canvasprintsedmonton.com/api/partner/v1, https://www.canvasprintstoronto.ca/api/partner/v1, https://www.canvasprintsvancouver.ca/api/partner/v1 or https://www.canvasprintsusa.com/api/partner/v1. Select the same site where the store API key was created; Canadian sites use CAD and the USA site uses USD. It sends the connected store URL, paid-order identifiers, canvas configuration, production image URL, delivery contact and address, and fulfillment totals needed to validate, charge and produce the order. It receives connection, catalog, validation, order, billing and fulfillment status responses.
    8489
    8590The service is provided by Canvas Prints Ltd. Review the service privacy policy at https://www.canvasprintscalgary.com/canvas-prints-privacy-policy and terms at https://www.canvasprintscalgary.com/canvas-prints-terms before connecting a store.
    8691
    8792== Changelog ==
     93
     94= 1.10.1 =
     95* Select the exact Canvas account site, including Edmonton, Toronto and Vancouver, without silently switching its API key to Calgary.
    8896
    8997= 1.10.0 =
Note: See TracChangeset for help on using the changeset viewer.