Merge branch 'master' into optimization

This commit is contained in:
devansh bawari 2021-02-12 21:13:21 +05:30
commit 663946cd7c
48 changed files with 566 additions and 427 deletions

View File

@ -61,7 +61,7 @@ class Product extends JsonResource
/* product's checks */
'in_stock' => $product->haveSufficientQuantity(1),
'is_saved' => false,
'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product),
'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product) ? true : false,
'is_item_in_cart' => \Cart::hasProduct($product),
'show_quantity_changer' => $this->when(
$product->type !== 'grouped',

View File

@ -49,9 +49,11 @@ class ChannelDataGrid extends DataGrid
public function prepareQueryBuilder()
{
$queryBuilder = $this->channelRepository->query()
->leftJoin('channel_translations', 'channel_translations.channel_id', '=', 'channels.id')
->addSelect('channels.id', 'channels.code', 'channel_translations.locale', 'channel_translations.name as translated_name', 'channels.hostname')
->where('channel_translations.locale', '=', $this->locale);
->leftJoin('channel_translations', function($leftJoin) {
$leftJoin->on('channel_translations.channel_id', '=', 'channels.id')
->where('channel_translations.locale', $this->locale);
})
->addSelect('channels.id', 'channels.code', 'channel_translations.locale', 'channel_translations.name as translated_name', 'channels.hostname');
$this->addFilter('id', 'channels.id');
$this->addFilter('code', 'channels.code');

View File

@ -1,52 +0,0 @@
<?php
namespace Webkul\Admin\Http\Middleware;
use Webkul\Core\Repositories\LocaleRepository;
use Closure;
class Locale
{
/**
* @var LocaleRepository
*/
protected $locale;
/**
* @param \Webkul\Core\Repositories\LocaleRepository $locale
*/
public function __construct(LocaleRepository $locale)
{
$this->locale = $locale;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$locale = request()->get('admin_locale');
if ($locale) {
if ($this->locale->findOneByField('code', $locale)) {
app()->setLocale($locale);
session()->put('admin_locale', $locale);
}
} else {
if ($locale = session()->get('admin_locale')) {
app()->setLocale($locale);
} else {
app()->setLocale(app()->getLocale());
}
}
unset($request['admin_locale']);
return $next($request);
}
}

View File

@ -1,6 +1,6 @@
<?php
Route::group(['middleware' => ['web', 'admin_locale']], function () {
Route::group(['middleware' => ['web']], function () {
Route::prefix(config('app.admin_url'))->group(function () {
Route::get('/', 'Webkul\Admin\Http\Controllers\Controller@redirectToLogin');

View File

@ -2,191 +2,35 @@
namespace Webkul\Admin\Listeners;
use Illuminate\Support\Facades\Mail;
use Webkul\Admin\Mail\NewAdminNotification;
use Webkul\Admin\Mail\NewOrderNotification;
use Webkul\Admin\Mail\NewRefundNotification;
use Webkul\Admin\Mail\NewInvoiceNotification;
use Webkul\Admin\Mail\CancelOrderNotification;
use Webkul\Admin\Mail\NewShipmentNotification;
use Webkul\Admin\Mail\OrderCommentNotification;
use Webkul\Admin\Mail\CancelOrderAdminNotification;
use Webkul\Admin\Mail\NewInventorySourceNotification;
use Webkul\Admin\Traits\Mails;
use Webkul\Paypal\Payment\SmartButton;
class Order
{
/**
* Send new order Mail to the customer and admin
*
* @param \Webkul\Sales\Contracts\Order $order
* @return void
*/
public function sendNewOrderMail($order)
use Mails;
public function refundOrder($refund)
{
$customerLocale = $this->getLocale($order);
$order = $refund->order;
try {
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-order';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewOrderNotification($order));
}
if ($order->payment->method === 'paypal_smart_button') {
/* getting smart button instance */
$smartButton = new SmartButton;
/* email to admin */
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
if (core()->getConfigData($configKey)) {
$this->prepareMail(config('app.locale'), new NewAdminNotification($order));
}
} catch (\Exception $e) {
report($e);
/* getting paypal oder id */
$paypalOrderID = $order->payment->additional['orderID'];
/* getting capture id by paypal order id */
$captureID = $smartButton->getCaptureId($paypalOrderID);
/* now refunding order on the basis of capture id and refund data */
$smartButton->refundOrder($captureID, [
'amount' =>
[
'value' => $refund->grand_total,
'currency_code' => $refund->order_currency_code
]
]);
}
}
/**
* Send new invoice mail to the customer
*
* @param \Webkul\Sales\Contracts\Invoice $invoice
* @return void
*/
public function sendNewInvoiceMail($invoice)
{
$customerLocale = $this->getLocale($invoice);
try {
if ($invoice->email_sent) {
return;
}
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-invoice';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewInvoiceNotification($invoice));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send new refund mail to the customer
*
* @param \Webkul\Sales\Contracts\Refund $refund
* @return void
*/
public function sendNewRefundMail($refund)
{
$customerLocale = $this->getLocale($refund);
try {
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-refund';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewRefundNotification($refund));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send new shipment mail to the customer
*
* @param \Webkul\Sales\Contracts\Shipment $shipment
* @return void
*/
public function sendNewShipmentMail($shipment)
{
$customerLocale = $this->getLocale($shipment);
try {
if ($shipment->email_sent) {
return;
}
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-shipment';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewShipmentNotification($shipment));
}
/* email to admin */
$configKey = 'emails.general.notifications.emails.general.notifications.new-inventory-source';
if (core()->getConfigData($configKey)) {
$this->prepareMail(config('app.locale'), new NewInventorySourceNotification($shipment));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* @param \Webkul\Sales\Contracts\Order $order
* @return void
*/
public function sendCancelOrderMail($order)
{
$customerLocale = $this->getLocale($order);
try {
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.cancel-order';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new CancelOrderNotification($order));
}
/* email to admin */
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
if (core()->getConfigData($configKey)) {
$this->prepareMail(config('app.locale'), new CancelOrderAdminNotification($order));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* @param \Webkul\Sales\Contracts\OrderComment $comment
* @return void
*/
public function sendOrderCommentMail($comment)
{
$customerLocale = $this->getLocale($comment);
if (! $comment->customer_notified) {
return;
}
try {
/* email to customer */
$this->prepareMail($customerLocale, new OrderCommentNotification($comment));
} catch (\Exception $e) {
report($e);
}
}
/**
* Get the locale of the customer if somehow item name changes then the english locale will pe provided.
*
* @param object \Webkul\Sales\Contracts\Order|\Webkul\Sales\Contracts\Invoice|\Webkul\Sales\Contracts\Refund|\Webkul\Sales\Contracts\Shipment|\Webkul\Sales\Contracts\OrderComment
* @return string
*/
private function getLocale($object)
{
if ($object instanceof \Webkul\Sales\Contracts\OrderComment) {
$object = $object->order;
}
$objectFirstItem = $object->items->first();
return isset($objectFirstItem->additional['locale']) ? $objectFirstItem->additional['locale'] : 'en';
}
/**
* Prepare Mail.
* @return void
*/
private function prepareMail($locale, $notification)
{
app()->setLocale($locale);
Mail::queue($notification);
}
}

View File

@ -3,8 +3,6 @@
namespace Webkul\Admin\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;
use Webkul\Admin\Http\Middleware\Locale;
use Webkul\Core\Tree;
class AdminServiceProvider extends ServiceProvider
@ -14,7 +12,7 @@ class AdminServiceProvider extends ServiceProvider
*
* @return void
*/
public function boot(Router $router)
public function boot()
{
$this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
@ -31,8 +29,6 @@ class AdminServiceProvider extends ServiceProvider
$this->registerACL();
$router->aliasMiddleware('admin_locale', Locale::class);
$this->app->register(EventServiceProvider::class);
}

View File

@ -22,12 +22,14 @@ class EventServiceProvider extends ServiceProvider
Event::listen('sales.shipment.save.after', 'Webkul\Admin\Listeners\Order@sendNewShipmentMail');
Event::listen('sales.order.cancel.after','Webkul\Admin\Listeners\Order@sendCancelOrderMail');
Event::listen('sales.order.cancel.after', 'Webkul\Admin\Listeners\Order@sendCancelOrderMail');
Event::listen('sales.refund.save.after','Webkul\Admin\Listeners\Order@sendNewRefundMail');
Event::listen('sales.refund.save.after', 'Webkul\Admin\Listeners\Order@refundOrder');
Event::listen('sales.order.comment.create.after','Webkul\Admin\Listeners\Order@sendOrderCommentMail');
Event::listen('sales.refund.save.after', 'Webkul\Admin\Listeners\Order@sendNewRefundMail');
Event::listen('core.channel.update.after','Webkul\Admin\Listeners\ChannelSettingsChange@checkForMaintenaceMode');
Event::listen('sales.order.comment.create.after', 'Webkul\Admin\Listeners\Order@sendOrderCommentMail');
Event::listen('core.channel.update.after', 'Webkul\Admin\Listeners\ChannelSettingsChange@checkForMaintenaceMode');
}
}

View File

@ -125,7 +125,7 @@
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.parent_category.controls.before') !!}
<tree-view value-field="id" name-field="parent_id" input-type="radio" items='@json($categories)'></tree-view>
<tree-view value-field="id" name-field="parent_id" input-type="radio" items='@json($categories)' fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
{!! view_render_event('bagisto.admin.catalog.category.create_form_accordian.parent_category.controls.after') !!}

View File

@ -137,7 +137,7 @@
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.parent_category.controls.before', ['category' => $category]) !!}
<tree-view value-field="id" name-field="parent_id" input-type="radio" items='@json($categories)' value='@json($category->parent_id)'></tree-view>
<tree-view value-field="id" name-field="parent_id" input-type="radio" items='@json($categories)' value='@json($category->parent_id)' fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
{!! view_render_event('bagisto.admin.catalog.category.edit_form_accordian.parent_category.controls.before', ['category' => $category]) !!}

View File

@ -7,7 +7,7 @@
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.categories.controls.before', ['product' => $product]) !!}
<tree-view behavior="normal" value-field="id" name-field="categories" input-type="checkbox" items='@json($categories)' value='@json($product->categories->pluck("id"))'></tree-view>
<tree-view behavior="normal" value-field="id" name-field="categories" input-type="checkbox" items='@json($categories)' value='@json($product->categories->pluck("id"))' fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
{!! view_render_event('bagisto.admin.catalog.product.edit_form_accordian.categories.controls.after', ['product' => $product]) !!}

View File

@ -14,7 +14,7 @@
<select class="control" name="channels[]" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.catalog.products.channel') }}&quot;" multiple>
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->code, $productChannels) ? 'selected' : ''}}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -6,8 +6,16 @@
@section('content')
<div class="content">
<?php $locale = request()->get('locale') ?: app()->getLocale(); ?>
<?php $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); ?>
@php
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
if (! $channelLocales->contains('code', $locale)) {
$locale = config('app.fallback_locale');
}
@endphp
{!! view_render_event('bagisto.admin.catalog.product.edit.before', ['product' => $product]) !!}
@ -29,7 +37,7 @@
<option
value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name }}
{{ core()->getChannelName($channelModel) }}
</option>
@endforeach
@ -38,7 +46,7 @@
<div class="control-group">
<select class="control" id="locale-switcher" name="locale">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales as $localeModel)
@foreach ($channelLocales as $localeModel)
<option
value="{{ $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>

View File

@ -48,7 +48,7 @@
<select type="text" class="control" name="channels[]" v-validate="'required'" value="{{ old('channel[]') }}" data-vv-as="&quot;{{ __('admin::app.cms.pages.channel') }}&quot;" multiple="multiple">
@foreach($channels->all() as $channel)
<option value="{{ $channel->id }}">{{ $channel->name }}</option>
<option value="{{ $channel->id }}">{{ core()->getChannelName($channel) }}</option>
@endforeach
</select>

View File

@ -66,7 +66,7 @@
<select type="text" class="control" name="channels[]" v-validate="'required'" value="{{ old('channel[]') }}" data-vv-as="&quot;{{ __('admin::app.cms.pages.channel') }}&quot;" multiple="multiple">
@foreach(app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -6,8 +6,16 @@
@section('content')
<div class="content">
<?php $locale = request()->get('locale') ?: app()->getLocale(); ?>
<?php $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); ?>
@php
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
if (! $channelLocales->contains('code', $locale)) {
$locale = config('app.fallback_locale');
}
@endphp
<form method="POST" action="" @submit.prevent="onSubmit" enctype="multipart/form-data">
@ -23,7 +31,7 @@
@foreach (core()->getAllChannels() as $channelModel)
<option value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name }}
{{ core()->getChannelName($channelModel) }}
</option>
@endforeach
@ -32,7 +40,7 @@
<div class="control-group">
<select class="control" id="locale-switcher" name="locale">
@foreach (core()->getAllLocales() as $localeModel)
@foreach ($channelLocales as $localeModel)
<option value="{{ $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
{{ $localeModel->name }}

View File

@ -16,42 +16,6 @@
<span class="avatar">
</span>
<?php $locale = request()->get('admin_locale') ?: app()->getLocale();?>
<div class="profile-info">
<div class="dropdown-toggle">
<div style="display: inline-block; vertical-align: middle;">
<span class="name">
{{ __('admin::app.datagrid.locale') }}
</span>
@foreach (core()->getAllLocales() as $localeModel)
@if ($localeModel->code == $locale)
<span class="role">
{{ $localeModel->name }}
</span>
@endif
@endforeach
</div>
<i class="icon arrow-down-icon active"></i>
</div>
<div class="dropdown-list bottom-right">
<div class="control-group">
<select class="control" onChange="window.location.href = this.value" style="margin-left: 30px;">
@foreach (core()->getAllLocales() as $localeModel)
<option value="{{ '?admin_locale=' . $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="profile-info">
<div class="dropdown-toggle">
<div style="display: inline-block; vertical-align: middle;">

View File

@ -93,7 +93,7 @@
<select v-validate="'required'" class="control" id="channel_id" name="channel_id" data-vv-as="&quot;{{ __('admin::app.marketing.campaigns.channel') }}&quot;">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ old('channel_id') == $channel->id ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -97,7 +97,7 @@
<select v-validate="'required'" class="control" id="channel_id" name="channel_id" data-vv-as="&quot;{{ __('admin::app.marketing.campaigns.channel') }}&quot;">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->all() as $channel)
<option value="{{ $channel->id }}" {{ $selectedOption == $channel->id ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
</select>

View File

@ -71,7 +71,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ old('channels') && in_array($channel->id, old('channels')) ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
@ -306,7 +306,7 @@
<input type="hidden" :name="['conditions[' + index + '][attribute_type]']" v-model="matchedAttribute.type">
<div v-if="matchedAttribute.key == 'product|category_ids' || matchedAttribute.key == 'product|category_ids' || matchedAttribute.key == 'product|parent::category_ids'">
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :behavior="'no'"></tree-view>
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :behavior="'no'" fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
</div>
<div v-else>

View File

@ -78,7 +78,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
@ -343,7 +343,7 @@
<input type="hidden" :name="['conditions[' + index + '][attribute_type]']" v-model="matchedAttribute.type">
<div v-if="matchedAttribute.key == 'product|children::category_ids' || matchedAttribute.key == 'product|category_ids' || matchedAttribute.key == 'product|parent::category_ids'">
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :value='condition.value' :behavior="'no'"></tree-view>
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :value='condition.value' :behavior="'no'" fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
</div>
<div v-else>

View File

@ -71,7 +71,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ old('channels') && in_array($channel->id, old('channels')) ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
@ -230,7 +230,7 @@
<input type="hidden" :name="['conditions[' + index + '][attribute_type]']" v-model="matchedAttribute.type">
<div v-if="matchedAttribute.key == 'product|category_ids'">
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :behavior="'no'"></tree-view>
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :behavior="'no'" fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
</div>
<div v-else>

View File

@ -73,7 +73,7 @@
@foreach(core()->getAllChannels() as $channel)
<option value="{{ $channel->id }}" {{ in_array($channel->id, $selectedOptionIds) ? 'selected' : '' }}>
{{ $channel->name }}
{{ core()->getChannelName($channel) }}
</option>
@endforeach
@ -239,7 +239,7 @@
<input type="hidden" :name="['conditions[' + index + '][attribute_type]']" v-model="matchedAttribute.type">
<div v-if="matchedAttribute.key == 'product|category_ids'">
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :value='condition.value' :behavior="'no'"></tree-view>
<tree-view value-field="id" id-field="id" :name-field="'conditions[' + index + '][value]'" input-type="checkbox" :items='matchedAttribute.options' :value='condition.value' :behavior="'no'" fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
</div>
<div v-else>

View File

@ -54,7 +54,7 @@
</div>
<div class="control-group">
<tree-view value-field="key" id-field="key" items='@json($acl->items)'></tree-view>
<tree-view value-field="key" id-field="key" items='@json($acl->items)' fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
</div>
</div>
</accordian>

View File

@ -56,7 +56,7 @@
</div>
<div class="control-group tree-wrapper {{ $role->permission_type == 'all' ? 'hide' : '' }}">
<tree-view value-field="key" id-field="key" items='@json($acl->items)' value='@json($role->permissions)'></tree-view>
<tree-view value-field="key" id-field="key" items='@json($acl->items)' value='@json($role->permissions)' fallback-locale="{{ config('app.fallback_locale') }}"></tree-view>
</div>
</div>
</accordian>

View File

@ -0,0 +1,197 @@
<?php
namespace Webkul\Admin\Traits;
use Illuminate\Support\Facades\Mail;
use Webkul\Admin\Mail\NewAdminNotification;
use Webkul\Admin\Mail\NewOrderNotification;
use Webkul\Admin\Mail\NewRefundNotification;
use Webkul\Admin\Mail\NewInvoiceNotification;
use Webkul\Admin\Mail\CancelOrderNotification;
use Webkul\Admin\Mail\NewShipmentNotification;
use Webkul\Admin\Mail\OrderCommentNotification;
use Webkul\Admin\Mail\CancelOrderAdminNotification;
use Webkul\Admin\Mail\NewInventorySourceNotification;
trait Mails
{
/**
* Send new order Mail to the customer and admin.
*
* @param \Webkul\Sales\Contracts\Order $order
* @return void
*/
public function sendNewOrderMail($order)
{
$customerLocale = $this->getLocale($order);
try {
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-order';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewOrderNotification($order));
}
/* email to admin */
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
if (core()->getConfigData($configKey)) {
$this->prepareMail(config('app.locale'), new NewAdminNotification($order));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send new invoice mail to the customer.
*
* @param \Webkul\Sales\Contracts\Invoice $invoice
* @return void
*/
public function sendNewInvoiceMail($invoice)
{
$customerLocale = $this->getLocale($invoice);
try {
if ($invoice->email_sent) {
return;
}
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-invoice';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewInvoiceNotification($invoice));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send new refund mail to the customer.
*
* @param \Webkul\Sales\Contracts\Refund $refund
* @return void
*/
public function sendNewRefundMail($refund)
{
$customerLocale = $this->getLocale($refund);
try {
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-refund';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewRefundNotification($refund));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send new shipment mail to the customer.
*
* @param \Webkul\Sales\Contracts\Shipment $shipment
* @return void
*/
public function sendNewShipmentMail($shipment)
{
$customerLocale = $this->getLocale($shipment);
try {
if ($shipment->email_sent) {
return;
}
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.new-shipment';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new NewShipmentNotification($shipment));
}
/* email to admin */
$configKey = 'emails.general.notifications.emails.general.notifications.new-inventory-source';
if (core()->getConfigData($configKey)) {
$this->prepareMail(config('app.locale'), new NewInventorySourceNotification($shipment));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send cancel order mail.
*
* @param \Webkul\Sales\Contracts\Order $order
* @return void
*/
public function sendCancelOrderMail($order)
{
$customerLocale = $this->getLocale($order);
try {
/* email to customer */
$configKey = 'emails.general.notifications.emails.general.notifications.cancel-order';
if (core()->getConfigData($configKey)) {
$this->prepareMail($customerLocale, new CancelOrderNotification($order));
}
/* email to admin */
$configKey = 'emails.general.notifications.emails.general.notifications.new-admin';
if (core()->getConfigData($configKey)) {
$this->prepareMail(config('app.locale'), new CancelOrderAdminNotification($order));
}
} catch (\Exception $e) {
report($e);
}
}
/**
* Send order comment mail.
*
* @param \Webkul\Sales\Contracts\OrderComment $comment
* @return void
*/
public function sendOrderCommentMail($comment)
{
$customerLocale = $this->getLocale($comment);
if (! $comment->customer_notified) {
return;
}
try {
/* email to customer */
$this->prepareMail($customerLocale, new OrderCommentNotification($comment));
} catch (\Exception $e) {
report($e);
}
}
/**
* Get the locale of the customer if somehow item name changes then the english locale will pe provided.
*
* @param object \Webkul\Sales\Contracts\Order|\Webkul\Sales\Contracts\Invoice|\Webkul\Sales\Contracts\Refund|\Webkul\Sales\Contracts\Shipment|\Webkul\Sales\Contracts\OrderComment
* @return string
*/
private function getLocale($object)
{
if ($object instanceof \Webkul\Sales\Contracts\OrderComment) {
$object = $object->order;
}
$objectFirstItem = $object->items->first();
return isset($objectFirstItem->additional['locale']) ? $objectFirstItem->additional['locale'] : 'en';
}
/**
* Prepare mail.
*
* @return void
*/
private function prepareMail($locale, $notification)
{
app()->setLocale($locale);
Mail::queue($notification);
}
}

View File

@ -897,6 +897,10 @@ class Cart
$finalData['items'][] = $this->prepareDataForOrderItem($item);
}
if ($finalData['payment']['method'] === 'paypal_smart_button') {
$finalData['payment']['additional'] = request()->get('orderData');
}
return $finalData;
}

View File

@ -233,7 +233,25 @@ class Core
}
/**
* Returns all locales.
* Returns the channel name.
*
* @return string
*/
public function getChannelName($channel): string
{
static $channelName;
if ($channelName) {
return $channelName;
}
return $channelName = $channel->name
?? $channel->translate(app()->getLocale())->name
?? $channel->translate(config('app.fallback_locale'))->name;
}
/**
* Returns all locales
*
* @return \Illuminate\Support\Collection
*/

View File

@ -21,9 +21,9 @@ class Wishlist
}
if ($wishlist) {
return true;
return $wishlist;
}
return false;
return null;
}
}

View File

@ -6,26 +6,25 @@ use Webkul\Checkout\Facades\Cart;
use Webkul\Paypal\Payment\SmartButton;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Sales\Repositories\InvoiceRepository;
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
class SmartButtonController extends Controller
{
/**
* SmartButton object
* SmartButton $smartButton
*
* @var \Webkul\Paypal\Payment\SmartButton
*/
protected $smartButtonClient;
protected $smartButton;
/**
* OrderRepository object
* OrderRepository $orderRepository
*
* @var \Webkul\Sales\Repositories\OrderRepository
*/
protected $orderRepository;
/**
* InvoiceRepository object
* InvoiceRepository $invoiceRepository
*
* @var \Webkul\Sales\Repositories\InvoiceRepository
*/
@ -34,70 +33,49 @@ class SmartButtonController extends Controller
/**
* Create a new controller instance.
*
* @param \Webkul\Paypal\Payment\SmartButton $smartButton
* @param \Webkul\Attribute\Repositories\OrderRepository $orderRepository
* @param \Webkul\Sales\Repositories\InvoiceRepository $invoiceRepository
* @return void
*/
public function __construct(
SmartButton $smartButtonClient,
SmartButton $smartButton,
OrderRepository $orderRepository,
InvoiceRepository $invoiceRepository
)
{
$this->smartButton = $smartButton;
$this->orderRepository = $orderRepository;
$this->invoiceRepository = $invoiceRepository;
$this->smartButtonClient = $smartButtonClient->client();
}
/**
* Success payment.
* Paypal order creation for approval of client.
*
* @return \Illuminate\Http\JsonResponse
*/
public function details(OrdersCreateRequest $request)
public function createOrder()
{
$request->prefer('return=representation');
$request->body = $this->buildRequestBody();
$response = $this->smartButtonClient->execute($request);
return response()->json($response);
try {
return response()->json($this->smartButton->createOrder($this->buildRequestBody()));
} catch (\Exception $e) {
throw $e;
}
}
/**
* Save order.
* Capturing paypal order after approval.
*
* @return \Illuminate\Http\Response
*/
public function saveOrder()
public function captureOrder()
{
if (Cart::hasError()) {
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
}
try {
Cart::collectTotals();
$this->validateOrder();
$order = $this->orderRepository->create(Cart::prepareDataForOrder());
$this->orderRepository->update(['status' => 'processing'], $order->id);
if ($order->canInvoice()) {
$this->invoiceRepository->create($this->prepareInvoiceData($order));
}
Cart::deActivateCart();
session()->flash('order', $order);
return response()->json([
'success' => true,
]);
$this->smartButton->captureOrder(request()->input('orderData.orderID'));
return $this->saveOrder();
} catch (\Exception $e) {
session()->flash('error', trans('shop::app.common.error'));
throw $e;
}
}
@ -143,12 +121,7 @@ class SmartButtonController extends Controller
],
'application_context' => [
'user_action' => 'PAY_NOW',
'shipping_preference' => 'SET_PROVIDED_ADDRESS',
'payment_method' => [
'payee_preferred' => 'IMMEDIATE_PAYMENT_REQUIRED',
]
],
'purchase_units' => [
@ -186,8 +159,6 @@ class SmartButtonController extends Controller
];
if ($cart->haveStockableItems() && $cart->shipping_address) {
$shippingAddressLines = $this->getAddressLines($cart->shipping_address->address1);
$data['purchase_units'][0] = array_merge($data['purchase_units'][0], [
'shipping' => [
'address' => [
@ -252,6 +223,44 @@ class SmartButtonController extends Controller
return $addressLines;
}
/**
* Saving order once captured and all formalities done.
*
* @return \Illuminate\Http\Response
*/
protected function saveOrder()
{
if (Cart::hasError()) {
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
}
try {
Cart::collectTotals();
$this->validateOrder();
$order = $this->orderRepository->create(Cart::prepareDataForOrder());
$this->orderRepository->update(['status' => 'processing'], $order->id);
if ($order->canInvoice()) {
$this->invoiceRepository->create($this->prepareInvoiceData($order));
}
Cart::deActivateCart();
session()->flash('order', $order);
return response()->json([
'success' => true,
]);
} catch (\Exception $e) {
session()->flash('error', trans('shop::app.common.error'));
throw $e;
}
}
/**
* Prepares order's invoice data for creation.
*

View File

@ -2,7 +2,6 @@
Route::group(['middleware' => ['web']], function () {
Route::prefix('paypal/standard')->group(function () {
Route::get('/redirect', 'Webkul\Paypal\Http\Controllers\StandardController@redirect')->name('paypal.standard.redirect');
Route::get('/success', 'Webkul\Paypal\Http\Controllers\StandardController@success')->name('paypal.standard.success');
@ -11,9 +10,9 @@ Route::group(['middleware' => ['web']], function () {
});
Route::prefix('paypal/smart-button')->group(function () {
Route::get('/details', 'Webkul\Paypal\Http\Controllers\SmartButtonController@details')->name('paypal.smart_button.details');
Route::get('/create-order', 'Webkul\Paypal\Http\Controllers\SmartButtonController@createOrder')->name('paypal.smart-button.create-order');
Route::post('/save-order', 'Webkul\Paypal\Http\Controllers\SmartButtonController@saveOrder')->name('paypal.smart_button.save_order');
Route::post('/capture-order', 'Webkul\Paypal\Http\Controllers\SmartButtonController@captureOrder')->name('paypal.smart-button.capture-order');
});
});

View File

@ -4,7 +4,11 @@ namespace Webkul\Paypal\Payment;
use PayPalCheckoutSdk\Core\PayPalHttpClient;
use PayPalCheckoutSdk\Core\SandboxEnvironment;
use PayPalCheckoutSdk\Orders\OrdersGetRequest;
use PayPalCheckoutSdk\Core\ProductionEnvironment;
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
use PayPalCheckoutSdk\Payments\CapturesRefundRequest;
class SmartButton extends Paypal
{
@ -37,6 +41,81 @@ class SmartButton extends Paypal
$this->initialize();
}
/**
* Returns PayPal HTTP client instance with environment that has access
* credentials context. Use this instance to invoke PayPal APIs, provided the
* credentials have access.
*
* @return PayPalCheckoutSdk\Core\PayPalHttpClient
*/
public function client()
{
return new PayPalHttpClient($this->environment());
}
/**
* Create order for approval of client.
*
* @param array $body
* @return HttpResponse
*/
public function createOrder($body)
{
$request = new OrdersCreateRequest;
$request->prefer('return=representation');
$request->body = $body;
return $this->client()->execute($request);
}
/**
* Capture order after approval.
*
* @param string $orderId
* @return HttpResponse
*/
public function captureOrder($orderId)
{
$request = new OrdersCaptureRequest($orderId);
$request->prefer('return=representation');
$this->client()->execute($request);
}
/**
* Get order details.
*
* @param string $orderId
* @return HttpResponse
*/
public function getOrder($orderId)
{
return $this->client()->execute(new OrdersGetRequest($orderId));
}
/**
* Get capture id.
*
* @param string $orderId
* @return string
*/
public function getCaptureId($orderId)
{
$paypalOrderDetails = $this->getOrder($orderId);
return $paypalOrderDetails->result->purchase_units[0]->payments->captures[0]->id;
}
/**
* Refund order.
*
* @return HttpResponse
*/
public function refundOrder($captureId, $body = [])
{
$request = new CapturesRefundRequest($captureId);
$request->body = $body;
return $this->client()->execute($request);
}
/**
* Return paypal redirect url
*
@ -46,19 +125,11 @@ class SmartButton extends Paypal
{
}
/**
* Returns PayPal HTTP client instance with environment that has access
* credentials context. Use this instance to invoke PayPal APIs, provided the
* credentials have access.
*/
public function client()
{
return new PayPalHttpClient($this->environment());
}
/**
* Set up and return PayPal PHP SDK environment with PayPal access credentials.
* This sample uses SandboxEnvironment. In production, use LiveEnvironment.
*
* @return PayPalCheckoutSdk\Core\SandboxEnvironment|PayPalCheckoutSdk\Core\ProductionEnvironment
*/
protected function environment()
{
@ -73,6 +144,8 @@ class SmartButton extends Paypal
/**
* Initialize properties.
*
* @return void
*/
protected function initialize()
{

View File

@ -41,7 +41,7 @@
enableStandardCardFields: false,
createOrder: function(data, actions) {
return window.axios.get("{{ route('paypal.smart_button.details') }}")
return window.axios.get("{{ route('paypal.smart-button.create-order') }}")
.then(function(response) {
return response.data.result;
})
@ -54,9 +54,9 @@
onApprove: function(data, actions) {
app.showLoader();
window.axios.post("{{ route('paypal.smart_button.save_order') }}", {
'_token': "{{ csrf_token() }}",
'data' : data
window.axios.post("{{ route('paypal.smart-button.capture-order') }}", {
_token: "{{ csrf_token() }}",
orderData: data
})
.then(function(response) {
if (response.data.success) {

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddAdittionalDataToOrderPaymentTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('order_payment', function (Blueprint $table) {
$table->json('additional')->after('order_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('order_payment', function (Blueprint $table) {
$table->dropColumn('additional');
});
}
}

View File

@ -5,7 +5,6 @@ namespace Webkul\Sales\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Sales\Contracts\OrderPayment as OrderPaymentContract;
class OrderPayment extends Model implements OrderPaymentContract
{
protected $table = 'order_payment';
@ -15,4 +14,8 @@ class OrderPayment extends Model implements OrderPaymentContract
'created_at',
'updated_at',
];
protected $casts = [
'additional' => 'array'
];
}

View File

@ -535,7 +535,9 @@
methods: {
methodSelected: function() {
this.$emit('onPaymentMethodSelected', this.payment)
this.$emit('onPaymentMethodSelected', this.payment);
$('.paypal-button-container').empty();
eventBus.$emit('after-payment-method-selected', this.payment);
}

View File

@ -194,7 +194,7 @@
$('img#pro-img').data('zoom-image', $('img#pro-img').data('image')).ezPlus();
}
var wishlist = " <?php echo $wishListHelper->getWishlistProduct($product); ?> ";
var wishlist = "{{ $wishListHelper->getWishlistProduct($product) ? 'true' : 'false' }}";
$(document).mousemove(function(event) {
if ($('.add-to-wishlist').length || wishlist != 0) {

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.3, @license MIT */
/* flatpickr v4.6.6, @license MIT */
/*! *****************************************************************************
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
Copyright (c) Microsoft Corporation.
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.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
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.
***************************************************************************** */
/**

View File

@ -1,4 +1,4 @@
{
"/js/ui.js": "/js/ui.js?id=9480d375da1da8eb3366",
"/css/ui.css": "/css/ui.css?id=6555a7029beea2bc5c1e"
"/js/ui.js": "/js/ui.js?id=8eae585f880f44e9aa39",
"/css/ui.css": "/css/ui.css?id=72e23fc21cf1623e7aff"
}

View File

@ -1,5 +1,4 @@
<script>
export default {
name: 'tree-view',
@ -40,7 +39,12 @@
type: Array,
required: false,
default: null
}
},
fallbackLocale: {
type: String,
required: false
},
},
created () {
@ -62,6 +66,8 @@
computed: {
caption () {
return this.items[this.captionField]
? this.items[this.captionField]
: this.items.translations.filter((translation) => translation.locale === this.fallbackLocale)[0][this.captionField];
},
allChildren () {
@ -201,7 +207,8 @@
childrenField: this.childrenField,
valueField: this.valueField,
idField: this.idField,
behavior: this.behavior
behavior: this.behavior,
fallbackLocale: this.fallbackLocale
}
})
},

View File

@ -1,5 +1,4 @@
<script>
export default {
name: 'tree-view',
@ -58,7 +57,12 @@
type: [Array, String, Object],
required: false,
default: () => ([])
}
},
fallbackLocale: {
type: String,
required: false
},
},
data() {
@ -105,7 +109,8 @@
childrenField: this.childrenField,
valueField: this.valueField,
idField: this.idField,
behavior: this.behavior
behavior: this.behavior,
fallbackLocale: this.fallbackLocale
},
on: {
input: selection => {

View File

@ -1,12 +1,21 @@
@php
/* all locales */
$locales = core()->getAllLocales();
/* request and fallback handling */
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode());
$customer_group = request()->get('customer_group');
if ($channel == 'all') {
$locales = core()->getAllLocales();
} else {
$locales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
/* handling cases for new locale if not present in current channel */
if ($channel !== 'all') {
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
if ($channelLocales->contains('code', $locale)) {
$locales = $channelLocales;
} else {
$channel = 'all';
}
}
@endphp
@ -35,7 +44,7 @@
<option
value="{{ $channelModel->code }}"
{{ (isset($channel) && ($channelModel->code) == $channel) ? 'selected' : '' }}>
{{ $channelModel->name }}
{{ core()->getChannelName($channelModel) }}
</option>
@endforeach
</select>

View File

@ -1,6 +1,6 @@
<?php
Route::group(['middleware' => ['web', 'admin_locale']], function () {
Route::group(['middleware' => ['web']], function () {
Route::prefix(config('app.admin_url') . '/velocity')->group(function () {
Route::group(['middleware' => ['admin']], function () {
Route::namespace('Webkul\Velocity\Http\Controllers\Admin')->group(function () {

View File

@ -6,7 +6,13 @@
@php
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: core()->getCurrentChannelCode();
$channel = request()->get('channel') ?: core()->getDefaultChannelCode();
$channelLocales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
if (! $channelLocales->contains('code', $locale)) {
$locale = config('app.fallback_locale');
}
@endphp
@section('content')
@ -38,7 +44,7 @@
<option
value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name }}
{{ core()->getChannelName($channelModel) }}
</option>
@endforeach
@ -47,7 +53,7 @@
<div class="control-group">
<select class="control" id="locale-switcher" name="locale">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales as $localeModel)
@foreach ($channelLocales as $localeModel)
<option
value="{{ $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
@ -113,7 +119,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.home-page-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
<span class="locale">[{{ $channel }} - {{ $locale }}]</span>
</label>
<textarea
@ -127,7 +133,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.product-policy') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
<span class="locale">[{{ $channel }} - {{ $locale }}]</span>
</label>
<textarea
@ -295,7 +301,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.subscription-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
<span class="locale">[{{ $channel }} - {{ $locale }}]</span>
</label>
<textarea
@ -309,7 +315,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.footer-left-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
<span class="locale">[{{ $channel }} - {{ $locale }}]</span>
</label>
<textarea
@ -323,7 +329,7 @@
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.footer-middle-content') }}
<span class="locale">[{{ $metaData ? $metaData->channel : $channel }} - {{ $metaData ? $metaData->locale : $locale }}]</span>
<span class="locale">[{{ $channel }} - {{ $locale }}]</span>
</label>
<textarea
@ -358,7 +364,7 @@
$('#channel-switcher').val()
if (event.target.id == 'channel-switcher') {
let locale = "{{ app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales->first()->code }}";
let locale = "{{ $channelLocales->first()->code }}";
$('#locale-switcher').val(locale);
}

View File

@ -340,6 +340,7 @@
'submitForm': function () {
if (this.inputVal !== '') {
$('input[name=term]').val(this.inputVal);
$('#search-form').submit();
}
},

View File

@ -19,6 +19,8 @@
.alert-wishlist {
display: inline-block;
position: relative;
top: -2px;
}
</style>
@endpush

View File

@ -4,22 +4,22 @@
@auth('customer')
@php
$isWished = $wishListHelper->getWishlistProduct($product);
/* search wishlist on the basis of product's id so that wishlist id can be catched */
$wishlist = $wishListHelper->getWishlistProduct($product);
/* link making */
$href = isset($route) ? $route : ($wishlist ? route('customer.wishlist.remove', $wishlist->id) : route('customer.wishlist.add', $product->product_id));
/* title */
$title = $wishlist ? __('velocity::app.shop.wishlist.remove-wishlist-text') : __('velocity::app.shop.wishlist.add-wishlist-text');
@endphp
<a
class="unset wishlist-icon {{ $addWishlistClass ?? '' }} text-right"
@if(isset($route))
href="{{ $route }}"
@elseif (! $isWished)
href="{{ route('customer.wishlist.add', $product->product_id) }}"
title="{{ __('velocity::app.shop.wishlist.add-wishlist-text') }}"
@elseif (isset($itemId) && $itemId)
href="{{ route('customer.wishlist.remove', $itemId) }}"
title="{{ __('velocity::app.shop.wishlist.remove-wishlist-text') }}"
@endif>
href="{{ $href }}"
title="{{ $title }}">
<wishlist-component active="{{ ! $isWished }}"></wishlist-component>
<wishlist-component active="{{ $wishlist ? false : true }}"></wishlist-component>
@if (isset($text))
{!! $text !!}