Merge pull request #12 from bagisto/master

Updated fork
This commit is contained in:
Glenn Hermans 2021-02-27 10:44:55 +01:00 committed by GitHub
commit c2a4220e52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
235 changed files with 4775 additions and 3317 deletions

View File

@ -1,6 +1,6 @@
APP_NAME=Bagisto
APP_ENV=local
APP_VERSION=1.2.0
APP_VERSION=1.3.1
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
@ -67,4 +67,4 @@ LINKEDIN_CALLBACK_URL=https://yourhost.com/customer/social-login/linkedin/callba
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL=https://yourhost.com/customer/social-login/github/callback
GITHUB_CALLBACK_URL=https://yourhost.com/customer/social-login/github/callback

View File

@ -1,6 +1,6 @@
APP_NAME=Laravel
APP_ENV=local
APP_VERSION=1.2.0
APP_VERSION=1.3.1
APP_KEY=base64:G4KY3tUsTaY9ONo1n/QyJvVLQZdJDgbIkSJswFK01HE=
APP_DEBUG=true
APP_URL=http://localhost

View File

@ -24,10 +24,10 @@ jobs:
uses: actions/checkout@v2
- name: Setup php
uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
extensions: intl, curl, mbstring, openssl, pdo, pdo_mysql, tokenizer
extensions: curl, gd, intl, mbstring, openssl, pdo, pdo_mysql, tokenizer, zip
- name: Set environment
run: |

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,17 @@
# CHANGELOG for v0.2.x
#### This changelog consists the bug & security fixes and new features being included in the releases listed below.
This changelog consists the bug & security fixes and new features being included in the releases listed below.
## **v0.2.0 (23th of December, 2019)** - *Release*
* #1955 [fixed] - Message need to be changed on mouse hover on cross symbol next to applied coupon.
* #1959 [fixed] - if admin has set the same condition twice, then catalog rule is not getting apply
* #1958 [fixed] - getting exception on front end, if action type is Buy x get y free in non couponable cart rule.
* #1957 [fixed] - if action type is Fixed Amount to Whole Cart, then apply to shipping option should get hide.
* #1955 [fixed] - Message need to be changed on mouse hover on cross symbol next to applied coupon.
* #1954 [fixed] - If any different tax category has been assigned to variants in configurable product, then while using tax category condition in cart rule, rule is not working properly.
* #1950 [fixed] - multiple catalog rule should not get get applied, if 1st one has been created as End Other Rules = yes
* #1950 [fixed] - multiple catalog rule should not get get applied, if 1st one has been created as End Other Rules = yes

File diff suppressed because it is too large Load Diff

View File

@ -157,4 +157,12 @@ Thank you to all our backers! 🙏
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
<a href="https://opencollective.com/bagisto/contribute/sponsor-7372/checkout" target="_blank"><img src="https://images.opencollective.com/static/images/become_sponsor.svg"></a>
<div>
<a href="https://opencollective.com/bagisto/contribute/sponsor-7372/checkout" target="_blank">
<img src="https://images.opencollective.com/static/images/become_sponsor.svg">
</a>
</div>
<kbd>
<img src="https://images.opencollective.com/e-ventures1/7d61db2/logo.png" height="75">
</kbd>

View File

@ -32,7 +32,7 @@
"intervention/image": "^2.4",
"intervention/imagecache": "^2.3",
"kalnoy/nestedset": "5.0.1",
"khaled.alshamaa/ar-php": "^5.5.2",
"khaled.alshamaa/ar-php": "^6.0.0",
"konekt/concord": "^1.2",
"laravel/framework": "^7.0",
"laravel/scout": "^8.0",
@ -161,4 +161,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}

544
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -341,5 +341,7 @@ return [
'Concord' => Konekt\Concord\Facades\Concord::class,
'Helper' => Konekt\Concord\Facades\Helper::class,
'Debugbar' => Barryvdh\Debugbar\Facade::class,
'ProductImage' => Webkul\Product\Facades\ProductImage::class,
'ProductVideo' => Webkul\Product\Facades\ProductVideo::class
],
];

View File

@ -28,7 +28,7 @@ return [
],
'admin-api' => [
'driver' => 'token',
'driver' => 'jwt',
'provider' => 'admins',
]
],

View File

