price variant
This commit is contained in:
parent
7173d2c117
commit
695494a2d9
14
.env.example
14
.env.example
|
|
@ -20,12 +20,12 @@ LOG_STACK=single
|
|||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
DB_CONNECTION=pgsql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=asiagolf
|
||||
DB_USERNAME=postgres
|
||||
DB_PASSWORD=12345678
|
||||
|
||||
SESSION_DRIVER=file
|
||||
SESSION_LIFETIME=120
|
||||
|
|
@ -37,7 +37,7 @@ BROADCAST_CONNECTION=log
|
|||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
CACHE_STORE=file
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ class ProductController extends Controller
|
|||
|
||||
$product = Items::where('slug', $slug)->first();
|
||||
|
||||
|
||||
if ($product == null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$complete_look_products_data = $productRepository->getList([
|
||||
'category_id' => $product->category1_id,
|
||||
'limit' => 4,
|
||||
|
|
|
|||
|
|
@ -72,50 +72,7 @@ class ItemVariant extends Model
|
|||
return $this->belongsTo(Items::class, 'item_id');
|
||||
}
|
||||
|
||||
public function conversion_value()
|
||||
{
|
||||
$item = $this->item;
|
||||
|
||||
$convertion = 1;
|
||||
if (($item->display_unit != $item->unit) and ($item->display_unit)){
|
||||
$convertions = DB::select("select to_qty / from_qty as conv
|
||||
from item_convertions where from_unit = ? and to_unit = ?",
|
||||
[$item->display_unit, $item->unit] );
|
||||
$convertion = max((float) @$convertions[0]->conv,1);
|
||||
}
|
||||
|
||||
return $convertion;
|
||||
}
|
||||
|
||||
|
||||
public function getDisplayPriceAttribute()
|
||||
{
|
||||
try {
|
||||
$convertion = $this->conversion_value();
|
||||
|
||||
$price = $this->reference->price->price ?? null;
|
||||
$price = $price ? $price : $this->item->net_price;
|
||||
|
||||
|
||||
|
||||
return (float) $price * $convertion;
|
||||
} catch (\Exception $e) {
|
||||
Log::info($e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getDisplayDiscountPriceAttribute()
|
||||
{
|
||||
try {
|
||||
$convertion = $this->conversion_value();
|
||||
|
||||
$discountPrice = @$this->discount->price ?? 0;
|
||||
return (float) $discountPrice * $convertion;
|
||||
} catch (\Exception $e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,20 +3,18 @@
|
|||
namespace App\Repositories\Catalog;
|
||||
|
||||
use App\Models\Brand;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Image;
|
||||
use Storage;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BrandRepository
|
||||
{
|
||||
public function getList($params)
|
||||
{
|
||||
return Cache::remember('catalog_brand_'.json_encode($params), 60, function () use ($params) {
|
||||
|
||||
public function getList($params){
|
||||
return Cache::remember("catalog_brand_".json_encode($params),60, function() use ($params) {
|
||||
|
||||
$category_id = @$params["category_id"];
|
||||
if ($category_id){
|
||||
$ids = DB::select("select distinct brand from store_category_map a
|
||||
$category_id = @$params['category_id'];
|
||||
if ($category_id) {
|
||||
$ids = DB::select('select distinct brand from store_category_map a
|
||||
left join item_dimension b
|
||||
left join items on b.no = items.number
|
||||
on a.category1 = b.category1
|
||||
|
|
@ -24,17 +22,19 @@ class BrandRepository
|
|||
and (a.category3 = b.category3 or a.category3 is null)
|
||||
and (a.category4 = b.category4 or a.category4 is null)
|
||||
where store_category_id = ?
|
||||
and items.is_publish = true ",[$category_id]);
|
||||
$ids = collect($ids)->pluck("brand");
|
||||
return Brand::whereIn("name",$ids)->orderBy('priority', 'desc')
|
||||
->where("priority",">",0)
|
||||
->orderBy('name', 'asc')->get();
|
||||
}
|
||||
return Brand::orderBy('priority', 'desc')->orderBy('name', 'asc')
|
||||
->where("priority",">",0)
|
||||
->get();
|
||||
and items.is_publish = true ', [$category_id]);
|
||||
$ids = collect($ids)->pluck('brand');
|
||||
|
||||
});
|
||||
return Brand::whereIn('name', $ids)->orderBy('priority', 'desc')
|
||||
->where('priority', '>', 0)
|
||||
->orderBy('name', 'asc')->get();
|
||||
}
|
||||
|
||||
return Brand::orderBy('priority', 'desc')->orderBy('name', 'asc')
|
||||
->where('priority', '>', 0)
|
||||
->get();
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Illuminate\View\View;
|
|||
|
||||
class LocationSelector extends Component
|
||||
{
|
||||
public Location $selected;
|
||||
public ?Location $selected;
|
||||
|
||||
public $locations;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use Illuminate\View\View;
|
|||
|
||||
class LocationSelectorSidebar extends Component
|
||||
{
|
||||
public Location $selected;
|
||||
public ?Location $selected;
|
||||
|
||||
public $locations;
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ return [
|
|||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
'sslmode' => 'disable',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
aria-label="Add to Wishlist">
|
||||
<i class="ci-heart animate-target"></i>
|
||||
</button>
|
||||
<a class="d-flex bg-body-tertiary rounded p-3" href="{{ route('product.detail', $product->slug) }}">
|
||||
<a class="d-flex bg-body-tertiary rounded p-3" href="{{ route('product.detail', $product->slug ?? '0') }}">
|
||||
<div class="ratio" style="--cz-aspect-ratio: calc(308 / 274 * 100%)">
|
||||
<img src="{{ $product->image_url }}" loading="lazy" class="w-100 h-100 object-cover">
|
||||
</div>
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
</div>
|
||||
<div class="nav mb-2">
|
||||
<a class="nav-link animate-target min-w-0 text-dark-emphasis p-0"
|
||||
href="{{ route('product.detail', $product->slug) }}">
|
||||
href="{{ route('product.detail', $product->slug ?? '0') }}">
|
||||
<span class="text-truncate">{{ $product->name ?? '' }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@
|
|||
|
||||
<!-- LOcation selector visible on screens > 768px wide (md breakpoint) -->
|
||||
<x-location-selector />
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Navbar brand (Logo) -->
|
||||
|
|
|
|||
|
|
@ -1809,21 +1809,23 @@
|
|||
@endif
|
||||
<div class="h4 d-flex align-items-center my-4">
|
||||
<span class="display_price">Rp {{ number_format($product->display_price, 0, ',', '.') }}</span>
|
||||
|
||||
|
||||
|
||||
<del class="display_discount_price fs-sm fw-normal text-body-tertiary ms-2" style="display: {{ $product->discount_display_price ? 'inline' : 'none' }};">{{ $product->discount_display_price ? ' Rp ' . number_format($product->discount_display_price, 0, ',', '.') : '' }}</del>
|
||||
<del class="display_discount_price fs-sm fw-normal text-body-tertiary ms-2" style="display: {{ $product->display_discount_price ? 'inline' : 'none' }};">{{ $product->display_discount_price ? ' Rp ' . number_format($product->display_discount_price, 0, ',', '.') : '' }}</del>
|
||||
</div>
|
||||
|
||||
<!-- Color options -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-semibold pb-1 mb-2">Varian: <span class="text-body fw-normal"
|
||||
id="colorOption">{{ $product->variants->first()->description ?? '' }}</span></label>
|
||||
<div class="d-flex flex-wrap gap-2" data-binded-label="#colorOption">
|
||||
id="variantOption">{{ $product->variants->first()->description ?? '' }}</span></label>
|
||||
<div class="d-flex flex-wrap gap-2" data-binded-label="#variantOption">
|
||||
|
||||
@foreach ($product->variants as $key => $variant)
|
||||
<input type="radio" class="btn-check" name="colors" id="variant-id-{{ $variant->id }}" {{ $key == 0 ? 'checked' : '' }}>
|
||||
<label for="variant-id-{{ $variant->id }}" class="btn btn-image p-0" data-label="{{ $variant->description }}"
|
||||
data-price="Rp {{ number_format($variant->display_price, 0, ",",".") }}"
|
||||
data-discount-price="{{ $variant->discount_display_price ? 'Rp ' . number_format($variant->discount_display_price, 0, ',', '.') : '' }}"
|
||||
data-price="Rp {{ number_format($product->display_price, 0, ",",".") }}"
|
||||
data-discount-price="{{ $product->display_discount_price ? 'Rp ' . number_format($product->display_discount_price, 0, ',', '.') : '' }}"
|
||||
data-image="{{ $variant->image_url ?? $product->image_url }}"
|
||||
>
|
||||
<img src="{{ $variant->image_url ?? $product->image_url }}" width="56"
|
||||
|
|
@ -1921,17 +1923,17 @@
|
|||
<div class="navbar container flex-nowrap align-items-center bg-body pt-4 pt-lg-5 mt-lg-n2">
|
||||
<div class="d-flex align-items-center min-w-0 ms-lg-2 me-3">
|
||||
<div class="ratio ratio-1x1 flex-shrink-0" style="width: 50px">
|
||||
<img src="/img/shop/fashion/product/thumb.png" alt="Image">
|
||||
<img src="{{ $product->image_url ?? '' }}" class="product-main-image" alt="Image">
|
||||
</div>
|
||||
<h4 class="h6 fw-medium d-none d-lg-block ps-3 mb-0">Denim midi skirt with pockets</h4>
|
||||
<h4 class="h6 fw-medium d-none d-lg-block ps-3 mb-0 variantOption">{{ $product->name }}</h4>
|
||||
<div class="w-100 min-w-0 d-lg-none ps-2">
|
||||
<h4 class="fs-sm fw-medium text-truncate mb-1">Denim midi skirt with pockets</h4>
|
||||
<h4 class="fs-sm fw-medium text-truncate mb-1 variantOption">{{ $product->name }}</h4>
|
||||
<div class="h6 mb-0">$126.50 <del class="fs-xs fw-normal text-body-tertiary">$156.00</del>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="h4 d-none d-lg-block mb-0 ms-auto me-4">$126.50 <del
|
||||
class="fs-sm fw-normal text-body-tertiary">$156.00</del></div>
|
||||
<div class="h4 d-none d-lg-block mb-0 ms-auto me-4 display_price">Rp {{ number_format($product->display_price,0,",",".") }} <del
|
||||
class="fs-sm fw-normal text-body-tertiary display_discount_price" style="display: {{ $product->display_discount_price ? 'inline' : 'none' }};">Rp {{ number_format($product->display_discount_price,0,",",".") }}</del></div>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="button" class="btn btn-icon btn-secondary animate-pulse"
|
||||
aria-label="Add to Wishlist">
|
||||
|
|
@ -3024,7 +3026,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||
discountSpan.style.display = 'none';
|
||||
}
|
||||
document.querySelector('.product-main-image').src = image;
|
||||
document.querySelector('#colorOption').textContent = labelText;
|
||||
document.querySelector('.variantOption').textContent = labelText;
|
||||
});
|
||||
});
|
||||
// Trigger change for the initially checked radio
|
||||
|
|
|
|||
Loading…
Reference in New Issue