designing process to get suitable discount rules
This commit is contained in:
parent
79ba3ebcf3
commit
4ab1e86d98
|
|
@ -19,6 +19,10 @@ class CustomerGroupTableSeeder extends Seeder
|
|||
'id' => 2,
|
||||
'name' => 'Wholesale',
|
||||
'is_user_defined' => 0,
|
||||
], [
|
||||
'id' => 3,
|
||||
'name' => 'Not Logged In',
|
||||
'is_user_defined' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,6 @@ class CustomerController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
dd(auth()->guard('customer')->user()->group);
|
||||
$customer = $this->customer->find(auth()->guard('customer')->user()->id);
|
||||
|
||||
return view($this->_config['view'], compact('customer'));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Discount\Helpers;
|
||||
|
||||
use Webkul\Discount\Repositories\CartRuleRepository as CartRule;
|
||||
|
||||
class Discount
|
||||
{
|
||||
/**
|
||||
* To hold the cart rule repository instance
|
||||
*/
|
||||
protected $cartRule;
|
||||
|
||||
public function __construct(CartRule $cartRule)
|
||||
{
|
||||
$this->cartRule = $cartRule;
|
||||
}
|
||||
|
||||
public function checkCoupon()
|
||||
{
|
||||
foreach($this->cartRule->all() as $rule) {
|
||||
return $rule->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function findAllRules()
|
||||
{
|
||||
$rules = $this->cartRule->all();
|
||||
|
||||
$channel = core()->getCurrentChannel();
|
||||
$locales = $channel->locales;
|
||||
}
|
||||
}
|
||||
|
|
@ -124,6 +124,11 @@ class CartRuleController extends Controller
|
|||
|
||||
$data = request()->all();
|
||||
|
||||
if ($data['starts_from'] == "" || $data['ends_till'] == "") {
|
||||
$data['starts_from'] = null;
|
||||
$data['ends_till'] = null;
|
||||
}
|
||||
|
||||
unset($data['_token']);
|
||||
|
||||
$channels = $data['channels'];
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ use Webkul\Shop\Http\Controllers\Controller;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Core\Repositories\SliderRepository;
|
||||
|
||||
use Webkul\Discount\Repositories\CartRuleRepository as CartRule;
|
||||
use Carbon\Carbon;
|
||||
/**
|
||||
* Home page controller
|
||||
*
|
||||
|
|
@ -21,11 +22,15 @@ use Webkul\Core\Repositories\SliderRepository;
|
|||
|
||||
protected $current_channel;
|
||||
|
||||
public function __construct(SliderRepository $sliderRepository)
|
||||
protected $cartRule;
|
||||
|
||||
public function __construct(SliderRepository $sliderRepository, CartRule $cartRule)
|
||||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->sliderRepository = $sliderRepository;
|
||||
|
||||
$this->cartRule = $cartRule;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -35,6 +40,64 @@ use Webkul\Core\Repositories\SliderRepository;
|
|||
{
|
||||
$currentChannel = core()->getCurrentChannel();
|
||||
|
||||
$rules = $this->cartRule->findWhere(['status' => 1, 'end_other_rules' => 1]);
|
||||
|
||||
$suitableRules = array();
|
||||
if ($rules->count() == 0) {
|
||||
$rules = $this->cartRule->findWhere(['status' => 1]);
|
||||
} else {
|
||||
foreach ($rules as $rule) {
|
||||
foreach($rule->channels as $channel) {
|
||||
if ($channel->channel_id == $currentChannel->id) {
|
||||
if (auth()->guard('customer')->check()) {
|
||||
foreach ($rule->customer_groups as $customerGroup) {
|
||||
if (auth()->guard('customer')->user()->customer_group_id == $customerGroup->customer_group_id)
|
||||
array_push($suitableRules, $rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// suitable rules will now be checked against the
|
||||
if (count($suitableRules) == 1) {
|
||||
$rule = reset($suitableRules);
|
||||
} else if (count($suitableRules) > 1) {
|
||||
$priorities = array();
|
||||
|
||||
$leastPriority = 999999999999;
|
||||
foreach ($suitableRules as $rule) {
|
||||
if ($leastPriority > $rule->priority) {
|
||||
$leastPriority = $rule->priority;
|
||||
}
|
||||
}
|
||||
|
||||
$leastId = 999999999999;
|
||||
foreach ($suitableRules as $rule) {
|
||||
if ($rule->id < $leastId) {
|
||||
$leastId = $rule->id;
|
||||
}
|
||||
}
|
||||
|
||||
if ($leastId != 999999999999) {
|
||||
$rule = $this->cartRule->find($leastId);
|
||||
}
|
||||
}
|
||||
// foreach($rules as $rule) {
|
||||
// foreach($rule->channels as $channel) {
|
||||
|
||||
// }
|
||||
// $starts_from = Carbon::parse($rule->starts_from);
|
||||
// $ends_till = Carbon::parse($rule->ends_till);
|
||||
|
||||
// $now = Carbon::now();
|
||||
|
||||
// if ($now->greaterThanOrEqualTo($starts_from) && $now->lessThanOrEqualTo($ends_till)) {
|
||||
// dd('date time matched');
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
$sliderData = $this->sliderRepository->findByField('channel_id', $currentChannel->id)->toArray();
|
||||
|
||||
return view($this->_config['view'], compact('sliderData'));
|
||||
|
|
|
|||
|
|
@ -38,6 +38,116 @@ input {
|
|||
border-radius: 0px !important;
|
||||
}
|
||||
|
||||
//margin bottom classes
|
||||
.mb-10 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.mb-15 {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.mb-20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.mb-25 {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.mb-30 {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.mb-35 {
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
|
||||
.mb-40 {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.mb-45 {
|
||||
margin-bottom: 45px;
|
||||
}
|
||||
|
||||
.mb-50 {
|
||||
margin-bottom: 50px;
|
||||
}
|
||||
|
||||
.mb-60 {
|
||||
margin-bottom: 60px;
|
||||
}
|
||||
|
||||
.mb-70 {
|
||||
margin-bottom: 70px;
|
||||
}
|
||||
|
||||
.mb-80 {
|
||||
margin-bottom: 80px;
|
||||
}
|
||||
|
||||
.mb-90 {
|
||||
margin-bottom: 90px;
|
||||
}
|
||||
|
||||
//margin-top
|
||||
.mt-5 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.mt-10 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.mt-15 {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.mt-20 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.mt-25 {
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
.mt-30 {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.mt-35 {
|
||||
margin-top: 35px;
|
||||
}
|
||||
|
||||
.mt-40 {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.mt-45 {
|
||||
margin-top: 45px;
|
||||
}
|
||||
|
||||
.mt-50 {
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.mt-60 {
|
||||
margin-top: 60px;
|
||||
}
|
||||
|
||||
.mt-70 {
|
||||
margin-top: 70px;
|
||||
}
|
||||
|
||||
.mt-80 {
|
||||
margin-top: 80px;
|
||||
}
|
||||
|
||||
.mt-90 {
|
||||
margin-top: 90px;
|
||||
}
|
||||
|
||||
//pagination
|
||||
.pagination.shop{
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -165,9 +165,7 @@
|
|||
</div>
|
||||
|
||||
<div class="pull-right" style="width: 40%; float: left;">
|
||||
|
||||
@include('shop::checkout.total.summary', ['cart' => $cart])
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -28,4 +28,12 @@
|
|||
<label>{{ __('shop::app.checkout.total.grand-total') }}</label>
|
||||
<label class="right">{{ core()->currency($cart->base_grand_total) }}</label>
|
||||
</div>
|
||||
|
||||
<div class="discount">
|
||||
<div class="dicount-group">
|
||||
@inject('cart_rule', 'Webkul\Discount\Helpers\Discount')
|
||||
|
||||
{{ $cart_rule->findAllRules() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -75,38 +75,19 @@
|
|||
<div class="control-group">
|
||||
<select class="control locale-switcher" onchange="window.location.href = this.value">
|
||||
|
||||
@foreach (core()->getCurrentChannel()->locales as $locale)
|
||||
@foreach (core()->getCurrentChannel()->currencies as $currency)
|
||||
@if(isset($serachQuery))
|
||||
<option value="?{{ $serachQuery }}?locale={{ $locale->code }}" {{ $locale->code == app()->getLocale() ? 'selected' : '' }}>{{ $locale->name }}</option>
|
||||
<option value="?{{ $serachQuery }}?currency={{ $currency->code }}" {{ $currency->code == core()->getCurrentCurrencyCode() ? 'selected' : '' }}>{{ $currency->code }}</option>
|
||||
@else
|
||||
<option value="?locale={{ $locale->code }}" {{ $locale->code == app()->getLocale() ? 'selected' : '' }}>{{ $locale->name }}</option>
|
||||
<option value="?currency={{ $currency->code }}" {{ $currency->code == core()->getCurrentCurrencyCode() ? 'selected' : '' }}>{{ $currency->code }}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if(count(core()->getCurrentChannel()->currencies) > 1)
|
||||
<div class="currency">
|
||||
<span class="list-heading">{{ __('shop::app.footer.currency') }}</span>
|
||||
<div class="form-container">
|
||||
<div class="control-group">
|
||||
<select class="control locale-switcher" onchange="window.location.href = this.value">
|
||||
|
||||
@foreach (core()->getCurrentChannel()->currencies as $currency)
|
||||
@if(isset($serachQuery))
|
||||
<option value="?{{ $serachQuery }}?currency={{ $currency->code }}" {{ $currency->code == core()->getCurrentCurrencyCode() ? 'selected' : '' }}>{{ $currency->code }}</option>
|
||||
@else
|
||||
<option value="?currency={{ $currency->code }}" {{ $currency->code == core()->getCurrentCurrencyCode() ? 'selected' : '' }}>{{ $currency->code }}</option>
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,21 +1,22 @@
|
|||
@if ($product->type == "configurable")
|
||||
<div class="cart-wish-wrap">
|
||||
<a href="{{ route('cart.add.configurable', $product->url_key) }}" class="btn btn-lg btn-primary addtocart">
|
||||
{{ __('shop::app.products.add-to-cart') }}
|
||||
</a>
|
||||
|
||||
@include('shop::products.wishlist')
|
||||
</div>
|
||||
@else
|
||||
<div class="cart-wish-wrap">
|
||||
<form action="{{ route('cart.add', $product->product_id) }}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="product" value="{{ $product->product_id }}">
|
||||
<input type="hidden" name="quantity" value="1">
|
||||
<input type="hidden" value="false" name="is_configurable">
|
||||
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
|
||||
</form>
|
||||
@if ($product->type == "configurable")
|
||||
<div class="cart-wish-wrap">
|
||||
<a href="{{ route('cart.add.configurable', $product->url_key) }}" class="btn btn-lg btn-primary addtocart">
|
||||
{{ __('shop::app.products.add-to-cart') }}
|
||||
</a>
|
||||
|
||||
@include('shop::products.wishlist')
|
||||
</div>
|
||||
@endif
|
||||
@include('shop::products.wishlist')
|
||||
</div>
|
||||
@else
|
||||
<div class="cart-wish-wrap">
|
||||
<form action="{{ route('cart.add', $product->product_id) }}" method="POST">
|
||||
@csrf
|
||||
<input type="hidden" name="product" value="{{ $product->product_id }}">
|
||||
<input type="hidden" name="quantity" value="1">
|
||||
<input type="hidden" value="false" name="is_configurable">
|
||||
<button class="btn btn-lg btn-primary addtocart" {{ $product->haveSufficientQuantity(1) ? '' : 'disabled' }}>{{ __('shop::app.products.add-to-cart') }}</button>
|
||||
</form>
|
||||
|
||||
@include('shop::products.wishlist')
|
||||
</div>
|
||||
@endif
|
||||
|
|
@ -70,7 +70,9 @@
|
|||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.products.index.pagination.after') !!}
|
||||
|
||||
@else
|
||||
|
||||
<div class="product-list empty">
|
||||
<h2>{{ __('shop::app.products.whoops') }}</h2>
|
||||
|
||||
|
|
@ -78,6 +80,7 @@
|
|||
{{ __('shop::app.products.empty') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
|
|
@ -91,16 +94,13 @@
|
|||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.responsive-layred-filter').css('display','none');
|
||||
|
||||
$(".sort-icon, .filter-icon").on('click', function(e){
|
||||
var currentElement = $(e.currentTarget);
|
||||
|
||||
if (currentElement.hasClass('sort-icon')) {
|
||||
currentElement.removeClass('sort-icon');
|
||||
currentElement.addClass('icon-menu-close-adj');
|
||||
currentElement.next().removeClass();
|
||||
currentElement.next().addClass('icon filter-icon');
|
||||
|
||||
$('.responsive-layred-filter').css('display','none');
|
||||
$('.pager').css('display','flex');
|
||||
$('.pager').css('justify-content','space-between');
|
||||
|
|
@ -109,7 +109,6 @@
|
|||
currentElement.addClass('icon-menu-close-adj');
|
||||
currentElement.prev().removeClass();
|
||||
currentElement.prev().addClass('icon sort-icon');
|
||||
|
||||
$('.pager').css('display','none');
|
||||
$('.responsive-layred-filter').css('display','block');
|
||||
$('.responsive-layred-filter').css('margin-top','10px');
|
||||
|
|
@ -117,7 +116,6 @@
|
|||
currentElement.removeClass('icon-menu-close-adj');
|
||||
$('.responsive-layred-filter').css('display','none');
|
||||
$('.pager').css('display','none');
|
||||
|
||||
if ($(this).index() == 0) {
|
||||
currentElement.addClass('sort-icon');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
@include ('shop::products.view.gallery')
|
||||
|
||||
<div class="details">
|
||||
|
||||
<div class="product-heading">
|
||||
<span>{{ $product->name }}</span>
|
||||
</div>
|
||||
|
|
@ -116,6 +117,7 @@
|
|||
<script>
|
||||
|
||||
Vue.component('product-view', {
|
||||
|
||||
template: '#product-view-template',
|
||||
|
||||
inject: ['$validator'],
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@
|
|||
{!! view_render_event('bagisto.shop.products.view.gallery.before', ['product' => $product]) !!}
|
||||
|
||||
<div class="product-image-group">
|
||||
|
||||
<div class="cp-spinner cp-round" id="loader">
|
||||
</div>
|
||||
|
||||
<product-gallery></product-gallery>
|
||||
|
||||
@include ('shop::products.view.product-add')
|
||||
|
||||
</div>
|
||||
|
||||
{!! view_render_event('bagisto.shop.products.view.gallery.after', ['product' => $product]) !!}
|
||||
|
|
@ -18,6 +20,7 @@
|
|||
|
||||
<script type="text/x-template" id="product-gallery-template">
|
||||
<div>
|
||||
|
||||
<ul class="thumb-list">
|
||||
<li class="gallery-control top" @click="moveThumbs('top')" v-if="(thumbs.length > 4) && this.is_move.up">
|
||||
<span class="overlay"></span>
|
||||
|
|
@ -53,18 +56,25 @@
|
|||
|
||||
template: '#product-gallery-template',
|
||||
|
||||
data: () => ({
|
||||
images: galleryImages,
|
||||
thumbs: [],
|
||||
currentLargeImageUrl: '',
|
||||
currentOriginalImageUrl: '',
|
||||
counter: {
|
||||
up: 0,
|
||||
down: 0,
|
||||
},
|
||||
is_move: {
|
||||
up: true,
|
||||
down: true,
|
||||
data: function() {
|
||||
return {
|
||||
images: galleryImages,
|
||||
|
||||
thumbs: [],
|
||||
|
||||
currentLargeImageUrl: '',
|
||||
|
||||
currentOriginalImageUrl: '',
|
||||
|
||||
counter: {
|
||||
up: 0,
|
||||
down: 0,
|
||||
},
|
||||
|
||||
is_move: {
|
||||
up: true,
|
||||
down: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -85,6 +95,7 @@
|
|||
methods: {
|
||||
prepareThumbs: function() {
|
||||
var this_this = this;
|
||||
|
||||
this_this.thumbs = [];
|
||||
|
||||
this.images.forEach(function(image) {
|
||||
|
|
@ -94,6 +105,7 @@
|
|||
|
||||
changeImage: function(image) {
|
||||
this.currentLargeImageUrl = image.large_image_url;
|
||||
|
||||
this.currentOriginalImageUrl = image.original_image_url;
|
||||
|
||||
$('img#pro-img').data('zoom-image', image.original_image_url).ezPlus();
|
||||
|
|
@ -106,15 +118,19 @@
|
|||
const moveThumb = this.thumbs.splice(len - 1, 1);
|
||||
|
||||
this.thumbs = [moveThumb[0]].concat((this.thumbs));
|
||||
this.counter.up = this.counter.up + 1;
|
||||
this.counter.down = this.counter.down - 1;
|
||||
|
||||
this.counter.up = this.counter.up+1;
|
||||
|
||||
this.counter.down = this.counter.down-1;
|
||||
|
||||
} else {
|
||||
const moveThumb = this.thumbs.splice(0, 1);
|
||||
|
||||
this.thumbs = [].concat((this.thumbs), [moveThumb[0]]);
|
||||
this.counter.down = this.counter.down + 1;
|
||||
this.counter.up = this.counter.up - 1;
|
||||
|
||||
this.counter.down = this.counter.down+1;
|
||||
|
||||
this.counter.up = this.counter.up-1;
|
||||
}
|
||||
|
||||
if ((len-4) == this.counter.down) {
|
||||
|
|
@ -141,6 +157,7 @@
|
|||
$(document).mousemove(function(event) {
|
||||
if ($('.add-to-wishlist').length) {
|
||||
if (event.pageX > $('.add-to-wishlist').offset().left && event.pageX < $('.add-to-wishlist').offset().left+32 && event.pageY > $('.add-to-wishlist').offset().top && event.pageY < $('.add-to-wishlist').offset().top+32) {
|
||||
|
||||
$(".zoomContainer").addClass("show-wishlist");
|
||||
|
||||
} else {
|
||||
|
|
@ -156,4 +173,5 @@
|
|||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
|
@ -6,4 +6,4 @@
|
|||
</a>
|
||||
|
||||
{!! view_render_event('bagisto.shop.products.wishlist.after') !!}
|
||||
@endauth
|
||||
@endauth
|
||||
|
|
|
|||
Loading…
Reference in New Issue