From 6e714747bd21cefcd2bf0d183daa7a05bf39f54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 22 Mar 2021 13:53:34 +0100 Subject: [PATCH] Update price per quantity --- app/Http/Livewire/BillingPortalPurchase.php | 19 ++++++++++++++++--- .../views/billing-portal/purchase.blade.php | 2 +- .../billing-portal-purchase.blade.php | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/BillingPortalPurchase.php b/app/Http/Livewire/BillingPortalPurchase.php index 144f721e313a..aa98fdc17da6 100644 --- a/app/Http/Livewire/BillingPortalPurchase.php +++ b/app/Http/Livewire/BillingPortalPurchase.php @@ -138,6 +138,13 @@ class BillingPortalPurchase extends Component */ public $request_data; + /** + * Price of product. + * + * @var string + */ + public $price; + /** * Handle user authentication * @@ -313,9 +320,15 @@ class BillingPortalPurchase extends Component return $this->quantity; } - return $option == 'increment' - ? $this->quantity++ - : $this->quantity--; + if ($option == 'increment') { + $this->quantity++; + return $this->price = (int) $this->price + $this->billing_subscription->product->price; + } + + $this->quantity--; + $this->price = (int) $this->price - $this->billing_subscription->product->price; + + return 0; } public function render() diff --git a/resources/views/billing-portal/purchase.blade.php b/resources/views/billing-portal/purchase.blade.php index 34ea32ccf0e8..b264ac635810 100644 --- a/resources/views/billing-portal/purchase.blade.php +++ b/resources/views/billing-portal/purchase.blade.php @@ -2,7 +2,7 @@ @section('meta_title', $billing_subscription->product->product_key) @section('body') - @livewire('billing-portal-purchase', ['billing_subscription' => $billing_subscription, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data]) + @livewire('billing-portal-purchase', ['billing_subscription' => $billing_subscription, 'contact' => auth('contact')->user(), 'hash' => $hash, 'request_data' => $request_data, 'price' => $billing_subscription->product->price]) @stop @push('footer') diff --git a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php index 8679a7ed844f..d5eb2719ca3e 100644 --- a/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/billing-portal-purchase.blade.php @@ -13,7 +13,7 @@ {{ ctrans('texts.price') }}:
-

{{ App\Utils\Number::formatMoney($billing_subscription->product->price, $billing_subscription->company) }}

+

{{ App\Utils\Number::formatMoney($price, $billing_subscription->company) }}

@if($billing_subscription->per_seat_enabled && $billing_subscription->max_seats_limit > 1)