Merge pull request #3714 from shubhwebkul/patch-1
compare count update in default theme
This commit is contained in:
commit
07c6832ab2
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
$attributeOptionTranslations = DB::table(DB::getTablePrefix() . 'attribute_option_translations')->where('locale', $locale)->get()->toJson();
|
||||
$attributeOptionTranslations = DB::table('attribute_option_translations')->where('locale', $locale)->get()->toJson();
|
||||
@endphp
|
||||
|
||||
@push('scripts')
|
||||
|
|
@ -230,6 +230,8 @@
|
|||
|
||||
this.$root.addFlashMessages();
|
||||
}
|
||||
|
||||
this.updateCompareCount();
|
||||
},
|
||||
|
||||
'getDynamicHTML': function (input) {
|
||||
|
|
@ -311,6 +313,28 @@
|
|||
}
|
||||
|
||||
return attributeOptions;
|
||||
},
|
||||
|
||||
'updateCompareCount': function () {
|
||||
if (this.isCustomer == "true" || this.isCustomer == true) {
|
||||
this.$http.get(`${this.baseUrl}/items-count`)
|
||||
.then(response => {
|
||||
$('#compare-items-count').html(response.data.compareProductsCount);
|
||||
})
|
||||
.catch(exception => {
|
||||
window.flashMessages = [{
|
||||
'type': `alert-error`,
|
||||
'message': "{{ __('shop::app.common.error') }}"
|
||||
}];
|
||||
|
||||
this.$root.addFlashMessages();
|
||||
});
|
||||
} else {
|
||||
let comparedItems = JSON.parse(localStorage.getItem('compared_product'));
|
||||
comparedItemsCount = comparedItems ? comparedItems.length : 0;
|
||||
|
||||
$('#compare-items-count').html(comparedItemsCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -336,8 +336,22 @@
|
|||
toggleDropdown(e);
|
||||
});
|
||||
|
||||
let comparedItems = JSON.parse(localStorage.getItem('compared_product'));
|
||||
$('#compare-items-count').append(comparedItems.length);
|
||||
@auth('customer')
|
||||
@php
|
||||
$compareCount = app('Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository')
|
||||
->count([
|
||||
'customer_id' => auth()->guard('customer')->user()->id,
|
||||
]);
|
||||
@endphp
|
||||
|
||||
let comparedItems = JSON.parse(localStorage.getItem('compared_product'));
|
||||
$('#compare-items-count').html({{ $compareCount }});
|
||||
@endauth
|
||||
|
||||
@guest('customer')
|
||||
let comparedItems = JSON.parse(localStorage.getItem('compared_product'));
|
||||
$('#compare-items-count').html(comparedItems ? comparedItems.length : 0);
|
||||
@endguest
|
||||
|
||||
function toggleDropdown(e) {
|
||||
var currentElement = $(e.currentTarget);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
template: '#compare-component-template',
|
||||
|
||||
data: function () {
|
||||
data: function () {
|
||||
return {
|
||||
'baseUrl': "{{ url()->to('/') }}",
|
||||
'customer': '{{ auth()->guard('customer')->user() ? "true" : "false" }}' == "true",
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
'type': `alert-${response.data.status}`,
|
||||
'message': response.data.message
|
||||
}];
|
||||
|
||||
|
||||
this.$root.addFlashMessages()
|
||||
}).catch(error => {
|
||||
window.flashMessages = [{
|
||||
|
|
@ -82,6 +82,8 @@
|
|||
this.$root.addFlashMessages()
|
||||
}
|
||||
}
|
||||
|
||||
this.updateCompareCount();
|
||||
},
|
||||
|
||||
'getStorageValue': function (key) {
|
||||
|
|
@ -99,6 +101,28 @@
|
|||
|
||||
return true;
|
||||
},
|
||||
|
||||
'updateCompareCount': function () {
|
||||
if (this.customer == "true" || this.customer == true) {
|
||||
this.$http.get(`${this.baseUrl}/items-count`)
|
||||
.then(response => {
|
||||
$('#compare-items-count').html(response.data.compareProductsCount);
|
||||
})
|
||||
.catch(exception => {
|
||||
window.flashMessages = [{
|
||||
'type': `alert-error`,
|
||||
'message': "{{ __('shop::app.common.error') }}"
|
||||
}];
|
||||
|
||||
this.$root.addFlashMessages();
|
||||
});
|
||||
} else {
|
||||
let comparedItems = JSON.parse(localStorage.getItem('compared_product'));
|
||||
comparedItemsCount = comparedItems ? comparedItems.length : 0;
|
||||
|
||||
$('#compare-items-count').html(comparedItemsCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ class Controller extends BaseController
|
|||
* @param \Webkul\Category\Repositories\CategoryRepository $categoryRepository
|
||||
* @param \Webkul\Velocity\Repositories\Product\ProductRepository $velocityProductRepository
|
||||
* @param \Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository $compareProductsRepository
|
||||
* @param \Webkul\Velocity\Repositories\VelocityCustomerCompareProductRepository $compareProductsRepository
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
$locale = request()->get('locale') ?: app()->getLocale();
|
||||
|
||||
$attributeOptionTranslations = DB::table(DB::getTablePrefix() . 'attribute_option_translations')->where('locale', $locale)->get()->toJson();
|
||||
$attributeOptionTranslations = DB::table('attribute_option_translations')->where('locale', $locale)->get()->toJson();
|
||||
@endphp
|
||||
|
||||
@push('css')
|
||||
|
|
|
|||
Loading…
Reference in New Issue