-
-
Save csavoronin/e121be0afd6d595a81a8914b665b6e9e to your computer and use it in GitHub Desktop.
[!] Shipping methods: The rate conditions were displayed in the wrong order. Fixed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/functions/fn.locations.php b/app/functions/fn.locations.php | |
index 1b068220133..d73620e0679 100644 | |
--- a/app/functions/fn.locations.php | |
+++ b/app/functions/fn.locations.php | |
@@ -1077,6 +1077,21 @@ function ($destination) use ($params) { | |
} | |
$shipping_info = fn_get_shipping_info($params['shipping_id'], $lang_code); | |
+ | |
+ // Sort rate values | |
+ foreach ($shipping_info['rates'] as $key_rate => $rate) { | |
+ if (!isset($rate['rate_value'])) { | |
+ continue; | |
+ } | |
+ foreach ($rate['rate_value'] as $key_rate_value => $rate_value) { | |
+ if (empty($rate_value)) { | |
+ continue; | |
+ } | |
+ $shipping_info['rates'][$key_rate]['rate_value'][$key_rate_value] = | |
+ array_values($rate['rate_value'][$key_rate_value]); | |
+ } | |
+ } | |
+ | |
$destinations = array_map( | |
function ($destination) use ($shipping_info) { | |
$destination_id = (int) $destination['destination_id']; | |
diff --git a/js/tygh/backend/shipping_rates.js b/js/tygh/backend/shipping_rates.js | |
index 1dfc72474a9..8560acb0a0f 100644 | |
--- a/js/tygh/backend/shipping_rates.js | |
+++ b/js/tygh/backend/shipping_rates.js | |
@@ -237,8 +237,7 @@ | |
} | |
function fn_add_table_conditions ($block, data, rateValues) { | |
- var typeCondition = data.type, | |
- rateValuesKeys = rateValues ? Object.keys(rateValues) : []; | |
+ var typeCondition = data.type; | |
var $newConditionTable = $(`<table> | |
<thead> | |
<th>${_.tr(typeCondition + '_condition_name')}</th> | |
@@ -250,11 +249,11 @@ | |
.attr({ id : `table_${data.destinationId}_${typeCondition}`}) | |
.addClass('table table-middle table--relative shipping-rate__table-condition'); | |
- if (rateValues && rateValuesKeys.length > 0) { | |
- rateValuesKeys.sort().forEach(key => { | |
- data.rateValue = rateValues[key]; | |
+ if (rateValues && Object.keys(rateValues).length > 0) { | |
+ for (value in rateValues) { | |
+ data.rateValue = rateValues[value]; | |
fn_add_tr_to_table_conditions(data, $newConditionTable, false); | |
- }); | |
+ } | |
delete data.rateValue; | |
if (!isDisabledFields) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment