Add quantity to subscriptions

This commit is contained in:
David Bomba 2022-07-06 16:18:16 +10:00
parent 3e5e915acc
commit 9359c84013
3 changed files with 32 additions and 6 deletions

View File

@ -144,7 +144,7 @@ class BillingPortalPurchase extends Component
* *
* @var int * @var int
*/ */
public $quantity = 1; public $quantity;
/** /**
* First-hit request data (queries, locales...). * First-hit request data (queries, locales...).
@ -183,6 +183,8 @@ class BillingPortalPurchase extends Component
{ {
MultiDB::setDb($this->company->db); MultiDB::setDb($this->company->db);
$this->quantity = 1;
$this->price = $this->subscription->price; $this->price = $this->subscription->price;
if (request()->query('coupon')) { if (request()->query('coupon')) {
@ -433,13 +435,14 @@ class BillingPortalPurchase extends Component
if ($option == 'increment') { if ($option == 'increment') {
$this->quantity++; $this->quantity++;
return $this->price = (int)$this->price + $this->subscription->product->price; $this->price = $this->subscription->promo_price * $this->quantity;
return $this->quantity;
} }
$this->quantity--; $this->quantity--;
$this->price = (int)$this->price - $this->subscription->product->price; $this->price = $this->subscription->promo_price * $this->quantity;
return 0; return $this->quantity;
} }
public function handleCoupon() public function handleCoupon()

View File

@ -51,6 +51,29 @@
</div> </div>
@endif @endif
@if($subscription->per_seat_enabled && $subscription->max_seats_limit > 1)
<div class="flex mt-4 space-x-4 items-center">
<span class="text-sm mx-2">{{ ctrans('texts.qty') }}:</span>
<button wire:click="updateQuantity('decrement')" class="bg-gray-100 border rounded p-1">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="feather feather-minus">
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
</button>
<div class="px-2">{{ $quantity }}</div>
<button wire:click="updateQuantity('increment')" class="bg-gray-100 border rounded p-1">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
class="feather feather-plus">
<line x1="12" y1="5" x2="12" y2="19"></line>
<line x1="5" y1="12" x2="19" y2="12"></line>
</svg>
</button>
</div>
@endif
<div class="relative mt-8"> <div class="relative mt-8">
<div class="absolute inset-0 flex items-center"> <div class="absolute inset-0 flex items-center">
<div class="w-full border-t border-gray-300"></div> <div class="w-full border-t border-gray-300"></div>

View File

@ -12,7 +12,7 @@
@section('body') @section('body')
@if($purchase_order->company->getSetting('vendor_portal_enable_uploads') || true) @if($purchase_order->company->getSetting('vendor_portal_enable_uploads'))
@component('portal.ninja2020.purchase_orders.includes.upload', ['purchase_order' => $purchase_order]) @endcomponent @component('portal.ninja2020.purchase_orders.includes.upload', ['purchase_order' => $purchase_order]) @endcomponent
@endif @endif