Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsumon4u committed Sep 12, 2024
1 parent 9442f60 commit bbdfc7b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 46 deletions.
6 changes: 3 additions & 3 deletions app/Http/Livewire/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ private function shippingCost()
{
$shipping_cost = 0;
if ($this->shipping) {
if (! setting('show_option')->productwise_delivery_charge) {
if (! setting('show_option')->productwise_delivery_charge ?? false) {
$shipping_cost = setting('delivery_charge')->{$this->shipping == 'Inside Dhaka' ? 'inside_dhaka' : 'outside_dhaka'} ?? config('services.shipping.' . $this->shipping);
} else {
$shipping_cost = collect($this->cart)->sum(function ($item) {
if ($this->shipping == 'Inside Dhaka') {
return $item['shipping_inside'] * (setting('show_option')->quantitywise_delivery_charge ? $item['quantity'] : 1);
return $item['shipping_inside'] * ((setting('show_option')->quantitywise_delivery_charge ?? false) ? $item['quantity'] : 1);
} else {
return $item['shipping_outside'] * (setting('show_option')->quantitywise_delivery_charge ? $item['quantity'] : 1);
return $item['shipping_outside'] * ((setting('show_option')->quantitywise_delivery_charge ?? false) ? $item['quantity'] : 1);
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions app/Http/Livewire/EditOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ public function decreaseQuantity($id)
public function updatedOrderDataShippingArea($value)
{
$shipping_cost = 0;
if (! setting('show_option')->productwise_delivery_charge) {
if (! setting('show_option')->productwise_delivery_charge ?? false) {
$shipping_cost = setting('delivery_charge')->{$this->order->data['shipping_area'] == 'Inside Dhaka' ? 'inside_dhaka' : 'outside_dhaka'} ?? config('services.shipping.' . $this->order->data['shipping_area'], 0);
} else {
$shipping_cost = collect($this->selectedProducts)->sum(function ($item) {
$default = setting('delivery_charge')->{$this->order->data['shipping_area'] == 'Inside Dhaka' ? 'inside_dhaka' : 'outside_dhaka'} ?? config('services.shipping.' . $this->order->data['shipping_area'], 0);
if ($this->order->data['shipping_area'] == 'Inside Dhaka') {
return ($item['shipping_inside'] ?? $default) * (setting('show_option')->quantitywise_delivery_charge ? $item['quantity'] : 1);
return ($item['shipping_inside'] ?? $default) * (setting('show_option')->quantitywise_delivery_charge ?? false ? $item['quantity'] : 1);
} else {
return ($item['shipping_outside'] ?? $default) * (setting('show_option')->quantitywise_delivery_charge ? $item['quantity'] : 1);
return ($item['shipping_outside'] ?? $default) * (setting('show_option')->quantitywise_delivery_charge ?? false ? $item['quantity'] : 1);
}
});
}
Expand Down Expand Up @@ -233,7 +233,7 @@ public function render()
if (strlen($this->search) > 2) {
$products = Product::with('variations.options')
->whereNotIn('id', array_keys($this->selectedProducts))
->where(fn ($q) => $q->where('name', 'like', "%$this->search%")->orWhere('sku', $this->search))
->where(fn($q) => $q->where('name', 'like', "%$this->search%")->orWhere('sku', $this->search))
->whereNull('parent_id')
->whereIsActive(1)
->take(5)
Expand Down
81 changes: 45 additions & 36 deletions resources/views/admin/settings/others.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,42 @@
<label for="" class="my-1">Product Grid Button</label>
<div class="d-flex ml-2">
<div class="radio radio-secondary mr-3">
<input type="radio" id="product-grid-add-to-cart" name="show_option[product_grid_button]" value="add_to_cart"
@if(old('show_option.product_grid_button', $show_option->product_grid_button ?? false) == 'add_to_cart') checked @endif />
<input type="radio" id="product-grid-add-to-cart" name="show_option[product_grid_button]"
value="add_to_cart" @if (old('show_option.product_grid_button', $show_option->product_grid_button ?? false) == 'add_to_cart') checked @endif />
<label for="product-grid-add-to-cart">`Add To Cart`</label>
</div>
<div class="radio radio-secondary ml-3">
<input type="radio" id="product-grid-order-now" name="show_option[product_grid_button]" value="order_now"
@if(old('show_option.product_grid_button', $show_option->product_grid_button ?? false) == 'order_now') checked @endif />
<input type="radio" id="product-grid-order-now" name="show_option[product_grid_button]"
value="order_now" @if (old('show_option.product_grid_button', $show_option->product_grid_button ?? false) == 'order_now') checked @endif />
<label for="product-grid-order-now">`Order Now`</label>
</div>
</div>
<label for="" class="my-1 d-inline-flex align-items-center">
<span class="mr-1">Product Detail Button(s)</span>
<span class="border px-1 d-inline-flex">
<input type="checkbox" id="product_detail_buttons_inline" name="show_option[product_detail_buttons_inline]"
@if(!!old('show_option.product_detail_buttons_inline', $show_option->product_detail_buttons_inline ?? false)) checked @endif />
<input type="checkbox" id="product_detail_buttons_inline"
name="show_option[product_detail_buttons_inline]"
@if (!!old('show_option.product_detail_buttons_inline', $show_option->product_detail_buttons_inline ?? false)) checked @endif />
<label for="product_detail_buttons_inline" class="ml-1 mb-0">inline</label>
</span>
</label>
<div class="d-flex ml-3">
<div class="checkbox checkbox-secondary mr-3">
<input type="hidden" name="show_option[product_detail_add_to_cart]" value="0">
<x-checkbox id="product-detail-add-to-cart" class="d-none" name="show_option[product_detail_add_to_cart]" value="1"
:checked="!!old('show_option.product_detail_add_to_cart', $show_option->product_detail_add_to_cart ?? false)" />
<x-checkbox id="product-detail-add-to-cart" class="d-none"
name="show_option[product_detail_add_to_cart]" value="1" :checked="!!old(
'show_option.product_detail_add_to_cart',
$show_option->product_detail_add_to_cart ?? false,
)" />
<label for="product-detail-add-to-cart" class="m-0">`Add To Cart`</label>
</div>
<div class="checkbox checkbox-secondary ml-3">
<input type="hidden" name="show_option[product_detail_order_now]" value="0">
<x-checkbox id="product-detail-order-now" class="d-none" name="show_option[product_detail_order_now]" value="1"
:checked="!!old('show_option.product_detail_order_now', $show_option->product_detail_order_now ?? false)" />
<x-checkbox id="product-detail-order-now" class="d-none"
name="show_option[product_detail_order_now]" value="1" :checked="!!old(
'show_option.product_detail_order_now',
$show_option->product_detail_order_now ?? false,
)" />
<label for="product-detail-order-now" class="m-0">`Order Now`</label>
</div>
</div>
Expand All @@ -68,16 +75,16 @@
{{-- Enable Productwise Delivery Charge --}}
<div class="checkbox checkbox-secondary ml-3">
<input type="hidden" name="show_option[productwise_delivery_charge]" value="0">
<x-checkbox id="productwise-delivery-charge" name="show_option[productwise_delivery_charge]" value="1"
:checked="!!($show_option->productwise_delivery_charge ?? false)" />
<x-checkbox id="productwise-delivery-charge" name="show_option[productwise_delivery_charge]"
value="1" :checked="!!($show_option->productwise_delivery_charge ?? (false ?? false))" />
<label for="productwise-delivery-charge" class="my-1">Productwise Delivery Charge</label>
</div>

{{-- Enable Quantitywise Delivery Charge --}}
<div class="checkbox checkbox-secondary ml-3">
<input type="hidden" name="show_option[quantitywise_delivery_charge]" value="0">
<x-checkbox id="quantitywise-delivery-charge" name="show_option[quantitywise_delivery_charge]" value="1"
:checked="!!($show_option->quantitywise_delivery_charge ?? false)" />
<x-checkbox id="quantitywise-delivery-charge" name="show_option[quantitywise_delivery_charge]"
value="1" :checked="!!($show_option->quantitywise_delivery_charge ?? (false ?? false))" />
<label for="quantitywise-delivery-charge" class="my-1">Quantitywise Delivery Charge</label>
</div>
</div>
Expand All @@ -86,7 +93,7 @@
<div class="col-md-8">
<div class="form-group">
<label for="">Scroll Text</label>
<x-textarea name="scroll_text" id="scroll_text">{{$scroll_text ?? null}}</x-textarea>
<x-textarea name="scroll_text" id="scroll_text">{{ $scroll_text ?? null }}</x-textarea>
<x-error field="scroll_text" />
</div>
</div>
Expand Down Expand Up @@ -136,9 +143,10 @@
<label for="product-sort">Product Sorted By</label>
@php $sorted = $show_option->product_sort ?? false; @endphp
<select name="show_option[product_sort]" id="product-sort" class="form-control">
<option value="random" @if($sorted == 'random') selected @endif>Random</option>
<option value="updated_at" @if($sorted == 'updated_at') selected @endif>Last Update</option>
<option value="selling_price" @if($sorted == 'selling_price') selected @endif>Cheap Price</option>
<option value="random" @if ($sorted == 'random') selected @endif>Random</option>
<option value="updated_at" @if ($sorted == 'updated_at') selected @endif>Last Update</option>
<option value="selling_price" @if ($sorted == 'selling_price') selected @endif>Cheap Price
</option>
</select>
</div>
</div>
Expand All @@ -164,8 +172,7 @@
</div>
<div class="checkbox checkbox-secondary">
<input type="hidden" name="services[enabled]" value="0">
<x-checkbox id="services" name="services[enabled]" value="1"
:checked="!!($services->enabled ?? false)" />
<x-checkbox id="services" name="services[enabled]" value="1" :checked="!!($services->enabled ?? false)" />
<label for="services" class="my-1">`Services` Section</label>
</div>
<div class="checkbox checkbox-secondary">
Expand All @@ -190,26 +197,28 @@
</div>
</div>
<div class="row">
@foreach(config('services.services', []) as $num => $icon)
<div class="col-md-6">
<div class="input-group">
<div class="input-group-prepend mr-1">
<span class="input-group-text">
<svg width="24px" height="24px"><use xlink:href="{{ asset($icon) }}"></use></svg>
</span>
</div>
<div class="" style="flex: 1;">
<div class="form-group mb-1">
<label for="" class="ml-1">Title</label>
<x-input name="services[{{ $num }}][title]" :value="$services->$num->title ?? ''" />
@foreach (config('services.services', []) as $num => $icon)
<div class="col-md-6">
<div class="input-group">
<div class="input-group-prepend mr-1">
<span class="input-group-text">
<svg width="24px" height="24px">
<use xlink:href="{{ asset($icon) }}"></use>
</svg>
</span>
</div>
<div class="form-group mt-2 mb-0">
<label for="" class="ml-1">Detail</label>
<x-input name="services[{{ $num }}][detail]" :value="$services->$num->detail ?? ''" />
<div class="" style="flex: 1;">
<div class="form-group mb-1">
<label for="" class="ml-1">Title</label>
<x-input name="services[{{ $num }}][title]" :value="$services->$num->title ?? ''" />
</div>
<div class="form-group mt-2 mb-0">
<label for="" class="ml-1">Detail</label>
<x-input name="services[{{ $num }}][detail]" :value="$services->$num->detail ?? ''" />
</div>
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
4 changes: 2 additions & 2 deletions resources/views/livewire/checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
<div class="form-control @error('shipping') is-invalid @enderror h-auto">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" wire:model="shipping" class="custom-control-input" id="inside-dhaka" name="shipping" value="Inside Dhaka">
<label class="custom-control-label" for="inside-dhaka">ঢাকা শহর @if(!setting('show_option')->productwise_delivery_charge) ({{ $isFreeDelivery ? 'FREE' : setting('delivery_charge')->inside_dhaka }} টাকা) @endif</label>
<label class="custom-control-label" for="inside-dhaka">ঢাকা শহর @if(!setting('show_option')->productwise_delivery_charge ?? false) ({{ $isFreeDelivery ? 'FREE' : setting('delivery_charge')->inside_dhaka }} টাকা) @endif</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" wire:model="shipping" class="custom-control-input" id="outside-dhaka" name="shipping" value="Outside Dhaka">
<label class="custom-control-label" for="outside-dhaka">ঢাকার বাইরে @if(!setting('show_option')->productwise_delivery_charge) ({{ $isFreeDelivery ? 'FREE' : setting('delivery_charge')->outside_dhaka }} টাকা) @endif</label>
<label class="custom-control-label" for="outside-dhaka">ঢাকার বাইরে @if(!setting('show_option')->productwise_delivery_charge ?? false) ({{ $isFreeDelivery ? 'FREE' : setting('delivery_charge')->outside_dhaka }} টাকা) @endif</label>
</div>
</div>
<x-error field="shipping" />
Expand Down
2 changes: 1 addition & 1 deletion resources/views/products/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
</div>
<div id="collapseTwo" class="collapse show" data-parent="#accordion">
<div class="card-body p-2">
{!! setting('show_option')->productwise_delivery_charge ? ($product->delivery_text ?? setting('delivery_text')) : setting('delivery_text') !!}
{!! (setting('show_option')->productwise_delivery_charge ?? false) ? ($product->delivery_text ?? setting('delivery_text')) : setting('delivery_text') !!}
</div>
</div>
</div>
Expand Down

0 comments on commit bbdfc7b

Please sign in to comment.