@ -34,10 +34,12 @@ return [
*/
'storage' => [
'enabled' => true,
'driver' => 'file', // redis, file, pdo, custom
'driver' => 'file', // redis, file, pdo, socket, custom
'path' => storage_path('debugbar'), // For file driver
'connection' => null, // Leave null for default connection (Redis/PDO)
'provider' => '', // Instance of StorageInterface for custom driver
'hostname' => '127.0.0.1', // Hostname to use with the "socket" driver
'port' => 2304, // Port to use with the "socket" driver
],
/*

View File

@ -31,7 +31,7 @@ class AddressController extends Controller
/**
* Controller instance
*
* @param Webkul\Customer\Repositories\CustomerAddressRepository $customerAddressRepository
* @param CustomerAddressRepository $customerAddressRepository
*/
public function __construct(CustomerAddressRepository $customerAddressRepository)
{
@ -49,12 +49,12 @@ class AddressController extends Controller
/**
* Get user address.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
*/
public function get()
{
$customer = auth($this->guard)->user();
$addresses = $customer->addresses()->get();
return CustomerAddressResource::collection($addresses);
@ -63,13 +63,14 @@ class AddressController extends Controller
/**
* Store a newly created resource in storage.
*
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function store()
{
$customer = auth($this->guard)->user();
if (request()->input('address1') && ! is_array(json_decode(request()->input('address1')))) {
if (request()->input('address1') && ! is_array(request()->input('address1'))) {
return response()->json([
'message' => 'address1 must be an array.',
]);
@ -77,18 +78,20 @@ class AddressController extends Controller
if (request()->input('address1')) {
request()->merge([
'address1' => implode(PHP_EOL, array_filter(json_decode(request()->input('address1')))),
'address1' => implode(PHP_EOL, array_filter(request()->input('address1'))),
'customer_id' => $customer->id,
]);
}
}
$this->validate(request(), [
'address1' => 'string|required',
'country' => 'string|required',
'state' => 'string|required',
'city' => 'string|required',
'company' => 'string|nullable',
'vat_id' => 'string|nullable',
'country' => 'string|required',
'state' => 'string|nullable',
'city' => 'string|required',
'postcode' => 'required',
'phone' => 'required',
'phone' => 'required',
]);
$customerAddress = $this->customerAddressRepository->create(request()->all());
@ -101,29 +104,37 @@ class AddressController extends Controller
/**
* Update the specified resource in storage.
*
* @return \Illuminate\Http\Response
* @param int $id
*
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
*/
public function update()
public function update(int $id)
{
$customer = auth($this->guard)->user();
if (request()->input('address1') && ! is_array(request()->input('address1'))) {
return response()->json([
'message' => 'address1 must be an array.',
]);
}
request()->merge(['address1' => implode(PHP_EOL, array_filter(request()->input('address1')))]);
$this->validate(request(), [
'address1' => 'string|required',
'country' => 'string|required',
'state' => 'string|required',
'city' => 'string|required',
'company' => 'string|nullable',
'vat_id' => 'string|nullable',
'country' => 'string|required',
'state' => 'string|nullable',
'city' => 'string|required',
'postcode' => 'required',
'phone' => 'required',
'phone' => 'required',
]);
$this->customerAddressRepository->update(request()->all(), request()->input('id'));
$customerAddress = $this->customerAddressRepository->update(request()->all(), $id);
return response()->json([
'message' => 'Your address has been updated successfully.',
'data' => new CustomerAddressResource($this->customerAddressRepository->find(request()->input('id'))),
'data' => new CustomerAddressResource($customerAddress),
]);
}
}

View File

@ -3,7 +3,7 @@
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
use Webkul\Product\Helpers\ProductType;
use Webkul\Product\Facades\ProductImage as ProductImageFacade;
class Product extends JsonResource
{
@ -14,10 +14,10 @@ class Product extends JsonResource
*/
public function __construct($resource)
{
$this->productImageHelper = app('Webkul\Product\Helpers\ProductImage');
$this->productReviewHelper = app('Webkul\Product\Helpers\Review');
$this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist');
parent::__construct($resource);
}
@ -29,52 +29,265 @@ class Product extends JsonResource
*/
public function toArray($request)
{
/* assign product */
$product = $this->product ? $this->product : $this;
$prices = $product->getTypeInstance()->getProductPrices();
/* get type instance */
$productTypeInstance = $product->getTypeInstance();
/* generating resource */
return [
/* product's information */
'id' => $product->id,
'sku' => $product->sku,
'type' => $product->type,
'name' => $this->name,
'url_key' => $this->url_key,
'price' => $product->getTypeInstance()->getMinimalPrice(),
'formated_price' => core()->currency($product->getTypeInstance()->getMinimalPrice()),
'short_description' => $this->short_description,
'description' => $this->description,
'sku' => $this->sku,
'name' => $product->name,
'url_key' => $product->url_key,
'price' => $productTypeInstance->getMinimalPrice(),
'formated_price' => core()->currency($productTypeInstance->getMinimalPrice()),
'short_description' => $product->short_description,
'description' => $product->description,
'images' => ProductImage::collection($product->images),
'base_image' => $this->productImageHelper->getProductBaseImage($product),
'variants' => Self::collection($this->variants),
'in_stock' => $product->haveSufficientQuantity(1),
$this->mergeWhen($product->getTypeInstance()->isComposite(), [
'super_attributes' => Attribute::collection($product->super_attributes),
]),
'special_price' => $this->when(
$product->getTypeInstance()->haveSpecialPrice(),
$product->getTypeInstance()->getSpecialPrice()
),
'formated_special_price' => $this->when(
$product->getTypeInstance()->haveSpecialPrice(),
core()->currency($product->getTypeInstance()->getSpecialPrice())
),
'regular_price' => $this->when(
$product->getTypeInstance()->haveSpecialPrice(),
data_get($prices, 'regular_price.price')
),
'formated_regular_price' => $this->when(
$product->getTypeInstance()->haveSpecialPrice(),
data_get($prices, 'regular_price.formated_price')
),
'videos' => ProductVideo::collection($product->videos),
'base_image' => ProductImageFacade::getProductBaseImage($product),
'created_at' => $product->created_at,
'updated_at' => $product->updated_at,
/* product's reviews */
'reviews' => [
'total' => $total = $this->productReviewHelper->getTotalReviews($product),
'total_rating' => $total ? $this->productReviewHelper->getTotalRating($product) : 0,
'average_rating' => $total ? $this->productReviewHelper->getAverageRating($product) : 0,
'percentage' => $total ? json_encode($this->productReviewHelper->getPercentageRating($product)) : [],
],
/* product's checks */
'in_stock' => $product->haveSufficientQuantity(1),
'is_saved' => false,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'is_wishlisted' => $this->wishlistHelper->getWishlistProduct($product) ? true : false,
'is_item_in_cart' => \Cart::hasProduct($product),
'show_quantity_changer' => $this->when(
$product->type !== 'grouped',
$product->getTypeInstance()->showQuantityBox()
),
/* product's extra information */
$this->merge($this->allProductExtraInfo()),
/* special price cases */
$this->merge($this->specialPriceInfo()),
/* super attributes */
$this->mergeWhen($productTypeInstance->isComposite(), [
'super_attributes' => Attribute::collection($product->super_attributes),
]),
];
}
/**
* Get special price information.
*
* @return array
*/
private function specialPriceInfo()
{
$product = $this->product ? $this->product : $this;
$productTypeInstance = $product->getTypeInstance();
return [
'special_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
$productTypeInstance->getSpecialPrice()
),
'formated_special_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
core()->currency($productTypeInstance->getSpecialPrice())
),
'regular_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
data_get($productTypeInstance->getProductPrices(), 'regular_price.price')
),
'formated_regular_price' => $this->when(
$productTypeInstance->haveSpecialPrice(),
data_get($productTypeInstance->getProductPrices(), 'regular_price.formated_price')
),
];
}
/**
* Get all product's extra information.
*
* @return array
*/
private function allProductExtraInfo()
{
$product = $this->product ? $this->product : $this;
$productTypeInstance = $product->getTypeInstance();
return [
/* grouped product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Grouped,
$product->type == 'grouped'
? $this->getGroupedProductInfo($product)
: null
),
/* bundle product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Bundle,
$product->type == 'bundle'
? $this->getBundleProductInfo($product)
: null
),
/* configurable product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Configurable,
$product->type == 'configurable'
? $this->getConfigurableProductInfo($product)
: null
),
/* downloadable product */
$this->mergeWhen(
$productTypeInstance instanceof \Webkul\Product\Type\Downloadable,
$product->type == 'downloadable'
? $this->getDownloadableProductInfo($product)
: null
),
/* booking product */
$this->mergeWhen(
$product->type == 'booking',
$product->type == 'booking'
? $this->getBookingProductInfo($product)
: null
),
];
}
/**
* Get grouped product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getGroupedProductInfo($product)
{
return [
'grouped_products' => $product->grouped_products->map(function($groupedProduct) {
$associatedProduct = $groupedProduct->associated_product;
$data = $associatedProduct->toArray();
return array_merge($data, [
'qty' => $groupedProduct->qty,
'isSaleable' => $associatedProduct->getTypeInstance()->isSaleable(),
'formated_price' => $associatedProduct->getTypeInstance()->getPriceHtml(),
'show_quantity_changer' => $associatedProduct->getTypeInstance()->showQuantityBox(),
]);
})
];
}
/**
* Get bundle product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getBundleProductInfo($product)
{
return [
'currency_options' => core()->getAccountJsSymbols(),
'bundle_options' => app('Webkul\Product\Helpers\BundleOption')->getBundleConfig($product)
];
}
/**
* Get configurable product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getConfigurableProductInfo($product)
{
return [
'variants' => $product->variants
];
}
/**
* Get downloadable product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getDownloadableProductInfo($product)
{
return [
'downloadable_links' => $product->downloadable_links->map(function ($downloadableLink) {
$data = $downloadableLink->toArray();
if (isset($data['sample_file'])) {
$data['price'] = core()->currency($downloadableLink->price);
$data['sample_download_url'] = route('shop.downloadable.download_sample', ['type' => 'link', 'id' => $downloadableLink['id']]);
}
return $data;
}),
'downloadable_samples' => $product->downloadable_samples->map(function ($downloadableSample) {
$sample = $downloadableSample->toArray();
$data = $sample;
$data['download_url'] = route('shop.downloadable.download_sample', ['type' => 'sample', 'id' => $sample['id']]);
return $data;
})
];
}
/**
* Get booking product's extra information.
*
* @param \Webkul\Product\Models\Product
* @return array
*/
private function getBookingProductInfo($product)
{
$bookingProduct = app('\Webkul\BookingProduct\Repositories\BookingProductRepository')->findOneByField('product_id', $product->id);
$data['slot_index_route'] = route('booking_product.slots.index', $bookingProduct->id);
if ($bookingProduct->type == 'appointment') {
$bookingSlotHelper = app('\Webkul\BookingProduct\Helpers\AppointmentSlot');
$data['today_slots_html'] = $bookingSlotHelper->getTodaySlotsHtml($bookingProduct);
$data['week_slot_durations'] = $bookingSlotHelper->getWeekSlotDurations($bookingProduct);
$data['appointment_slot'] = $bookingProduct->appointment_slot;
}
if ($bookingProduct->type == 'event') {
$bookingSlotHelper = app('\Webkul\BookingProduct\Helpers\EventTicket');
$data['tickets'] = $bookingSlotHelper->getTickets($bookingProduct);
$data['event_date'] = $bookingSlotHelper->getEventDate($bookingProduct);
}
if ($bookingProduct->type == 'rental') {
$data['renting_type'] = $bookingProduct->rental_slot->renting_type;
}
if ($bookingProduct->type == 'table') {
$bookingSlotHelper = app('\Webkul\BookingProduct\Helpers\TableSlot');
$data['today_slots_html'] = $bookingSlotHelper->getTodaySlotsHtml($bookingProduct);
$data['week_slot_durations'] = $bookingSlotHelper->getWeekSlotDurations($bookingProduct);
$data['table_slot'] = $bookingProduct->table_slot;
}
return $data;
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Webkul\API\Http\Resources\Catalog;
use Illuminate\Http\Resources\Json\JsonResource;
class ProductVideo extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'id' => $this->id,
'type' => $this->type,
'url' => $this->url
];
}
}

View File

@ -19,6 +19,7 @@ class CustomerAddress extends JsonResource
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'company_name' => $this->company_name,
'vat_id' => $this->vat_id,
'address1' => explode(PHP_EOL, $this->address1),
'country' => $this->country,
'country_name' => core()->country_name($this->country),
@ -26,6 +27,7 @@ class CustomerAddress extends JsonResource
'city' => $this->city,
'postcode' => $this->postcode,
'phone' => $this->phone,
'is_default' => $this->default_address,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];

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

@ -30,10 +30,17 @@ class SliderDataGrid extends DataGrid
{
parent::__construct();
$this->locale = request()->get('locale') ?? 'all';
$this->channel = request()->get('channel')
? Channel::find(request()->get('channel'))->code
: 'all';
/* locale */
$this->locale = request()->get('locale') ?? app()->getLocale();
/* channel */
$this->channel = request()->get('channel') ?? (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode());
/* finding channel code */
if ($this->channel !== 'all') {
$this->channel = Channel::query()->find($this->channel);
$this->channel = $this->channel ? $this->channel->code : 'all';
}
}
public function prepareQueryBuilder()

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

@ -63,7 +63,7 @@
<accordian :title="'{{ __('admin::app.account.current-password') }}'" :active="true">
<div slot="body">
<div class="control-group" :class="[errors.has('current_password') ? 'has-error' : '']">
<label for="current_password">{{ __('admin::app.account.current-password') }}</label>
<label for="current_password" class="required">{{ __('admin::app.account.current-password') }}</label>
<input type="password" v-validate="'required|min:6'" class="control" id="current_password" name="current_password" data-vv-as="&quot;{{ __('admin::app.account.current-password') }}&quot;"/>
<span class="control-error" v-if="errors.has('current_password')">@{{ errors.first('current_password') }}</span>
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.attributes.index') }}'"></i>
{{ __('admin::app.catalog.attributes.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.attributes.index') }}'"></i>
{{ __('admin::app.catalog.attributes.edit-title') }}
</h1>

View File

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.categories.index') }}'"></i>
{{ __('admin::app.catalog.categories.add-title') }}
</h1>
@ -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

@ -13,7 +13,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.categories.index') }}'"></i>
{{ __('admin::app.catalog.categories.edit-title') }}
</h1>
@ -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

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.families.index') }}'"></i>
{{ __('admin::app.catalog.families.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.families.index') }}'"></i>
{{ __('admin::app.catalog.families.edit-title') }}
</h1>

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

@ -26,7 +26,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.catalog.products.index') }}'"></i>
{{ __('admin::app.catalog.products.add-title') }}
</h1>

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]) !!}
@ -18,7 +26,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link"
onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
onclick="window.location = '{{ route('admin.catalog.products.index') }}'"></i>
{{ __('admin::app.catalog.products.edit-title') }}
</h1>
@ -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 (core()->getAllLocales() as $localeModel)
@foreach ($channelLocales as $localeModel)
<option
value="{{ $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
@ -199,6 +207,13 @@
$(document).ready(function () {
$('#channel-switcher, #locale-switcher').on('change', function (e) {
$('#channel-switcher').val()
if (event.target.id == 'channel-switcher') {
let locale = "{{ app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales->first()->code }}";
$('#locale-switcher').val(locale);
}
var query = '?channel=' + $('#channel-switcher').val() + '&locale=' + $('#locale-switcher').val();
window.location.href = "{{ route('admin.catalog.products.edit', $product->id) }}" + query;

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.cms.index') }}'"></i>
{{ __('admin::app.cms.pages.add-title') }}
</h1>
@ -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

@ -13,7 +13,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.cms.index') }}'"></i>
{{ __('admin::app.cms.pages.edit-title') }}
</h1>
@ -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

@ -14,7 +14,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.addresses.index', ['id' => $customer->id]) }}'"></i>
{{ __('admin::app.customers.addresses.create-title') }}
</h1>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.index') }}'"></i>
{{ __('address::app.admin.addresses.title-orders', ['customer_name' => $customer->first_name . ' ' . $customer->last_name]) }}
</h1>

View File

@ -9,7 +9,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.index') }}'"></i>
{{ __('admin::app.users.users.confirm-delete-title') }}
</h1>
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.index') }}'"></i>
{{ __('admin::app.customers.customers.title') }}

View File

@ -9,7 +9,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.index') }}'"></i>
{{ $customer->first_name . " " . $customer->last_name }}
</h1>
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.groups.index') }}'"></i>
{{ __('admin::app.customers.groups.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.groups.index') }}'"></i>
{{ __('admin::app.customers.groups.edit-title') }}
</h1>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.index') }}'"></i>
{{ __('admin::app.customers.note.title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.review.index') }}'"></i>
{{ __('admin::app.customers.reviews.edit-title') }}
</h1>

View File

@ -192,8 +192,6 @@
</div>
@inject ('productImageHelper', 'Webkul\Product\Helpers\ProductImage')
<div class="sale-stock">
<div class="card">
<div class="card-title">
@ -208,7 +206,7 @@
<li>
<a href="{{ route('admin.catalog.products.edit', $item->product_id) }}">
<div class="product image">
<?php $productBaseImage = $productImageHelper->getProductBaseImage($item->product); ?>
<?php $productBaseImage = productimage()->getProductBaseImage($item->product); ?>
<img class="item-image" src="{{ $productBaseImage['small_image_url'] }}" />
</div>
@ -318,7 +316,7 @@
<li>
<a href="{{ route('admin.catalog.products.edit', $item->product_id) }}">
<div class="image">
<?php $productBaseImage = $productImageHelper->getProductBaseImage($item->product); ?>
<?php $productBaseImage = productimage()->getProductBaseImage($item->product); ?>
<img class="item-image" src="{{ $productBaseImage['small_image_url'] }}" />
</div>

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

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customer.review.index') }}'"></i>
{{ __('admin::app.marketing.campaigns.add-title') }}
</h1>
@ -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>
@ -114,7 +114,7 @@
</div>
</accordian>
{!! view_render_event('bagisto.admin.marketing.templates.create.after') !!}
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.campaigns.index') }}'"></i>
{{ __('admin::app.marketing.campaigns.edit-title') }}
</h1>
@ -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>
@ -119,7 +119,7 @@
</div>
</accordian>
{!! view_render_event('bagisto.admin.marketing.templates.create.after') !!}
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.events.index') }}'"></i>
{{ __('admin::app.marketing.events.add-title') }}
</h1>
@ -44,7 +44,7 @@
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
</div>
<div class="control-group" :class="[errors.has('date') ? 'has-error' : '']">
<div class="control-group date" :class="[errors.has('date') ? 'has-error' : '']">
<label for="date" class="required">{{ __('admin::app.marketing.events.date') }}</label>
<date>
<input type="text" name="date" class="control" v-validate="'required'" value="{{ old('date') }}" data-vv-as="&quot;{{ __('admin::app.marketing.events.date') }}&quot;">
@ -54,7 +54,7 @@
</div>
</accordian>
{!! view_render_event('bagisto.admin.marketing.events.create.after') !!}
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.events.index') }}'"></i>
{{ __('admin::app.marketing.events.edit-title') }}
</h1>
@ -45,7 +45,7 @@
<span class="control-error" v-if="errors.has('description')">@{{ errors.first('description') }}</span>
</div>
<div class="control-group" :class="[errors.has('date') ? 'has-error' : '']">
<div class="control-group date" :class="[errors.has('date') ? 'has-error' : '']">
<label for="date" class="required">{{ __('admin::app.marketing.events.date') }}</label>
<date>
<input type="text" name="date" class="control" v-validate="'required'" value="{{ old('date') ?: $event->date }}" data-vv-as="&quot;{{ __('admin::app.marketing.events.date') }}&quot;">
@ -55,7 +55,7 @@
</div>
</accordian>
{!! view_render_event('bagisto.admin.marketing.events.create.after') !!}
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.customers.subscribers.index') }}'"></i>
{{ __('admin::app.customers.subscribers.title-edit') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.email-templates.index') }}'"></i>
{{ __('admin::app.marketing.templates.add-title') }}
</h1>
@ -61,7 +61,7 @@
</div>
</div>
</accordian>
{!! view_render_event('bagisto.admin.marketing.templates.create.after') !!}
</div>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.email-templates.index') }}'"></i>
{{ __('admin::app.marketing.templates.edit-title') }}
</h1>
@ -62,7 +62,7 @@
</div>
</div>
</accordian>
{!! view_render_event('bagisto.admin.marketing.templates.create.after') !!}
</div>

View File

@ -22,7 +22,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link"
onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
onclick="window.location = '{{ route('admin.cart-rules.index') }}'"></i>
{{ __('admin::app.promotions.cart-rules.add-title') }}
</h1>
@ -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

@ -27,7 +27,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link"
onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
onclick="window.location = '{{ route('admin.cart-rules.index') }}'"></i>
{{ __('admin::app.promotions.cart-rules.edit-title') }}
</h1>
@ -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>
@ -783,7 +783,7 @@
},
showModal(id) {
this.$root.$set(this.$root.modalIds, id, true);
this.$root.$set(this.$root.modalIds, id, true);
},
}
});

View File

@ -22,7 +22,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link"
onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
onclick="window.location = '{{ route('admin.catalog-rules.index') }}'"></i>
{{ __('admin::app.promotions.catalog-rules.add-title') }}
</h1>
@ -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

@ -22,7 +22,7 @@
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link"
onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
onclick="window.location = '{{ route('admin.catalog-rules.index') }}'"></i>
{{ __('admin::app.promotions.catalog-rules.edit-title') }}
</h1>
@ -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

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.invoices.index') }}'"></i>
{{ __('admin::app.sales.invoices.add-title') }}
</h1>

View File

@ -14,7 +14,7 @@
<h1>
{!! view_render_event('sales.invoice.title.before', ['order' => $order]) !!}
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.invoices.index') }}'"></i>
{{ __('admin::app.sales.invoices.view-title', ['invoice_id' => $invoice->id]) }}

View File

@ -14,7 +14,7 @@
<h1>
{!! view_render_event('sales.order.title.before', ['order' => $order]) !!}
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.orders.index') }}'"></i>
{{ __('admin::app.sales.orders.view-title', ['order_id' => $order->increment_id]) }}

View File

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.refunds.index') }}'"></i>
{{ __('admin::app.sales.refunds.add-title') }}
</h1>

View File

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.refunds.index') }}'"></i>
{{ __('admin::app.sales.refunds.view-title', ['refund_id' => $refund->id]) }}
</h1>

View File

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.shipments.index') }}'"></i>
{{ __('admin::app.sales.shipments.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sales.shipments.index') }}'"></i>
{{ __('admin::app.sales.shipments.view-title', ['shipment_id' => $shipment->id]) }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.channels.index') }}'"></i>
{{ __('admin::app.settings.channels.add-title') }}
</h1>

View File

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.channels.index') }}'"></i>
{{ __('admin::app.settings.channels.edit-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.currencies.index') }}'"></i>
{{ __('admin::app.settings.currencies.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.currencies.index') }}'"></i>
{{ __('admin::app.settings.currencies.edit-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.exchange_rates.index') }}'"></i>
{{ __('admin::app.settings.exchange_rates.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.exchange_rates.index') }}'"></i>
{{ __('admin::app.settings.exchange_rates.edit-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.inventory_sources.index') }}'"></i>
{{ __('admin::app.settings.inventory_sources.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.inventory_sources.index') }}'"></i>
{{ __('admin::app.settings.inventory_sources.edit-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.locales.index') }}'"></i>
{{ __('admin::app.settings.locales.add-title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.locales.index') }}'"></i>
{{ __('admin::app.settings.locales.edit-title') }}
</h1>

View File

@ -15,7 +15,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sliders.index') }}'"></i>
{{ __('admin::app.settings.sliders.add-title') }}
</h1>
@ -60,7 +60,7 @@
<select class="control" id="channel_id" name="channel_id" v-validate="'required'" data-vv-as="&quot;{{ __('admin::app.settings.sliders.channels') }}&quot;">
@foreach ($channels as $channel)
<option value="{{ $channel->id }}" @if ($channel->id == old('channel_id')) selected @endif>
{{ __($channel->name) }}
{{ __(core()->getChannelName($channel)) }}
</option>
@endforeach
</select>

View File

@ -12,7 +12,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.sliders.index') }}'"></i>
{{ __('admin::app.settings.sliders.edit-title') }}
@ -49,7 +49,7 @@
<select class="control" id="channel_id" name="channel_id" data-vv-as="&quot;{{ __('admin::app.settings.sliders.channels') }}&quot;" value="" v-validate="'required'">
@foreach ($channels as $channel)
<option value="{{ $channel->id }}" @if ($channel->id == $slider->channel_id) selected @endif>
{{ __($channel->name) }}
{{ __(core()->getChannelName($channel)) }}
</option>
@endforeach
</select>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.tax-categories.index') }}'"></i>
{{ __('admin::app.settings.tax-categories.add-title') }}
</h1>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.tax-categories.index') }}'"></i>
{{ __('admin::app.settings.tax-categories.edit.title') }}
</h1>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.tax-rates.index') }}'"></i>
{{ __('admin::app.settings.tax-rates.add-title') }}
</h1>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.tax-rates.index') }}'"></i>
{{ __('admin::app.settings.tax-rates.edit.title') }}
</h1>

View File

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.roles.index') }}'"></i>
{{ __('admin::app.users.roles.add-role-title') }}
</h1>
@ -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

@ -11,7 +11,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.roles.index') }}'"></i>
{{ __('admin::app.users.roles.edit-role-title') }}
</h1>
@ -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

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.users.index') }}'"></i>
{{ __('admin::app.users.users.add-user-title') }}
</h1>

View File

@ -10,7 +10,7 @@
<div class="page-header">
<div class="page-title">
<h1>
<i class="icon angle-left-icon back-link" onclick="window.location = history.length > 1 ? document.referrer : '{{ route('admin.dashboard.index') }}'"></i>
<i class="icon angle-left-icon back-link" onclick="window.location = '{{ route('admin.users.index') }}'"></i>
{{ __('admin::app.users.users.edit-user-title') }}
</h1>

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

@ -73,12 +73,12 @@ class BookingProductEventTicketRepository extends Repository
$savedTickets[$ticketId]['ticket'] = $ticket;
$savedTickets[$ticketId]['ticketInputs'] = $ticketInputs;
}
Event::dispatch('booking_product.booking.event-ticket.save.after', ['tickets' => $savedTickets]);
}
foreach ($previousTicketIds as $previousTicketId) {
$this->delete($previousTicketId);
}
Event::dispatch('booking_product.booking.event-ticket.save.after', ['tickets' => $savedTickets]);
}
}

View File

@ -9,7 +9,6 @@ use Webkul\BookingProduct\Helpers\Booking as BookingHelper;
use Webkul\BookingProduct\Repositories\BookingProductRepository;
use Webkul\Checkout\Models\CartItem;
use Webkul\Product\Datatypes\CartItemValidationResult;
use Webkul\Product\Helpers\ProductImage;
use Webkul\Product\Repositories\ProductAttributeValueRepository;
use Webkul\Product\Repositories\ProductImageRepository;
use Webkul\Product\Repositories\ProductVideoRepository;
@ -56,7 +55,6 @@ class Booking extends Virtual
* @param \Webkul\Product\Repositories\ProductAttributeValueRepository $attributeValueRepository
* @param \Webkul\Product\Repositories\ProductInventoryRepository $productInventoryRepository
* @param \Webkul\Product\Repositories\ProductImageRepository $productImageRepository
* @param \Webkul\Product\Helpers\ProductImage $productImageHelper
* @param \Webkul\BookingProduct\Repositories\BookingProductRepository $bookingProductRepository
* @param \Webkul\BookingProduct\Helpers\BookingHelper $bookingHelper
* @param \Webkul\Product\Repositories\ProductVideoRepository $productVideoRepository
@ -68,7 +66,6 @@ class Booking extends Virtual
ProductAttributeValueRepository $attributeValueRepository,
ProductInventoryRepository $productInventoryRepository,
ProductImageRepository $productImageRepository,
ProductImage $productImageHelper,
BookingProductRepository $bookingProductRepository,
BookingHelper $bookingHelper,
ProductVideoRepository $productVideoRepository
@ -80,7 +77,6 @@ class Booking extends Virtual
$attributeValueRepository,
$productInventoryRepository,
$productImageRepository,
$productImageHelper,
$productVideoRepository
);

View File

@ -3,15 +3,15 @@
namespace Webkul\CartRule\Helpers;
use Carbon\Carbon;
use Webkul\Checkout\Facades\Cart;
use Webkul\Rule\Helpers\Validator;
use Webkul\Checkout\Models\CartItem;
use Illuminate\Database\Eloquent\Builder;
use Webkul\CartRule\Repositories\CartRuleRepository;
use Webkul\CartRule\Repositories\CartRuleCouponRepository;
use Webkul\CartRule\Repositories\CartRuleCouponUsageRepository;
use Webkul\CartRule\Repositories\CartRuleCustomerRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\Checkout\Models\CartItem;
use Webkul\Rule\Helpers\Validator;
use Webkul\Checkout\Facades\Cart;
use Webkul\CartRule\Repositories\CartRuleCouponRepository;
use Webkul\CartRule\Repositories\CartRuleCustomerRepository;
use Webkul\CartRule\Repositories\CartRuleCouponUsageRepository;
class CartRule
{
@ -153,7 +153,9 @@ class CartRule
if (Cart::getCurrentCustomer()->check()) {
$customerGroupId = Cart::getCurrentCustomer()->user()->customer_group_id;
} else {
if ($customerGuestGroup = $this->customerGroupRepository->findOneByField('code', 'guest')) {
$customerGuestGroup = $this->customerGroupRepository->getCustomerGuestGroup();
if ($customerGuestGroup) {
$customerGroupId = $customerGuestGroup->id;
}
}
@ -581,12 +583,12 @@ class CartRule
->where('cart_rule_channels.channel_id', $channelId)
->where(function ($query1) {
/** @var Builder $query1 */
$query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d'))
$query1->where('cart_rules.starts_from', '<=', Carbon::now()->format('Y-m-d H:m:s'))
->orWhereNull('cart_rules.starts_from');
})
->where(function ($query2) {
/** @var Builder $query2 */
$query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d'))
$query2->where('cart_rules.ends_till', '>=', Carbon::now()->format('Y-m-d H:m:s'))
->orWhereNull('cart_rules.ends_till');
})
->with([

View File

@ -3,8 +3,8 @@
namespace Webkul\CatalogRule\Helpers;
use Carbon\Carbon;
use Webkul\CatalogRule\Repositories\CatalogRuleProductPriceRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
use Webkul\CatalogRule\Repositories\CatalogRuleProductPriceRepository;
class CatalogRuleProductPrice
{
@ -161,7 +161,7 @@ class CatalogRuleProductPrice
case 'by_fixed':
$price = max(0, $price - $rule->discount_amount);
break;
case 'by_percent':
@ -191,7 +191,7 @@ class CatalogRuleProductPrice
}
/**
* Get catalog rules product price for specific date, channel and customer group
* Get catalog rules product price for specific date, channel and customer group.
*
* @param \Webkul\Product\Contracts\Product $product
* @return array|void
@ -201,7 +201,7 @@ class CatalogRuleProductPrice
if ($this->getCurrentCustomer()->check()) {
$customerGroupId = $this->getCurrentCustomer()->user()->customer_group_id;
} else {
$customerGroup = $this->customerGroupRepository->findOneByField('code', 'guest');
$customerGroup = $this->customerGroupRepository->getCustomerGuestGroup();
if (! $customerGroup) {
return;
@ -210,11 +210,6 @@ class CatalogRuleProductPrice
$customerGroupId = $customerGroup->id;
}
return $this->catalogRuleProductPriceRepository->findOneWhere([
'product_id' => $product->id,
'channel_id' => core()->getCurrentChannel()->id,
'customer_group_id' => $customerGroupId,
'rule_date' => Carbon::now()->format('Y-m-d'),
]);
return $this->catalogRuleProductPriceRepository->checkInLoadedCatalogRulePrice($product, $customerGroupId);
}
}

View File

@ -2,12 +2,13 @@
namespace Webkul\CatalogRule\Repositories;
use Illuminate\Support\Carbon;
use Webkul\Core\Eloquent\Repository;
class CatalogRuleProductPriceRepository extends Repository
{
/**
* Specify Model class name
* Specify Model class name.
*
* @return mixed
*/
@ -15,4 +16,25 @@ class CatalogRuleProductPriceRepository extends Repository
{
return 'Webkul\CatalogRule\Contracts\CatalogRuleProductPrice';
}
/**
* Check if catalog rule prices already loaded. If already loaded then load from it.
*
* @return object
*/
public function checkInLoadedCatalogRulePrice($product, $customerGroupId)
{
static $catalogRulePrices = [];
if (array_key_exists($product->id, $catalogRulePrices)) {
return $catalogRulePrices[$product->id];
}
return $catalogRulePrices[$product->id] = $this->findOneWhere([
'product_id' => $product->id,
'channel_id' => core()->getCurrentChannel()->id,
'customer_group_id' => $customerGroupId,
'rule_date' => Carbon::now()->format('Y-m-d'),
]);
}
}

View File

@ -20,7 +20,6 @@ use Webkul\Customer\Repositories\CustomerAddressRepository;
class Cart
{
/**
* CartRepository instance
*
@ -898,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;
}
@ -1290,6 +1293,25 @@ class Cart
}
}
/**
* Check whether cart has product.
*
* @param \Webkul\Product\Models\Product $product
* @return bool
*/
public function hasProduct($product): bool
{
$cart = \Cart::getCart();
if (! $cart) {
return false;
}
$count = $cart->all_items()->where('product_id', $product->id)->count();
return $count > 0 ? true : false;
}
/**
* Check minimum order.
*

View File

@ -4,14 +4,14 @@ namespace Webkul\Core;
use Carbon\Carbon;
use Webkul\Core\Models\Channel;
use Webkul\Core\Repositories\CurrencyRepository;
use Webkul\Core\Repositories\ExchangeRateRepository;
use Webkul\Core\Repositories\CountryRepository;
use Webkul\Core\Repositories\CountryStateRepository;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Core\Repositories\LocaleRepository;
use Webkul\Core\Repositories\CoreConfigRepository;
use Illuminate\Support\Facades\Config;
use Webkul\Core\Repositories\LocaleRepository;
use Webkul\Core\Repositories\ChannelRepository;
use Webkul\Core\Repositories\CountryRepository;
use Webkul\Core\Repositories\CurrencyRepository;
use Webkul\Core\Repositories\CoreConfigRepository;
use Webkul\Core\Repositories\CountryStateRepository;
use Webkul\Core\Repositories\ExchangeRateRepository;
use Webkul\Customer\Repositories\CustomerGroupRepository;
class Core
@ -72,9 +72,20 @@ class Core
*/
protected $coreConfigRepository;
/** @var Channel */
/**
* @var \Webkul\Core\Models\Channel
*/
private static $channel;
/**
* Register your core config keys here which you don't want to
* load in static array. These keys will load from database
* everytime the `getConfigData` method is called.
*/
private $coreConfigExceptions = [
'catalog.products.guest-checkout.allow-guest-checkout'
];
/**
* Create a new instance.
*
@ -118,7 +129,7 @@ class Core
}
/**
* Returns all channels
* Returns all channels.
*
* @return \Illuminate\Support\Collection
*/
@ -134,7 +145,7 @@ class Core
}
/**
* Returns currenct channel models
* Returns currenct channel models.
*
* @return \Webkul\Core\Contracts\Channel
*/
@ -158,7 +169,7 @@ class Core
}
/**
* Set the current channel
* Set the current channel.
*
* @param Channel $channel
*/
@ -168,7 +179,7 @@ class Core
}
/**
* Returns currenct channel code
* Returns currenct channel code.
*
* @return \Webkul\Core\Contracts\Channel
*/
@ -184,7 +195,7 @@ class Core
}
/**
* Returns default channel models
* Returns default channel models.
*
* @return \Webkul\Core\Contracts\Channel
*/
@ -206,7 +217,7 @@ class Core
}
/**
* Returns the default channel code configured in config/app.php
* Returns the default channel code configured in `config/app.php`.
*
* @return string
*/
@ -221,6 +232,18 @@ class Core
return ($channel = $this->getDefaultChannel()) ? $channelCode = $channel->code : '';
}
/**
* Returns the channel name.
*
* @return string
*/
public function getChannelName($channel): string
{
return $channel->name
?? $channel->translate(app()->getLocale())->name
?? $channel->translate(config('app.fallback_locale'))->name;
}
/**
* Returns all locales
*
@ -238,7 +261,7 @@ class Core
}
/**
* Returns current locale
* Returns current locale.
*
* @return \Webkul\Core\Contracts\Locale
*/
@ -260,7 +283,7 @@ class Core
}
/**
* Returns all Customer Groups
* Returns all customer groups.
*
* @return \Illuminate\Support\Collection
*/
@ -276,7 +299,7 @@ class Core
}
/**
* Returns all currencies
* Returns all currencies.
*
* @return \Illuminate\Support\Collection
*/
@ -292,7 +315,7 @@ class Core
}
/**
* Returns base channel's currency model
* Returns base channel's currency model.
*
* @return \Webkul\Core\Contracts\Currency
*/
@ -314,7 +337,7 @@ class Core
}
/**
* Returns base channel's currency code
* Returns base channel's currency code.
*
* @return string
*/
@ -330,7 +353,7 @@ class Core
}
/**
* Returns base channel's currency model
* Returns base channel's currency model.
*
* @return \Webkul\Core\Contracts\Currency
*/
@ -348,7 +371,7 @@ class Core
}
/**
* Returns base channel's currency code
* Returns base channel's currency code.
*
* @return string
*/
@ -364,7 +387,7 @@ class Core
}
/**
* Returns current channel's currency model
* Returns current channel's currency model.
*
* @return \Webkul\Core\Contracts\Currency
*/
@ -386,7 +409,7 @@ class Core
}
/**
* Returns current channel's currency code
* Returns current channel's currency code.
*
* @return string
*/
@ -402,7 +425,27 @@ class Core
}
/**
* Converts price
* Returns exchange rates.
*
* @return object
*/
public function getExchangeRate($targetCurrencyId)
{
static $exchangeRate;
if ($exchangeRate || $exchangeRate === '') {
return $exchangeRate;
}
$found = $this->exchangeRateRepository->findOneWhere([
'target_currency' => $targetCurrencyId,
]);
return $exchangeRate = ($found ? $found : '');
}
/**
* Converts price.
*
* @param float $amount
* @param string $targetCurrencyCode
@ -438,11 +481,9 @@ class Core
return $amount;
}
$exchangeRate = $this->exchangeRateRepository->findOneWhere([
'target_currency' => $targetCurrency->id,
]);
$exchangeRate = $this->getExchangeRate($targetCurrency->id);
if (null === $exchangeRate || ! $exchangeRate->rate) {
if ('' === $exchangeRate || null === $exchangeRate || ! $exchangeRate->rate) {
return $amount;
}
@ -456,7 +497,7 @@ class Core
}
/**
* Converts to base price
* Converts to base price.
*
* @param float $amount
* @param string $targetCurrencyCode
@ -485,7 +526,7 @@ class Core
}
/**
* Format and convert price with currency symbol
* Format and convert price with currency symbol.
*
* @param float $price
*
@ -501,7 +542,7 @@ class Core
}
/**
* Return currency symbol from currency code
* Return currency symbol from currency code.
*
* @param float $price
*
@ -515,7 +556,7 @@ class Core
}
/**
* Format and convert price with currency symbol
* Format and convert price with currency symbol.
*
* @param float $price
*
@ -532,7 +573,7 @@ class Core
}
/**
* Format and convert price with currency symbol
* Format and convert price with currency symbol.
*
* @return array
*/
@ -547,7 +588,7 @@ class Core
$pattern = str_replace("#,##0.00", "%v", $pattern);
return [
'symbol' => core()->currencySymbol(core()->getCurrentCurrencyCode()),
'symbol' => $this->currencySymbol($this->getCurrentCurrencyCode()),
'decimal' => $formater->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL),
'format' => $pattern,
];
@ -586,7 +627,7 @@ class Core
}
/**
* Checks if current date of the given channel (in the channel timezone) is within the range
* Checks if current date of the given channel (in the channel timezone) is within the range.
*
* @param int|string|\Webkul\Core\Contracts\Channel $channel
* @param string|null $dateFrom
@ -620,7 +661,7 @@ class Core
}
/**
* Get channel timestamp, timstamp will be builded with channel timezone settings
* Get channel timestamp, timstamp will be builded with channel timezone settings.
*
* @param \Webkul\Core\Contracts\Channel $channel
*
@ -642,7 +683,7 @@ class Core
}
/**
* Check whether sql date is empty
* Check whether sql date is empty.
*
* @param string $date
*
@ -675,7 +716,7 @@ class Core
}
/**
* Retrieve information from payment configuration
* Retrieve information from payment configuration.
*
* @param string $field
* @param int|string|null $channelId
@ -685,51 +726,20 @@ class Core
*/
public function getConfigData($field, $channel = null, $locale = null)
{
if (null === $channel) {
$channel = request()->get('channel') ?: ($this->getCurrentChannelCode() ?: $this->getDefaultChannelCode());
}
static $loadedConfigs = [];
if (null === $locale) {
$locale = request()->get('locale') ?: app()->getLocale();
}
$fields = $this->getConfigField($field);
$channel_based = false;
$locale_based = false;
if (isset($fields['channel_based']) && $fields['channel_based']) {
$channel_based = true;
}
if (isset($fields['locale_based']) && $fields['locale_based']) {
$locale_based = true;
}
if (isset($fields['channel_based']) && $fields['channel_based']) {
if (isset($fields['locale_based']) && $fields['locale_based']) {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
'channel_code' => $channel,
'locale_code' => $locale,
]);
} else {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
'channel_code' => $channel,
]);
}
if (array_key_exists($field, $loadedConfigs) && ! in_array($field, $this->coreConfigExceptions)) {
$coreConfigValue = $loadedConfigs[$field];
} else {
if (isset($fields['locale_based']) && $fields['locale_based']) {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
'locale_code' => $locale,
]);
} else {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
]);
if (null === $channel) {
$channel = request()->get('channel') ?: ($this->getCurrentChannelCode() ?: $this->getDefaultChannelCode());
}
if (null === $locale) {
$locale = request()->get('locale') ?: app()->getLocale();
}
$loadedConfigs[$field] = $coreConfigValue = $this->getCoreConfigValue($field, $channel, $locale);
}
if (! $coreConfigValue) {
@ -746,7 +756,7 @@ class Core
}
/**
* Retrieve a group of information from the core config table
* Retrieve a group of information from the core config table.
*
* @param mixed $criteria
*
@ -758,7 +768,7 @@ class Core
}
/**
* Retrieve all countries
* Retrieve all countries.
*
* @return \Illuminate\Support\Collection
*/
@ -768,7 +778,7 @@ class Core
}
/**
* Returns country name by code
* Returns country name by code.
*
* @param string $code
*
@ -782,7 +792,7 @@ class Core
}
/**
* Retrieve all country states
* Retrieve all country states.
*
* @param string $countryCode
*
@ -794,7 +804,7 @@ class Core
}
/**
* Retrieve all grouped states by country code
* Retrieve all grouped states by country code.
*
* @return \Illuminate\Support\Collection
*/
@ -810,7 +820,7 @@ class Core
}
/**
* Retrieve all grouped states by country code
* Retrieve all grouped states by country code.
*
* @return \Illuminate\Support\Collection
*/
@ -828,7 +838,7 @@ class Core
}
/**
* Returns time intervals
* Returns time intervals.
*
* @param \Illuminate\Support\Carbon $startDate
* @param \Illuminate\Support\Carbon $endDate
@ -888,7 +898,6 @@ class Core
}
/**
*
* @param string $date
* @param int $day
*
@ -910,7 +919,7 @@ class Core
}
/**
* Method to sort through the acl items and put them in order
* Method to sort through the acl items and put them in order.
*
* @param array $items
*
@ -1026,6 +1035,86 @@ class Core
return $array;
}
/**
* @param array $array1
*
* @return array
*/
public function convertEmptyStringsToNull($array)
{
foreach ($array as $key => $value) {
if ($value == "" || $value == "null") {
$array[$key] = null;
}
}
return $array;
}
/**
* Create singleton object through single facade.
*
* @param string $className
*
* @return object
*/
public function getSingletonInstance($className)
{
static $instance = [];
if (array_key_exists($className, $instance)) {
return $instance[$className];
}
return $instance[$className] = app($className);
}
/**
* Returns a string as selector part for identifying elements in views.
*
* @param float $taxRate
*
* @return string
*/
public static function taxRateAsIdentifier(float $taxRate): string
{
return str_replace('.', '_', (string)$taxRate);
}
/**
* Get Shop email sender details.
*
* @return array
*/
public function getSenderEmailDetails()
{
$sender_name = $this->getConfigData('general.general.email_settings.sender_name') ? $this->getConfigData('general.general.email_settings.sender_name') : config('mail.from.name');
$sender_email = $this->getConfigData('general.general.email_settings.shop_email_from') ? $this->getConfigData('general.general.email_settings.shop_email_from') : config('mail.from.address');
return [
'name' => $sender_name,
'email' => $sender_email,
];
}
/**
* Get Admin email details.
*
* @return array
*/
public function getAdminEmailDetails()
{
$admin_name = $this->getConfigData('general.general.email_settings.admin_name') ? $this->getConfigData('general.general.email_settings.admin_name') : config('mail.admin.name');
$admin_email = $this->getConfigData('general.general.email_settings.admin_email') ? $this->getConfigData('general.general.email_settings.admin_email') : config('mail.admin.address');
return [
'name' => $admin_name,
'email' => $admin_email,
];
}
/**
* @param array $array1
* @param array $array2
@ -1048,82 +1137,38 @@ class Core
}
/**
* @param array $array1
*
* @return array
* Get core config values.
*/
public function convertEmptyStringsToNull($array)
protected function getCoreConfigValue($field, $channel, $locale)
{
foreach ($array as $key => $value) {
if ($value == "" || $value == "null") {
$array[$key] = null;
$fields = $this->getConfigField($field);
if (isset($fields['channel_based']) && $fields['channel_based']) {
if (isset($fields['locale_based']) && $fields['locale_based']) {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
'channel_code' => $channel,
'locale_code' => $locale,
]);
} else {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
'channel_code' => $channel,
]);
}
} else {
if (isset($fields['locale_based']) && $fields['locale_based']) {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
'locale_code' => $locale,
]);
} else {
$coreConfigValue = $this->coreConfigRepository->findOneWhere([
'code' => $field,
]);
}
}
return $array;
}
/**
* Create singletom object through single facade
*
* @param string $className
*
* @return object
*/
public function getSingletonInstance($className)
{
static $instance = [];
if (array_key_exists($className, $instance)) {
return $instance[$className];
}
return $instance[$className] = app($className);
}
/**
* Returns a string as selector part for identifying elements in views
*
* @param float $taxRate
*
* @return string
*/
public static function taxRateAsIdentifier(float $taxRate): string
{
return str_replace('.', '_', (string)$taxRate);
}
/**
* Get Shop email sender details
*
* @return array
*/
public function getSenderEmailDetails()
{
$sender_name = core()->getConfigData('general.general.email_settings.sender_name') ? core()->getConfigData('general.general.email_settings.sender_name') : config('mail.from.name');
$sender_email = core()->getConfigData('general.general.email_settings.shop_email_from') ? core()->getConfigData('general.general.email_settings.shop_email_from') : config('mail.from.address');
return [
'name' => $sender_name,
'email' => $sender_email,
];
}
/**
* Get Admin email details
*
* @return array
*/
public function getAdminEmailDetails()
{
$admin_name = core()->getConfigData('general.general.email_settings.admin_name') ? core()->getConfigData('general.general.email_settings.admin_name') : config('mail.admin.name');
$admin_email = core()->getConfigData('general.general.email_settings.admin_email') ? core()->getConfigData('general.general.email_settings.admin_email') : config('mail.admin.address');
return [
'name' => $admin_name,
'email' => $admin_email,
];
return $coreConfigValue;
}
}

