Skip to content

Commit

Permalink
Fix price breaks not storing in correct currency factor (#1948)
Browse files Browse the repository at this point in the history
  • Loading branch information
wychoong authored Sep 18, 2024
1 parent 24cba88 commit 4aad66d
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function () {
->label(
__('lunarpanel.shipping::relationmanagers.shipping_rates.form.shipping_method_id.label')
)
->required()
->relationship(name: 'shippingMethod', titleAttribute: 'name')
->columnSpan(2),
Forms\Components\TextInput::make('price')
Expand Down Expand Up @@ -180,9 +181,14 @@ protected static function saveShippingRate(?ShippingRate $shippingRate = null, a

$shippingRate->priceBreaks()->delete();

$currencies = Currency::all();
$tiers = collect($data['prices'] ?? [])->map(
function ($price) {
$price['min_quantity'] = $price['min_quantity'] * 100;
function ($price) use ($currencies) {
$currency = $currencies->first(fn ($currency) => $currency->id == $price['currency_id']);

$price['min_quantity'] = (int) ($price['min_quantity'] * $currency->factor);

$price['price'] = (int) ($price['price'] * $currency->factor);

return $price;
}
Expand Down

0 comments on commit 4aad66d

Please sign in to comment.