Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Configurations and frontend changes #7468

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions packages/Webkul/Admin/src/Config/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,35 @@
'title' => 'admin::app.admin.system.allow-no-of-new-product-homepage',
'type' => 'number',
'validation' => 'min:0',
],
[
], [
'name' => 'no_of_featured_product_homepage',
'title' => 'admin::app.admin.system.allow-no-of-featured-product-homepage',
'type' => 'number',
'validation' => 'min:0',
],
],
], [
'key' => 'catalog.products.product-view-page',
'name' => 'admin::app.admin.system.product-view-page',
'sort' => 3,
'fields' => [
[
'name' => 'no_of_related_product_productpage',
'title' => 'admin::app.admin.system.allow-no-of-related-productpage',
'type' => 'number',
'validation' => 'min:0',
], [
'name' => 'no_of_up_sells_product_productpage',
'title' => 'admin::app.admin.system.allow-no-of-up-sells-productpage',
'type' => 'number',
'validation' => 'min:0',
], [
'name' => 'no_of_cross_sells_product_productpage',
'title' => 'admin::app.admin.system.allow-no-of-cross-sells-productpage',
'type' => 'number',
'validation' => 'min:0',
],
],
], [
'key' => 'catalog.products.storefront',
'name' => 'admin::app.admin.system.storefront',
Expand Down
5 changes: 5 additions & 0 deletions packages/Webkul/Admin/src/Resources/lang/en/app.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php

return [
Expand Down Expand Up @@ -1530,6 +1531,7 @@
'system' => [
'catalog' => 'Catalog',
'homepage' => 'Homepage configuration',
'product-view-page' => 'Product view page configuration',
'allow-out-of-stock-items' => 'Allow out of stock items',
'products' => 'Products',
'guest-checkout' => 'Guest Checkout',
Expand Down Expand Up @@ -1677,6 +1679,9 @@
'show-search-input-field' => 'Show Search Input Field',
'allow-no-of-new-product-homepage' => 'Allowed number of New Product in Homepage',
'allow-no-of-featured-product-homepage' => 'Allowed number of Featured Product in Homepage',
'allow-no-of-related-productpage' => 'Allowed number of Related Product in Productpage',
'allow-no-of-up-sells-productpage' => 'Allowed number of Up-Sells Product in Productpage',
'allow-no-of-cross-sells-productpage' => 'Allowed number of Cross-Sells Product in Productpage',
devansh-webkul marked this conversation as resolved.
Show resolved Hide resolved
'width' => 'Width',
'height' => 'Height',
'cache-small-image' => 'Small Image',
Expand Down
9 changes: 3 additions & 6 deletions packages/Webkul/Product/src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ public function booking_product()
*/
public function related_products(): BelongsToMany
{
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id')
->limit(4);
return $this->belongsToMany(static::class, 'product_relations', 'parent_id', 'child_id');
}

/**
Expand All @@ -316,8 +315,7 @@ public function related_products(): BelongsToMany
*/
public function up_sells(): BelongsToMany
{
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id')
->limit(4);
return $this->belongsToMany(static::class, 'product_up_sells', 'parent_id', 'child_id');
}

/**
Expand All @@ -327,8 +325,7 @@ public function up_sells(): BelongsToMany
*/
public function cross_sells(): BelongsToMany
{
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id')
->limit(4);
return $this->belongsToMany(static::class, 'product_cross_sells', 'parent_id', 'child_id');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@

<div class="related-products">
@include('shop::products.view.related-products')

@include('shop::products.view.up-sells')
@include('shop::products.view.cross-sells')
shivendra-webkul marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
@foreach ($cart->items as $item)
@php
$product = $item->product;
@php
$productCount = core()->getConfigData('catalog.products.product-view-page.no_of_cross_sells_product_productpage');
$products = $product->cross_sells()->take($productCount)->get();
@endphp
shivendra-webkul marked this conversation as resolved.
Show resolved Hide resolved

if ($product->cross_sells()->count()) {
$products[] = $product;
$products = array_unique($products);
}
@endphp
@endforeach

@if (isset($products))
@if ($products->count())
<card-list-header
heading="{{ __('shop::app.products.cross-sell-title') }}"
view-all="false"
Expand All @@ -23,17 +17,14 @@
pagination-enabled="hide"
id="upsell-products-carousel"
:slides-count="{{ $product->cross_sells()->count() }}">

@foreach($products as $product)
@foreach ($product->cross_sells()->paginate(2) as $index => $crossSellProduct)
@foreach ($products as $index => $crossSellProduct)
<slide slot="slide-{{ $index }}">
@include ('shop::products.list.card', [
'product' => $crossSellProduct,
'addToCartBtnClass' => 'small-padding',
])
</slide>
@endforeach
@endforeach
</carousel-component>
</div>

Expand All @@ -44,17 +35,14 @@
id="upsell-products-carousel"
navigation-enabled="hide"
pagination-enabled="hide">

@foreach($products as $product)
@foreach ($product->cross_sells()->paginate(2) as $index => $crossSellProduct)
@foreach ($products as $index => $crossSellProduct)
<slide slot="slide-{{ $index }}">
@include ('shop::products.list.card', [
'product' => $crossSellProduct,
'addToCartBtnClass' => 'small-padding',
])
</slide>
@endforeach
@endforeach
</carousel-component>
</div>
@endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
@php $relatedProducts = $product->related_products()->get(); @endphp
@php
$productCount = core()->getConfigData('catalog.products.product-view-page.no_of_related_product_productpage');
$relatedProducts = $product->related_products()->take($productCount)->get();
@endphp
shivendra-webkul marked this conversation as resolved.
Show resolved Hide resolved

@if ($relatedProducts->count())
<card-list-header
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
@php $productUpSells = $product->up_sells()->get(); @endphp
@php
$productCount = core()->getConfigData('catalog.products.product-view-page.no_of_up_sells_product_productpage');
$productUpSells = $product->up_sells()->take($productCount)->get();
@endphp
devansh-webkul marked this conversation as resolved.
Show resolved Hide resolved

@if ($productUpSells->count())
@if ($productUpSells->count())
<card-list-header
heading="{{ __('shop::app.products.up-sell-title') }}"
view-all="false"
Expand Down Expand Up @@ -41,6 +44,7 @@
'addToCartBtnClass' => 'small-padding',
])
</slide>

@endforeach
</carousel-component>
</div>
Expand Down