Skip to content

Commit

Permalink
Merge branch 'WP-67' into 'main'
Browse files Browse the repository at this point in the history
fix: add rounding to zero for delivery cost

See merge request ecommerce_modules/cms/wordpress/wordpress!33
  • Loading branch information
vermorag committed Oct 23, 2024
2 parents fd37407 + 5fbcf85 commit 3e46a1d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Actions/CalculateDeliveryAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static function ($carry, $item) use ($package) {
'label' => sprintf(esc_html__('CDEK: %s, (%s-%s days)', 'cdekdelivery'),
Tariff::getTariffUserNameByCode($tariff['tariff_code']), $minDay,
$maxDay),
'cost' => $cost,
'cost' => max($cost, 0),
'meta_data' => [
MetaKeys::ADDRESS_HASH => sha1($deliveryParam['to']['postal_code'].
$deliveryParam['to']['city'].
Expand Down Expand Up @@ -173,8 +173,8 @@ static function ($carry, $item) use ($package) {
}

if (isset($rule['type']) && $rule['type'] === 'fixed') {
$tariff['cost'] = function_exists('wcml_get_woocommerce_currency_option') ?
apply_filters('wcml_raw_price_amount', $rule['value'], 'RUB') : $rule['value'];
$tariff['cost'] = max(function_exists('wcml_get_woocommerce_currency_option') ?
apply_filters('wcml_raw_price_amount', $rule['value'], 'RUB') : $rule['value'], 0);

return $tariff;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ static function ($carry, $item) use ($package) {
$cost /= $coef;
}

$tariff['cost'] = ceil($cost);
$tariff['cost'] = max(ceil($cost), 0);

return $tariff;
}, $this->rates);
Expand Down

0 comments on commit 3e46a1d

Please sign in to comment.