From b826373a78ca77d7d4d4e9f12f30cec0cea6693d Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Tue, 14 Sep 2021 13:23:43 -0600 Subject: [PATCH] Add international rate calculation support --- www/assets/js/rates.js | 19 +++ www/pages/rates.html | 279 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 297 insertions(+), 1 deletion(-) diff --git a/www/assets/js/rates.js b/www/assets/js/rates.js index e7d4b8e..b2ecd09 100644 --- a/www/assets/js/rates.js +++ b/www/assets/js/rates.js @@ -39,6 +39,21 @@ var itemTypeCharacteristics = { }; function updateRateForm() { + if ($("#to_country").val() == "" || $("#to_country").val() == "US") { + $(".citystateboxes").css("display", "none"); + $("#ziptext").html("ZIP Code"); + $("#to_zip").attr("inputmode", "numeric"); + $("#to_zip").attr("required", "true"); + $("#to_zip").attr("placeholder", "ZIP Code"); + } else { + $(".citystateboxes").css("display", ""); + $("#ziptext").html("Postal Code"); + $("#to_zip").attr("inputmode", "text"); + $("#to_zip").removeAttr("required"); + $("#to_zip").attr("placeholder", "Postal Code"); + } + + $("#itemweight").css("display", "none"); $("#itemsize").css("display", "none"); $("#itemweightlbs").css("display", "none"); @@ -75,6 +90,7 @@ function updateRateForm() { } $("#app").on("click change", "#itemType", updateRateForm); +$("#app").on("click change", "#to_country", updateRateForm); function initRateForm() { $("#itemType").val(""); @@ -91,6 +107,9 @@ function getRates() { from_zip: $("#from_zip").val(), to_street1: $("#to_street1").val(), to_zip: $("#to_zip").val(), + to_city: $("#to_city").val(), + to_state: $("#to_state").val(), + to_country: $("#to_country").val(), itemType: $("#itemType").val(), length: $("input[name=length]").val(), width: $("input[name=width]").val(), diff --git a/www/pages/rates.html b/www/pages/rates.html index 72c8e80..c7838d7 100644 --- a/www/pages/rates.html +++ b/www/pages/rates.html @@ -56,13 +56,290 @@
  • -
    ZIP Code
    +
    ZIP Code
  • + + +
  • +
    +
    Country
    +
    + +
    +
    +
  • Item Type: