Improvements for v3 of subscriptions
This commit is contained in:
parent
f51f0c0c37
commit
38c0d8dd95
|
|
@ -57,6 +57,11 @@ class Cart extends Component
|
||||||
return count($optional) > 0;
|
return count($optional) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function payableAmount()
|
||||||
|
{
|
||||||
|
return isset($this->context['products']) && collect($this->context['products'])->sum('total_raw') > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('billing-portal.v3.cart.cart');
|
return view('billing-portal.v3.cart.cart');
|
||||||
|
|
|
||||||
|
|
@ -53,38 +53,68 @@ class Summary extends Component
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($subscription->service()->recurring_products() as $key => $product) {
|
foreach ($subscription->service()->recurring_products() as $key => $product) {
|
||||||
|
|
||||||
|
|
||||||
|
$default_quantity = $bundle['recurring_products'][$product->hashed_id]['quantity'] ?? 1;
|
||||||
|
|
||||||
|
if($subscription->use_inventory_management && $product['in_stock_quantity'] < 1){
|
||||||
|
$default_quantity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$bundle['recurring_products'][$product->hashed_id] = [
|
$bundle['recurring_products'][$product->hashed_id] = [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'quantity' => $bundle['recurring_products'][$product->hashed_id]['quantity'] ?? 1,
|
'quantity' => $default_quantity,
|
||||||
'notes' => $product->markdownNotes(),
|
'notes' => $product->markdownNotes(),
|
||||||
];
|
];
|
||||||
$bundle['recurring_products'][$product->hashed_id]['product']['is_recurring'] = true;
|
$bundle['recurring_products'][$product->hashed_id]['product']['is_recurring'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($subscription->service()->products() as $key => $product) {
|
foreach ($subscription->service()->products() as $key => $product) {
|
||||||
|
|
||||||
|
$default_quantity = $bundle['one_time_products'][$product->hashed_id]['quantity'] ?? 1;
|
||||||
|
|
||||||
|
if($subscription->use_inventory_management && $product['in_stock_quantity'] < 1){
|
||||||
|
$default_quantity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$bundle['one_time_products'][$product->hashed_id] = [
|
$bundle['one_time_products'][$product->hashed_id] = [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'quantity' => $bundle['one_time_products'][$product->hashed_id]['quantity'] ?? 1,
|
'quantity' => $default_quantity,
|
||||||
'notes' => $product->markdownNotes(),
|
'notes' => $product->markdownNotes(),
|
||||||
];
|
];
|
||||||
$bundle['one_time_products'][$product->hashed_id]['product']['is_recurring'] = false;
|
$bundle['one_time_products'][$product->hashed_id]['product']['is_recurring'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($subscription->service()->optional_recurring_products() as $key => $product) {
|
foreach ($subscription->service()->optional_recurring_products() as $key => $product) {
|
||||||
|
|
||||||
|
$default_quantity = $bundle['optional_recurring_products'][$product->hashed_id]['quantity'] ?? 0;
|
||||||
|
|
||||||
|
if($subscription->use_inventory_management && $product['in_stock_quantity'] < 1){
|
||||||
|
$default_quantity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$bundle['optional_recurring_products'][$product->hashed_id] = [
|
$bundle['optional_recurring_products'][$product->hashed_id] = [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'quantity' => $bundle['optional_recurring_products'][$product->hashed_id]['quantity'] ?? 0,
|
'quantity' => $default_quantity,
|
||||||
'notes' => $product->markdownNotes(),
|
'notes' => $product->markdownNotes(),
|
||||||
];
|
];
|
||||||
$bundle['optional_recurring_products'][$product->hashed_id]['product']['is_recurring'] = true;
|
$bundle['optional_recurring_products'][$product->hashed_id]['product']['is_recurring'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($subscription->service()->optional_products() as $key => $product) {
|
foreach ($subscription->service()->optional_products() as $key => $product) {
|
||||||
|
|
||||||
|
$default_quantity = $bundle['optional_one_time_products'][$product->hashed_id]['quantity'] ?? 0;
|
||||||
|
|
||||||
|
if($subscription->use_inventory_management && $product['in_stock_quantity'] < 1){
|
||||||
|
$default_quantity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$bundle['optional_one_time_products'][$product->hashed_id] = [
|
$bundle['optional_one_time_products'][$product->hashed_id] = [
|
||||||
'product' => $product,
|
'product' => $product,
|
||||||
'quantity' => $bundle['optional_one_time_products'][$product->hashed_id]['quantity'] ?? 0,
|
'quantity' => $default_quantity,
|
||||||
'notes' => $product->markdownNotes(),
|
'notes' => $product->markdownNotes(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$bundle['optional_one_time_products'][$product->hashed_id]['product']['is_recurring'] = false;
|
$bundle['optional_one_time_products'][$product->hashed_id]['product']['is_recurring'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
:context="$context"
|
:context="$context"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
@if($this->payableAmount())
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<form wire:submit="handleSubmit">
|
<form wire:submit="handleSubmit">
|
||||||
<button
|
<button
|
||||||
|
|
@ -46,4 +47,5 @@
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,12 @@
|
||||||
class="block w-20 rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm"
|
class="block w-20 rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm"
|
||||||
{{ $this->subscription->use_inventory_management && $product['in_stock_quantity'] < 1 ? 'disabled' : '' }}
|
{{ $this->subscription->use_inventory_management && $product['in_stock_quantity'] < 1 ? 'disabled' : '' }}
|
||||||
>
|
>
|
||||||
<option value="1" {{ $entry['quantity'] == 1 ? 'selected' : '' }}>1</option>
|
@if($this->subscription->use_inventory_management && $product['in_stock_quantity'] < 1)
|
||||||
|
<option value="0" {{ $entry['quantity'] == 0 ? 'selected' : '' }}>0</option>
|
||||||
|
@else
|
||||||
|
<option value="1" {{ $entry['quantity'] == 1 ? 'selected' : '' }}>1</option>
|
||||||
|
@endif
|
||||||
|
|
||||||
@for ($i = 2; $i <= $this->subscription->maxQuantity($product); $i++)
|
@for ($i = 2; $i <= $this->subscription->maxQuantity($product); $i++)
|
||||||
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
|
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
|
||||||
@endfor
|
@endfor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue