Merge remote-tracking branch 'upstream/master' into optimization

This commit is contained in:
devansh bawari 2021-01-13 19:54:15 +05:30
commit 266760d386
34 changed files with 294 additions and 1609 deletions

View File

@ -33,6 +33,7 @@
"intervention/image": "^2.4",
"intervention/imagecache": "^2.3",
"kalnoy/nestedset": "5.0.1",
"khaled.alshamaa/ar-php": "^5.5",
"konekt/concord": "^1.2",
"laravel/framework": "^7.0",
"laravel/scout": "^8.0",

1522
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,10 @@ class AttributeDataGrid extends DataGrid
->select('id')
->addSelect('id', 'code', 'admin_name', 'type', 'is_required', 'is_unique', 'value_per_locale', 'value_per_channel');
$this->addFilter('is_unique', 'is_unique');
$this->addFilter('value_per_locale', 'value_per_locale');
$this->addFilter('value_per_channel', 'value_per_channel');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -62,6 +62,8 @@ class CartRuleDataGrid extends DataGrid
$queryBuilder->where('cart_rule_channels.channel_id', $this->channel);
}
$this->addFilter('status', 'status');
$this->setQueryBuilder($queryBuilder);
}
@ -120,9 +122,9 @@ class CartRuleDataGrid extends DataGrid
'sortable' => true,
'filterable' => true,
'wrapper' => function ($value) {
if ($value->status == 'active') {
if ($value->status == 1) {
return trans('admin::app.datagrid.active');
} else if ($value->status == 'inactive') {
} else if ($value->status == 0) {
return trans('admin::app.datagrid.inactive');
} else {
return trans('admin::app.datagrid.draft');

View File

@ -16,6 +16,9 @@ class CatalogRuleDataGrid extends DataGrid
$queryBuilder = DB::table('catalog_rules')
->addSelect('catalog_rules.id', 'name', 'status', 'starts_from', 'ends_till', 'sort_order');
$this->addFilter('status', 'status');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -24,6 +24,7 @@ class CategoryDataGrid extends DataGrid
->groupBy('cat.id');
$this->addFilter('status', 'cat.status');
$this->addFilter('category_id', 'cat.id');
$this->setQueryBuilder($queryBuilder);

View File

@ -24,6 +24,7 @@ class CustomerDataGrid extends DataGrid
$this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)'));
$this->addFilter('phone', 'customers.phone');
$this->addFilter('gender', 'customers.gender');
$this->addFilter('status', 'status');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -15,6 +15,8 @@ class EmailTemplateDataGrid extends DataGrid
{
$queryBuilder = DB::table('marketing_templates')->addSelect('id', 'name', 'status');
$this->addFilter('status', 'status');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -15,6 +15,8 @@ class InventorySourcesDataGrid extends DataGrid
{
$queryBuilder = DB::table('inventory_sources')->addSelect('id', 'code', 'name', 'priority', 'status');
$this->addFilter('status', 'status');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -20,6 +20,7 @@ class UserDataGrid extends DataGrid
$this->addFilter('user_id', 'u.id');
$this->addFilter('user_name', 'u.name');
$this->addFilter('role_name', 'ro.name');
$this->addFilter('status', 'u.status');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -2,10 +2,10 @@
namespace Webkul\Admin\Http\Controllers\Sales;
use PDF;
use Webkul\Admin\Http\Controllers\Controller;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\InvoiceRepository;
use PDF;
class InvoiceController extends Controller
{
@ -141,8 +141,30 @@ class InvoiceController extends Controller
{
$invoice = $this->invoiceRepository->findOrFail($id);
$pdf = PDF::loadView('admin::sales.invoices.pdf', compact('invoice'))->setPaper('a4');
$html = view('admin::sales.invoices.pdf', compact('invoice'))->render();
return $pdf->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
return PDF::loadHTML($this->adjustArabicAndPersianContent($html))
->setPaper('a4')
->download('invoice-' . $invoice->created_at->format('d-m-Y') . '.pdf');
}
/**
* Adjust arabic and persian content.
*
* @param string $html
* @return string
*/
private function adjustArabicAndPersianContent($html)
{
$arabic = new \ArPHP\I18N\Arabic();
$p = $arabic->arIdentify($html);
for ($i = count($p)-1; $i >= 0; $i -= 2) {
$utf8ar = $arabic->utf8Glyphs(substr($html, $p[$i-1], $p[$i] - $p[$i-1]));
$html = substr_replace($html, $utf8ar, $p[$i-1], $p[$i] - $p[$i-1]);
}
return $html;
}
}

View File

@ -1,4 +1 @@
<input type="text" v-validate="'{{$validations}}'" class="control" id="{{ $attribute->code }}" name="{{ $attribute->code }}" value="{{ old($attribute->code) ?: $product[$attribute->code] }}" {{ in_array($attribute->code, ['sku', 'url_key']) ? 'v-slugify' : '' }} data-vv-as="&quot;{{ $attribute->admin_name }}&quot;" {{ $attribute->code == 'name' && ! $product[$attribute->code] ? 'v-slugify-target=\'url_key\'' : '' }} />
<input type="text" v-validate="'{{$validations}}'" class="control" id="{{ $attribute->code }}" name="{{ $attribute->code }}" value="{{ old($attribute->code) ?: $product[$attribute->code] }}" {{ in_array($attribute->code, ['sku', 'url_key']) ? 'v-slugify' : '' }} data-vv-as="&quot;{{ $attribute->admin_name }}&quot;" {{ $attribute->code == 'name' && ! $product[$attribute->code] ? 'v-slugify-target=\'url_key\'' : '' }} />

View File

@ -260,11 +260,11 @@
</div>
@endif
</td>
<td>{{ core()->formatBasePrice($item->base_price) }}</td>
<td>{!! core()->formatBasePrice($item->base_price, true) !!}</td>
<td class="text-center">{{ $item->qty }}</td>
<td class="text-center">{{ core()->formatBasePrice($item->base_total) }}</td>
<td class="text-center">{{ core()->formatBasePrice($item->base_tax_amount) }}</td>
<td class="text-center">{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount) }}</td>
<td class="text-center">{!! core()->formatBasePrice($item->base_total, true) !!}</td>
<td class="text-center">{!! core()->formatBasePrice($item->base_tax_amount, true) !!}</td>
<td class="text-center">{!! core()->formatBasePrice($item->base_total + $item->base_tax_amount, true) !!}</td>
</tr>
@endforeach
@ -277,31 +277,31 @@
<tr>
<td>{{ __('admin::app.sales.orders.subtotal') }}</td>
<td>-</td>
<td>{{ core()->formatBasePrice($invoice->base_sub_total) }}</td>
<td>{!! core()->formatBasePrice($invoice->base_sub_total, true) !!}</td>
</tr>
<tr>
<td>{{ __('admin::app.sales.orders.shipping-handling') }}</td>
<td>-</td>
<td>{{ core()->formatBasePrice($invoice->base_shipping_amount) }}</td>
<td>{!! core()->formatBasePrice($invoice->base_shipping_amount, true) !!}</td>
</tr>
<tr>
<td>{{ __('admin::app.sales.orders.tax') }}</td>
<td>-</td>
<td>{{ core()->formatBasePrice($invoice->base_tax_amount) }}</td>
<td>{!! core()->formatBasePrice($invoice->base_tax_amount, true) !!}</td>
</tr>
<tr>
<td>{{ __('admin::app.sales.orders.discount') }}</td>
<td>-</td>
<td>{{ core()->formatBasePrice($invoice->base_discount_amount) }}</td>
<td>{!! core()->formatBasePrice($invoice->base_discount_amount, true) !!}</td>
</tr>
<tr>
<td><strong>{{ __('admin::app.sales.orders.grand-total') }}</strong></td>
<td><strong>-</strong></td>
<td><strong>{{ core()->formatBasePrice($invoice->base_grand_total) }}</strong></td>
<td><strong>{!! core()->formatBasePrice($invoice->base_grand_total, true) !!}</strong></td>
</tr>
</table>

View File

@ -61,7 +61,7 @@
{{ __('admin::app.settings.channels.name') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<input v-validate="'required'" class="control" id="name" name="{{$locale}}[name]" data-vv-as="&quot;{{ __('admin::app.settings.channels.name') }}&quot;" value="{{ old($locale)['name'] ?? ($channel->translate($locale)['name'] ?? '') }}"/>
<input v-validate="'required'" class="control" id="name" name="{{$locale}}[name]" data-vv-as="&quot;{{ __('admin::app.settings.channels.name') }}&quot;" value="{{ old($locale)['name'] ?? ($channel->translate($locale)['name'] ?? $channel->name) }}"/>
<span class="control-error" v-if="errors.has('{{$locale}}[name]')">@{{ errors.first('{!!$locale!!}[page_title]') }}</span>
</div>
@ -70,7 +70,7 @@
{{ __('admin::app.settings.channels.description') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea class="control" id="description" name="{{$locale}}[description]">{{ old($locale)['description'] ?? ($channel->translate($locale)['description'] ?? '') }}</textarea>
<textarea class="control" id="description" name="{{$locale}}[description]">{{ old($locale)['description'] ?? ($channel->translate($locale)['description'] ?? $channel->description) }}</textarea>
</div>
<div class="control-group" :class="[errors.has('inventory_sources[]') ? 'has-error' : '']">
@ -190,7 +190,7 @@
{{ __('admin::app.settings.channels.home_page_content') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea class="control" id="home_page_content" name="{{$locale}}[home_page_content]">{{ old($locale)['home_page_content'] ?? ($channel->translate($locale)['home_page_content'] ?? '') }}</textarea>
<textarea class="control" id="home_page_content" name="{{$locale}}[home_page_content]">{{ old($locale)['home_page_content'] ?? ($channel->translate($locale)['home_page_content'] ?? $channel->home_page_content) }}</textarea>
</div>
<div class="control-group">
@ -198,7 +198,7 @@
{{ __('admin::app.settings.channels.footer_content') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<textarea class="control" id="footer_content" name="{{$locale}}[footer_content]">{{ old($locale)['footer_content'] ?? ($channel->translate($locale)['footer_content'] ?? '') }}</textarea>
<textarea class="control" id="footer_content" name="{{$locale}}[footer_content]">{{ old($locale)['footer_content'] ?? ($channel->translate($locale)['footer_content'] ?? $channel->footer_content) }}</textarea>
</div>
<div class="control-group">
@ -217,7 +217,7 @@
</accordian>
@php
$home_seo = $channel->translate($locale)['home_seo'] ?? '{}';
$home_seo = $channel->translate($locale)['home_seo'] ?? $channel->home_seo;
$seo = json_decode($home_seo);
@endphp
@ -276,7 +276,7 @@
{{ __('admin::app.settings.channels.maintenance-mode-text') }}
<span class="locale">[{{ $locale }}]</span>
</label>
<input class="control" id="maintenance-mode-text" name="{{$locale}}[maintenance_mode_text]" value="{{ old('maintenance_mode_text') ?? ($channel->translate($locale)['maintenance_mode_text'] ?? '') }}"/>
<input class="control" id="maintenance-mode-text" name="{{$locale}}[maintenance_mode_text]" value="{{ old('maintenance_mode_text') ?? ($channel->translate($locale)['maintenance_mode_text'] ?? $channel->maintenance_mode_text) }}"/>
</div>
<div class="control-group">

View File

@ -180,7 +180,6 @@ class CartRuleController extends Controller
'customer_groups' => 'required|array|min:1',
'coupon_type' => 'required',
'use_auto_generation' => 'required_if:coupon_type,==,1',
'coupon_code' => 'required_if:use_auto_generation,==,0|unique:cart_rule_coupons,code,' . $id,
'starts_from' => 'nullable|date',
'ends_till' => 'nullable|date|after_or_equal:starts_from',
'action_type' => 'required',
@ -189,6 +188,12 @@ class CartRuleController extends Controller
$cartRule = $this->cartRuleRepository->findOrFail($id);
if ($cartRule->coupon_type) {
$this->validate(request(), [
'coupon_code' => 'required_if:use_auto_generation,==,0|unique:cart_rule_coupons,code,' . $cartRule->cart_rule_coupon->id,
]);
}
Event::dispatch('promotions.cart_rule.update.before', $cartRule);
$cartRule = $this->cartRuleRepository->update(request()->all(), $id);

View File

@ -583,13 +583,15 @@ class Core
}
/**
* Format price with base currency symbol.
* Format price with base currency symbol. This method also give ability to encode
* the base currency symbol and its optional.
*
* @param float $price
* @param float $price
* @param bool $isEncoded
*
* @return string
*/
public function formatBasePrice($price)
public function formatBasePrice($price, $isEncoded = false)
{
if (is_null($price)) {
$price = 0;
@ -599,15 +601,17 @@ class Core
if ($symbol = $this->getBaseCurrency()->symbol) {
if ($this->currencySymbol($this->getBaseCurrencyCode()) == $symbol) {
return $formater->formatCurrency($price, $this->getBaseCurrencyCode());
$content = $formater->formatCurrency($price, $this->getBaseCurrencyCode());
} else {
$formater->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $symbol);
return $formater->format($this->convertPrice($price));
$content = $formater->format($this->convertPrice($price));
}
} else {
return $formater->formatCurrency($price, $this->getBaseCurrencyCode());
$content = $formater->formatCurrency($price, $this->getBaseCurrencyCode());
}
return ! $isEncoded ? $content : htmlentities($content);
}
/**

View File

@ -59,6 +59,10 @@ class WishlistController extends Controller
{
$wishlistItems = $this->wishlistRepository->getCustomerWhishlist();
if (! core()->getConfigData('general.content.shop.wishlist_option')) {
abort(404);
}
return view($this->_config['view'])->with('items', $wishlistItems);
}

View File

@ -53,7 +53,10 @@ class ProductsCategoriesProxyController extends Controller
{
$slugOrPath = trim($request->getPathInfo(), '/');
if (preg_match('/^([a-z0-9-]+\/?)+$/', $slugOrPath)) {
$slugOrPath = urldecode($slugOrPath);
// support url for chinese, japanese, arbic and english with numbers.
if (preg_match('/^([\x{0621}-\x{064A}\x{4e00}-\x{9fa5}\x{3402}-\x{FA6D}\x{3041}-\x{30A0}\x{30A0}-\x{31FF}_a-z0-9-]+\/?)+$/u', $slugOrPath)) {
if ($category = $this->categoryRepository->findByPath($slugOrPath)) {
@ -71,7 +74,7 @@ class ProductsCategoriesProxyController extends Controller
}
$sliderRepository = app('Webkul\Core\Repositories\SliderRepository');
$sliderData = $sliderRepository
->where('channel_id', core()->getCurrentChannel()->id)
->where('locale', core()->getCurrentLocale()->code)

View File

@ -219,10 +219,10 @@
return false;
},
validateForm: function(scope) {
validateForm: async function(scope) {
var this_this = this;
this.$validator.validateAll(scope).then(function (result) {
await this.$validator.validateAll(scope).then(function (result) {
if (result) {
if (scope == 'address-form') {
this_this.saveAddress();
@ -286,7 +286,7 @@
.catch(function (error) {})
},
saveAddress: function() {
saveAddress: async function() {
var this_this = this;
this.disable_button = true;
@ -327,7 +327,7 @@
})
},
saveShipping: function() {
saveShipping: async function() {
var this_this = this;
this.disable_button = true;
@ -351,7 +351,7 @@
})
},
savePayment: function() {
savePayment: async function() {
var this_this = this;
this.disable_button = true;
@ -373,7 +373,7 @@
});
},
placeOrder: function() {
placeOrder: async function() {
var this_this = this;
this.disable_button = true;
@ -610,4 +610,4 @@
})
</script>
@endpush
@endpush

View File

@ -40,7 +40,13 @@
@section('content-wrapper')
{!! view_render_event('bagisto.shop.home.content.before') !!}
{!! DbView::make($channel)->field('home_page_content')->with(['sliderData' => $sliderData])->render() !!}
@if (! is_null($channel->home_page_content))
{!! DbView::make($channel)->field('home_page_content')->with(['sliderData' => $sliderData])->render() !!}
@else
@include('shop::home.slider', ['sliderData' => $sliderData])
@include('shop::home.featured-products')
@include('shop::home.new-products')
@endif
{{ view_render_event('bagisto.shop.home.content.after') }}

View File

@ -21,15 +21,13 @@
<span>{{ __('shop::app.search.no-results') }}</span>
</div>
@else
@if ($results->total() == 1)
<div class="search-result-status mb-20">
<span><b>{{ $results->total() }} </b>{{ __('shop::app.search.found-result') }}</span>
</div>
@else
<div class="search-result-status mb-20">
<span><b>{{ $results->total() }} </b>{{ __('shop::app.search.found-results') }}</span>
</div>
@endif
<div class="search-result-status mb-20">
<span>
<b>{{ $results->total() }} </b>
{{ ($results->total() == 1) ? __('shop::app.search.found-result') : __('shop::app.search.found-results') }}
</span>
</div>
<div class="product-grid-4">
@foreach ($results as $productFlat)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,18 +1,18 @@
/* flatpickr v4.6.6, @license MIT */
/* flatpickr v4.6.3, @license MIT */
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/**

View File

@ -1,4 +1,4 @@
{
"/js/ui.js": "/js/ui.js?id=2cf17b86ea451828fd09",
"/css/ui.css": "/css/ui.css?id=5673703005b2ac3d0889"
"/js/ui.js": "/js/ui.js?id=9480d375da1da8eb3366",
"/css/ui.css": "/css/ui.css?id=6555a7029beea2bc5c1e"
}

View File

@ -7,10 +7,10 @@
target.value = e.target.value.toString()
.toLowerCase()
.normalize('NFKD') // Normalize Unicode
.replace(/[^\w- ]+/g, '')
.replace(/[^\w\u0621-\u064A\u4e00-\u9fa5\u3402-\uFA6D\u3041-\u30A0\u30A0-\u31FF- ]+/g, '')
// replace whitespaces with dashes
.replace(/ +/g, '-')

View File

@ -6,7 +6,7 @@
e.target.value = e.target.value
.toString()
.toLowerCase()
.replace(/[^\w- ]+/g, '')
.replace(/[^\w\u0621-\u064A\u4e00-\u9fa5\u3402-\uFA6D\u3041-\u30A0\u30A0-\u31FF- ]+/g, '')
// replace whitespaces with dashes
.replace(/ +/g, '-')

View File

@ -705,11 +705,15 @@ h5 {
&.date, &.datetime {
&::after {
top: 6px;
left: unset;
left: 100%;
}
}
.cross-icon {
top: 10px;
&.has-error.date, &.has-error.date {
&.date, &.datetime {
&::after {
top: 18px;
}
}
}
}
@ -740,12 +744,9 @@ h5 {
&.date, &.datetime {
&::after {
right: unset !important;
left: auto;
}
}
.cross-icon {
top: 10px;
}
}
}
}
@ -1240,14 +1241,14 @@ modal {
.tooltip {
display: block !important;
z-index: 10000;
.tooltip-inner {
background: black;
color: white;
border-radius: 4px;
padding: 5px 10px 4px;
}
.tooltip-arrow {
width: 0;
height: 0;
@ -1257,10 +1258,10 @@ modal {
border-color: black;
z-index: 1;
}
&[x-placement^="top"] {
margin-bottom: 5px;
.tooltip-arrow {
border-width: 5px 5px 0 5px;
border-left-color: transparent !important;
@ -1272,10 +1273,10 @@ modal {
margin-bottom: 0;
}
}
&[x-placement^="bottom"] {
margin-top: 5px;
.tooltip-arrow {
border-width: 0 5px 5px 5px;
border-left-color: transparent !important;
@ -1287,10 +1288,10 @@ modal {
margin-bottom: 0;
}
}
&[x-placement^="right"] {
margin-left: 5px;
.tooltip-arrow {
border-width: 5px 5px 5px 0;
border-left-color: transparent !important;
@ -1302,10 +1303,10 @@ modal {
margin-right: 0;
}
}
&[x-placement^="left"] {
margin-right: 5px;
.tooltip-arrow {
border-width: 5px 0 5px 5px;
border-top-color: transparent !important;

View File

@ -3,12 +3,10 @@
namespace Webkul\User\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\User\Models\Admin;
use Webkul\User\Contracts\Role as RoleContract;
class Role extends Model implements RoleContract
{
/**
* The attributes that are mass assignable.
*

View File

@ -15,4 +15,29 @@ class RoleRepository extends Repository
{
return 'Webkul\User\Contracts\Role';
}
/**
* Update method.
*
* @param array $data
* @param int $id
*
* @return \Webkul\User\Model\Role
*/
public function update(array $data, $id)
{
/* making collection for ease */
$requestedData = collect($data);
/* updating role data */
$role = $this->find($id);
$role->name = $requestedData['name'];
$role->description = $requestedData['description'];
$role->permission_type = $requestedData['permission_type'];
$role->permissions = $requestedData->has('permissions') ? $requestedData['permissions'] : [];
$role->update();
/* returning updated role */
return $role;
}
}

View File

@ -22,6 +22,7 @@ class ContentDataGrid extends DataGrid
->groupBy('con.id');
$this->addFilter('content_id', 'con.id');
$this->addFilter('status', 'con.status');
$this->setQueryBuilder($queryBuilder);
}

View File

@ -11,42 +11,46 @@ class ComparisonController extends Controller
*/
public function getComparisonList()
{
if (request()->get('data')) {
$productCollection = [];
if (! core()->getConfigData('general.content.shop.compare_option')) {
abort(404);
} else {
if (request()->get('data')) {
$productCollection = [];
if (auth()->guard('customer')->user()) {
$productCollection = $this->compareProductsRepository
->leftJoin(
'product_flat',
'velocity_customer_compare_products.product_flat_id',
'product_flat.id'
)
->where('customer_id', auth()->guard('customer')->user()->id)
->get();
if (auth()->guard('customer')->user()) {
$productCollection = $this->compareProductsRepository
->leftJoin(
'product_flat',
'velocity_customer_compare_products.product_flat_id',
'product_flat.id'
)
->where('customer_id', auth()->guard('customer')->user()->id)
->get();
$items = $productCollection->map(function ($product) {
return $product->id;
})->join('&');
$items = $productCollection->map(function ($product) {
return $product->id;
})->join('&');
$productCollection = ! empty($items)
? $this->velocityHelper->fetchProductCollection($items)
: [];
} else {
/* for product details */
if ($items = request()->get('items')) {
$productCollection = $this->velocityHelper->fetchProductCollection($items);
$productCollection = ! empty($items)
? $this->velocityHelper->fetchProductCollection($items)
: [];
} else {
/* for product details */
if ($items = request()->get('items')) {
$productCollection = $this->velocityHelper->fetchProductCollection($items);
}
}
$response = [
'status' => 'success',
'products' => $productCollection,
];
} else {
$response = view($this->_config['view']);
}
$response = [
'status' => 'success',
'products' => $productCollection,
];
} else {
$response = view($this->_config['view']);
return $response;
}
return $response;
}
/**

View File

@ -132,8 +132,8 @@
new_shipping_address: false,
selected_payment_method: '',
selected_shipping_method: '',
country: @json(core()->countries()),
countryStates: @json(core()->groupedStatesByCountries()),
countries: [],
countryStates: [],
step_numbers: {
'information': 1,
@ -157,6 +157,10 @@
},
created: function () {
this.fetchCountries();
this.fetchCountryStates();
this.getOrderSummary();
if (! customerAddress) {
@ -173,11 +177,11 @@
} else {
this.allAddress = customerAddress;
for (var country in this.country) {
for (var code in this.allAddress) {
for (let country in this.countries) {
for (let code in this.allAddress) {
if (this.allAddress[code].country) {
if (this.allAddress[code].country == this.country[country].code) {
this.allAddress[code]['country'] = this.country[country].name;
if (this.allAddress[code].country == this.countries[country].code) {
this.allAddress[code]['country'] = this.countries[country].name;
}
}
}
@ -194,6 +198,26 @@
}
},
fetchCountries: function () {
let countriesEndPoint = `${this.$root.baseUrl}/api/countries?pagination=0`;
this.$http.get(countriesEndPoint)
.then(response => {
this.countries = response.data.data;
})
.catch(function (error) {});
},
fetchCountryStates: function () {
let countryStateEndPoint = `${this.$root.baseUrl}/api/country-states?pagination=0`;
this.$http.get(countryStateEndPoint)
.then(response => {
this.countryStates = response.data.data;
})
.catch(function (error) {});
},
haveStates: function (addressType) {
if (this.countryStates[this.address[addressType].country] && this.countryStates[this.address[addressType].country].length)
return true;
@ -201,7 +225,7 @@
return false;
},
validateForm: function (scope) {
validateForm: async function (scope) {
var isManualValidationFail = false;
if (scope == 'address-form') {
@ -209,7 +233,7 @@
}
if (! isManualValidationFail) {
this.$validator.validateAll(scope)
await this.$validator.validateAll(scope)
.then(result => {
if (result) {
switch (scope) {
@ -341,7 +365,7 @@
.catch(function (error) {})
},
saveAddress: function () {
saveAddress: async function () {
this.disable_button = true;
if (this.allAddress.length > 0) {
@ -414,7 +438,7 @@
})
},
saveShipping: function () {
saveShipping: async function () {
this.disable_button = true;
this.$http.post("{{ route('shop.checkout.save-shipping') }}", {'shipping_method': this.selected_shipping_method})
@ -444,7 +468,7 @@
})
},
savePayment: function () {
savePayment: async function () {
this.disable_button = true;
if (this.isCheckPayment) {
@ -474,7 +498,7 @@
}
},
placeOrder: function () {
placeOrder: async function () {
if (this.isPlaceOrderEnabled) {
this.disable_button = false;
this.isPlaceOrderEnabled = false;
@ -735,4 +759,4 @@
})()
</script>
@endpush
@endpush

View File

@ -137,9 +137,9 @@
<option value=""></option>
@foreach (core()->countries() as $country)
<option value="{{ $country->code }}">{{ $country->name }}</option>
@endforeach
<option v-for='(country, index) in countries' :value="country.code">
@{{ country.name }}
</option>
</select>
<div class="select-icon-container">
@ -410,9 +410,9 @@
<option value=""></option>
@foreach (core()->countries() as $country)
<option value="{{ $country->code }}">{{ $country->name }}</option>
@endforeach
<option v-for='(country, index) in countries' :value="country.code">
@{{ country.name }}
</option>
</select>
<div class="select-icon-container">