View File

@ -123,5 +123,15 @@ class ConfigTableSeeder extends Seeder
'created_at' => $now,
'updated_at' => $now,
]);
DB::table('core_config')->insert([
'id' => 12,
'code' => 'catalog.products.homepage.out_of_stock_items',
'value' => '1',
'channel_code' => null,
'locale_code' => null,
'created_at' => $now,
'updated_at' => $now,
]);
}
}

View File

@ -162,24 +162,20 @@ class ExchangeRateController extends Controller
{
$exchangeRate = $this->exchangeRateRepository->findOrFail($id);
if ($this->exchangeRateRepository->count() == 1) {
session()->flash('error', trans('admin::app.settings.exchange_rates.last-delete-error'));
} else {
try {
Event::dispatch('core.exchange_rate.delete.before', $id);
try {
Event::dispatch('core.exchange_rate.delete.before', $id);
$this->exchangeRateRepository->delete($id);
$this->exchangeRateRepository->delete($id);
session()->flash('success', trans('admin::app.settings.exchange_rates.delete-success'));
session()->flash('success', trans('admin::app.settings.exchange_rates.delete-success'));
Event::dispatch('core.exchange_rate.delete.after', $id);
Event::dispatch('core.exchange_rate.delete.after', $id);
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-error', ['name' => 'Exchange rate']));
}
return response()->json(['message' => true], 200);
} catch (\Exception $e) {
report($e);
session()->flash('error', trans('admin::app.response.delete-error', ['name' => 'Exchange rate']));
}
return response()->json(['message' => false], 400);

View File

@ -72,9 +72,10 @@ class SubscriptionController extends Controller
$customer = $subscriber->customer;
$customer->subscribed_to_news_letter = $data['is_subscribed'];
$customer->save();
if (! is_null($customer)) {
$customer->subscribed_to_news_letter = $data['is_subscribed'];
$customer->save();
}
$result = $subscriber->update($data);

View File

@ -72,6 +72,7 @@ abstract class Address extends Model implements AddressContract
protected $casts = [
'additional' => 'array',
'default_address' => 'boolean',
];
/**

View File

@ -2,28 +2,8 @@
namespace Webkul\Customer\Helpers;
use Webkul\Customer\Repositories\WishlistRepository;
class Wishlist
{
/**
* WishlistRepository object
*
* @var \Webkul\Customer\Repositories\WishlistRepository
*/
protected $wishlistRepository;
/**
* Create a new controller instance.
*
* @param \Webkul\Customer\Repositories\WishlistRepository
* @return void
*/
public function __construct(WishlistRepository $wishlistRepository)
{
$this->wishlistRepository = $wishlistRepository;
}
/**
* Returns wishlist products for current customer.
*
@ -34,18 +14,16 @@ class Wishlist
{
$wishlist = false;
if (auth()->guard('customer')->user()) {
$wishlist = $this->wishlistRepository->findOneWhere([
'channel_id' => core()->getCurrentChannel()->id,
'product_id' => $product->product_id,
'customer_id' => auth()->guard('customer')->user()->id,
]);
if ($customer = auth()->guard('customer')->user()) {
$wishlist = $customer->wishlist_items->filter(function ($item) use ($product) {
return $item->channel_id == core()->getCurrentChannel()->id && $item->product_id == $product->product_id;
})->first();
}
if ($wishlist) {
return true;
return $wishlist;
}
return false;
return null;
}
}

View File

@ -42,4 +42,20 @@ class CustomerGroupRepository extends Repository
return $customer;
}
/**
* Returns guest group.
*
* @return object
*/
public function getCustomerGuestGroup()
{
static $customerGuestGroup;
if ($customerGuestGroup) {
return $customerGuestGroup;
}
return $customerGuestGroup = $this->findOneByField('code', 'guest');
}
}

Some files were not shown because too many files have changed in this diff Show More