Merge pull request #13 from bagisto/master

This commit is contained in:
Glenn Hermans 2021-02-16 15:19:05 +01:00 committed by GitHub
commit ea58f8a38e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
276 changed files with 4790 additions and 3323 deletions

5
.gitignore vendored
View File

@ -18,10 +18,7 @@ package-lock.json
/public/storage
/public/themes
/public/vendor
/resources/themes/velocity/*
/resources/lang/vendor/admin/*
/resources/lang/vendor/shop/*
/resources/lang/vendor/velocity/*
/resources/lang/vendor
/storage/*.key
/storage/dcc-data/
/vendor

View File

@ -2,6 +2,204 @@
#### This changelog consists the bug & security fixes and new features being included in the releases listed below.
## **v1.3.0 (16th of February 2021)** - *Release*
* [feature] - PayPal Smart Button for quick and fast payment.
* [feature] - Email Marketing-Newsletter to send the newsletter to your valuable customers.
* [feature] - Control on Displaying of out of stock Product.
* [feature] - Minimum Order Amount by which it will necessary to meet their order subtotal to make a successful purchase.
* [feature] - Add Video of Your Product.
* [feature] - Maintenance Mode, let search engines know that your site is currently down.
* [feature] - Buy Now at Product Page, Admin can easily enable/disable the Buy Now Button for both themes.
* [feature] - laravel Debugger Mode, This will help the developer/users to see all the packages they are using inside the Webkul folder.
* [enhancement] - Duplicated queries removed.
* [enhancement] - Improved lighthouse score.
* [enhancement] - Slider path should also work in default theme.
* [enhancement] - Add configuration to enable/disable the image search feature.
* [enhancement] - Multi product images should be changed on mouse hover.
* [enhancement] - Add configuration to set admin url while install using bagisto:install command.
* [enhancement] - Add confirm box while moving an item to wishlist from the cart page.
* [enhancement] - Add option to export auto generated coupons in cart rule.
* [enhancement] - Add bulk category delete functionality.
* [enhancement] - Default shop content should be localized.
* [enhancement] - Schedule cron job to process newsletter campaigns mails.
* [enhancement] - Showing configurable product base on catalog rule price.
* [enhancement] - Wishlist and Cart key in Product API.
* [enhancement] - Add a option in the channel configuration to enable/disable wishlist.
* [enhancement] - Add product number.
* #3886 [fixed] - Cart item not bound to the account when login with social login.
* #3785 [fixed] - Product filter is not working according to channel filter.
* #3879 [fixed] - Getting exception on uploading high size image in Invoice Slip Design logo.
* #3954 [fixed] - Featured New Product Adding Special Price the 2 columns in mobile version is broke.
* #3964 [fixed] - pay with paypal smart button is missing in checkout.
* #3940 [fixed] - bagisto:install defines APP_URL to localhost by default.
* #3957 [fixed] - Configurable product parent image is visible in cart instead of variant image.
* #3981 [fixed] - No validation message on creating addresses without required params.
* #4030 [fixed] - featured or new label should not visible if product is not exist in default theme.
* #4061 [fixed] - variant image is not visible when item added in wishlist.
* #4024 [fixed] - customer group price discount is not applied when product price and discount amount is same.
* #4062 [fixed] - search icon in velocity theme is not clickable.
* #4085 [fixed] - Not able to fetch invoice by API.
* #4094 [fixed] - filter is not working properly in case product name contains any special character.
* #4130 [fixed] - event ticket price field accepts negative values.
* #4117 [fixed] - error in booking product while booking a slot.
* #4124 [fixed] - Client Side validation issue in Special Price for ticket booking Product.
* #4191 [fixed] - back date should be disabled in booking products.
* #4105 [fixed] - Issue with total due in cash on delivery.
* #3975 [fixed] - Filter is not working properly for status column in case product has not been name and other required details.
* #4212 [fixed] - Error uninstall developer dependencies going into production mode.
* #4234 [fixed] - default values are not working in system configuration.
* #4228 [fixed] - add a validation if user trying to upload greater size image in image search.
* #3807 [fixed] - Can't locate path for migrations in bagisto/packages.
* #4248 [fixed] - PayPay scripts are being loaded even if inactive.
* #4277 [fixed] - subtotal is not updating when remove product from the minicart.
* #4287 [fixed] - Product locale not correctly selected since admin language select.
* #4119 [fixed] - Admin should not be able to create multiple cart rule using same coupon code.
* #4299 [fixed] - sort by newest first or oldest first doesn't work in category.
* #3932 [fixed] - When copying a product, replicating the image causes it to be volatile.
* #4335 [fixed] - Image search disable functionality is not working.
* #4325 [fixed] - address is not saving on onepage checkout.
* #4394 [fixed] - maintenance mode status is not working in channel section.
* #4372 [fixed] - The brand attribute should be deletable.
* #4393 [fixed] - composer test in windows.
* #4413 [fixed] - getting error when setup fresh bagisto from master.
* #4408 [fixed] - silder image not work.
* #4401 [fixed] - composer install --no-dev , gives error.
* #4192 [fixed] - db connection failed at first time when setup using bagisto:install.
* #4425 [fixed] - saved billing address details are not showing on onepage checkout.
* #4434 [fixed] - missing date picker option in event filter #4434.
* #3374 [fixed] - Social Login Error.
* #4440 [fixed] - getting exception when allow user role with marketing permission.
* #3002 [fixed] - Buggggggg iOS Safari images are stretched.
* #4456 [fixed] - getting exception when filter category, attribute, customer datagrid based on status.
* #4433 [fixed] - getting exception when filter campaigns/email templates based on status.
* #4452 [fixed] - products are not visible on homepage if filter based on ar locale.
* #4457 [fixed] - cart rule status always set as draft.
* #4428 [fixed] - user roles permission option always save when trying to uncheck selected option.
* #4392 [fixed] - Multiple cart rule is getting applied in case condition matches on applying only one coupon.
* #4459 [fixed] - disabled option should not accessible from routes in frontend.
* #4447 [fixed] - Product URl key not accepting value for Chinese, Japnese, Arabic locale.
* #4481 [fixed] - Shipping costs are not calculated with grand total.
* #4399 [fixed] - Role-based security issue - User with no permission has acces to some admin pages/controls.
* #4369 [fixed] - Product filter [Shop By].
* #4486 [fixed] - getting exception when copy cart rule.
* #4386 [fixed] - Slow Category Query.
* #4432 [fixed] - subscribed checkbox should be mark if customer is already subscribed.
* #4435 [fixed] - customer group condition doesn't match while sending newsletter email.
* #4506 [fixed] - customer group pricing fixed discount should accept decimal values.
* #4498 [fixed] - able to delete root category which is selected in channel.
* #4420 [fixed] - Invoice PDF breaking.
* #3638 [fixed] - Promotion, combine "percentage" & "fixed amount to whole cart" cart rules get wrong disco * unt amount.
* #3572 [fixed] - No info about other discounts in case there is multiple group pricing exist in same product.
* #4577 [fixed] - error on minicart while adding configurable item.
* #4571 [fixed] - video is not showing for variant product in product page.
* #4566 [fixed] - wrong attribute are visible on layered navigation.
* #4567 [fixed] - configurable product variant attribute options are not visible in layered navigation.
* #4590 [fixed] - getting exception on cart when remove minimum amount from backend.
* #4583 [fixed] - inactive template are sending in newsletter mail to subscribed users.
* #4596 [fixed] - Unable to view order at customer end.
* #4495 [fixed] - Only load the locales that are enabled on the channel.
* #4597 [fixed] - Add a product to Wishlist twice issue.
* #4620 [fixed] - value is not saved in fallback locale in configuration section.
* #4573 [fixed] - out of stock items are visible on category & search page when configuration is disabled.
## **v1.2.0 (8th of September 2020)** - *Release*
* [feature] - Config to add custom css and javascript (Eg. google anlytics)

View File

@ -1,13 +1,12 @@
{
"name": "bagisto/bagisto",
"description": "Bagisto Laravel ECommerce",
"description": "Bagisto Laravel E-Commerce",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.2.5",
"ext-curl": "*",
@ -33,19 +32,18 @@
"intervention/image": "^2.4",
"intervention/imagecache": "^2.3",
"kalnoy/nestedset": "5.0.1",
"khaled.alshamaa/ar-php": "^5.5",
"khaled.alshamaa/ar-php": "^6.0.0",
"konekt/concord": "^1.2",
"laravel/framework": "^7.0",
"laravel/scout": "^8.0",
"laravel/socialite": "^4.4",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"maatwebsite/excel": "3.1.19",
"maatwebsite/excel": "^3.1.26",
"paypal/paypal-checkout-sdk": "1.0.1",
"prettus/l5-repository": "^2.6",
"tymon/jwt-auth": "^1.0.0"
},
"require-dev": {
"codeception/codeception": "4.1.1",
"codeception/module-asserts": "^1.1",
@ -57,7 +55,6 @@
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
},
"replace": {
"bagisto/laravel-user": "v0.1.0",
"bagisto/laravel-admin": "v0.1.0",
@ -79,7 +76,6 @@
"bagisto/laravel-paypal": "v0.1.0",
"bagisto/laravel-discount": "v0.1.0"
},
"autoload": {
"classmap": [
"database/seeds",
@ -116,7 +112,6 @@
"Webkul\\Marketing\\": "packages/Webkul/Marketing/src"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Acceptance\\": "tests/acceptance/",
@ -125,7 +120,6 @@
"Tests\\Trigger\\": "tests/trigger/"
}
},
"extra": {
"laravel": {
"dont-discover": [
@ -133,22 +127,18 @@
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate",
"Webkul\\Core\\Events\\ComposerEvents::postCreateProject"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
],
"test": [
"set -e",
"@php artisan migrate:fresh --env=testing",
@ -171,4 +161,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}

2190
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

@ -3,7 +3,6 @@
use Maatwebsite\Excel\Excel;
return [
'exports' => [
/*
@ -24,6 +23,16 @@ return [
*/
'pre_calculate_formulas' => false,
/*
|--------------------------------------------------------------------------
| Enable strict null comparison
|--------------------------------------------------------------------------
|
| When enabling strict null comparison empty cells ('') will
| be added to the sheet.
*/
'strict_null_comparison' => false,
/*
|--------------------------------------------------------------------------
| CSV Settings
@ -40,13 +49,55 @@ return [
'include_separator_line' => false,
'excel_compatibility' => false,
],
/*
|--------------------------------------------------------------------------
| Worksheet properties
|--------------------------------------------------------------------------
|
| Configure e.g. default title, creator, subject,...
|
*/
'properties' => [
'creator' => '',
'lastModifiedBy' => '',
'title' => '',
'description' => '',
'subject' => '',
'keywords' => '',
'category' => '',
'manager' => '',
'company' => '',
],
],
'imports' => [
/*
|--------------------------------------------------------------------------
| Read Only
|--------------------------------------------------------------------------
|
| When dealing with imports, you might only be interested in the
| data that the sheet exists. By default we ignore all styles,
| however if you want to do some logic based on style data
| you can enable it by setting read_only to false.
|
*/
'read_only' => true,
'heading_row' => [
/*
|--------------------------------------------------------------------------
| Ignore Empty
|--------------------------------------------------------------------------
|
| When dealing with imports, you might be interested in ignoring
| rows that have null values or empty strings. By default rows
| containing empty strings or empty values are not ignored but can be
| ignored by enabling the setting ignore_empty to true.
|
*/
'ignore_empty' => false,
/*
|--------------------------------------------------------------------------
@ -57,6 +108,7 @@ return [
| Available options: none|slug|custom
|
*/
'heading_row' => [
'formatter' => 'slug',
],
@ -75,6 +127,27 @@ return [
'contiguous' => false,
'input_encoding' => 'UTF-8',
],
/*
|--------------------------------------------------------------------------
| Worksheet properties
|--------------------------------------------------------------------------
|
| Configure e.g. default title, creator, subject,...
|
*/
'properties' => [
'creator' => '',
'lastModifiedBy' => '',
'title' => '',
'description' => '',
'subject' => '',
'keywords' => '',
'category' => '',
'manager' => '',
'company' => '',
],
],
/*
@ -82,9 +155,8 @@ return [
| Extension detector
|--------------------------------------------------------------------------
|
| Configure here which writer type should be used when
| the package needs to guess the correct type
| based on the extension alone.
| Configure here which writer/reader type should be used when the package
| needs to guess the correct type based on the extension alone.
|
*/
'extension_detector' => [
@ -116,11 +188,9 @@ return [
'pdf' => Excel::DOMPDF,
],
'value_binder' => [
/*
|--------------------------------------------------------------------------
| Default Value Binder
| Value Binder
|--------------------------------------------------------------------------
|
| PhpSpreadsheet offers a way to hook into the process of a value being
@ -128,11 +198,66 @@ return [
| value should be formatted. If you want to change those defaults,
| you can implement your own default value binder.
|
| Possible value binders:
|
| [x] Maatwebsite\Excel\DefaultValueBinder::class
| [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
| [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class
|
*/
'value_binder' => [
'default' => Maatwebsite\Excel\DefaultValueBinder::class,
],
'transactions' => [
'cache' => [
/*
|--------------------------------------------------------------------------
| Default cell caching driver
|--------------------------------------------------------------------------
|
| By default PhpSpreadsheet keeps all cell values in memory, however when
| dealing with large files, this might result into memory issues. If you
| want to mitigate that, you can configure a cell caching driver here.
| When using the illuminate driver, it will store each value in a the
| cache store. This can slow down the process, because it needs to
| store each value. You can use the "batch" store if you want to
| only persist to the store when the memory limit is reached.
|
| Drivers: memory|illuminate|batch
|
*/
'driver' => 'memory',
/*
|--------------------------------------------------------------------------
| Batch memory caching
|--------------------------------------------------------------------------
|
| When dealing with the "batch" caching driver, it will only
| persist to the store when the memory limit is reached.
| Here you can tweak the memory limit to your liking.
|
*/
'batch' => [
'memory_limit' => 60000,
],
/*
|--------------------------------------------------------------------------
| Illuminate cache
|--------------------------------------------------------------------------
|
| When using the "illuminate" caching driver, it will automatically use
| your default cache store. However if you prefer to have the cell
| cache on a separate store, you can configure the store name here.
| You can use any store defined in your cache config. When leaving
| at "null" it will use the default store.
|
*/
'illuminate' => [
'store' => null,
],
],
/*
|--------------------------------------------------------------------------
@ -149,6 +274,7 @@ return [
| Supported handlers: null|db
|
*/
'transactions' => [
'handler' => 'db',
],
@ -163,7 +289,7 @@ return [
| storing reading or downloading. Here you can customize that path.
|
*/
'local_path' => sys_get_temp_dir(),
'local_path' => storage_path('framework/laravel-excel'),
/*
|--------------------------------------------------------------------------
@ -182,5 +308,21 @@ return [
'remote_disk' => null,
'remote_prefix' => null,
/*
|--------------------------------------------------------------------------
| Force Resync
|--------------------------------------------------------------------------
|
| When dealing with a multi server setup as above, it's possible
| for the clean up that occurs after entire queue has been run to only
| cleanup the server that the last AfterImportJob runs on. The rest of the server
| would still have the local temporary file stored on it. In this case your
| local storage limits can be exceeded and future imports won't be processed.
| To mitigate this you can set this config value to be true, so that after every
| queued chunk is processed the local temporary file is deleted on the server that
| processed it.
|
*/
'force_resync_remote' => null,
],
];

View File

@ -169,7 +169,8 @@ return [
*/
'acceptedConditions' => [
'=',
'like'
'like',
'in'
],
/*
|--------------------------------------------------------------------------

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,11 +14,9 @@ class Product extends JsonResource
*/
public function __construct($resource)
{
$this->productImageHelper = app('Webkul\Product\Helpers\ProductImage');
$this->productReviewHelper = app('Webkul\Product\Helpers\Review');
parent::__construct($resource);
$this->wishlistHelper = app('Webkul\Customer\Helpers\Wishlist');
}
/**
@ -29,52 +27,264 @@ 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,
'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')
),
'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' => ProductImageFacade::collection($product->images),
'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

@ -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

@ -2,8 +2,8 @@
namespace Webkul\Admin\DataGrids;
use Illuminate\Support\Facades\DB;
use Webkul\Ui\DataGrid\DataGrid;
use Illuminate\Support\Facades\DB;
class CustomerDataGrid extends DataGrid
{
@ -17,11 +17,12 @@ class CustomerDataGrid extends DataGrid
{
$queryBuilder = DB::table('customers')
->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id')
->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'customers.phone', 'customers.gender', 'status')
->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name as group', 'customers.phone', 'customers.gender', 'status')
->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name'));
$this->addFilter('customer_id', 'customers.id');
$this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)'));
$this->addFilter('group', 'customer_groups.name');
$this->addFilter('phone', 'customers.phone');
$this->addFilter('gender', 'customers.gender');
$this->addFilter('status', 'status');
@ -59,7 +60,7 @@ class CustomerDataGrid extends DataGrid
]);
$this->addColumn([
'index' => 'name',
'index' => 'group',
'label' => trans('admin::app.datagrid.group'),
'type' => 'string',
'searchable' => false,

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

@ -156,10 +156,7 @@ class InvoiceController extends Controller
*/
private function adjustArabicAndPersianContent($html)
{
/* temporary require */
require_once base_path('vendor/khaled.alshamaa/ar-php/src/arabic.php');
$arabic = new \ArPHP\I18N\arabic();
$arabic = new \ArPHP\I18N\Arabic();
$p = $arabic->arIdentify($html);

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'];
/**
* Send new invoice mail to the customer
*
* @param \Webkul\Sales\Contracts\Invoice $invoice
* @return void
*/
public function sendNewInvoiceMail($invoice)
{
$customerLocale = $this->getLocale($invoice);
/* getting capture id by paypal order id */
$captureID = $smartButton->getCaptureId($paypalOrderID);
try {
if ($invoice->email_sent) {
return;
/* 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
]
]);
}
/* 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

@ -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

@ -85,7 +85,7 @@
<div class="control-group">
<div class="control-group" :class="[errors.has(inputName + '[value]') ? 'has-error' : '']">
<input type="number" v-validate="{required: true, min_value: 0, ...(customerGroupPrice.value_type === 'discount' ? {max_value: 100} : {})}" :name="[inputName + '[value]']" v-model="customerGroupPrice.value" class="control" data-vv-as="&quot;{{ __('admin::app.datagrid.price') }}&quot;"/>
<input type="number" step=".01" v-validate="{required: true, min_value: 0, ...(customerGroupPrice.value_type === 'discount' ? {max_value: 100} : {})}" :name="[inputName + '[value]']" v-model="customerGroupPrice.value" class="control" data-vv-as="&quot;{{ __('admin::app.datagrid.price') }}&quot;"/>
<span class="control-error" v-if="errors.has(inputName + '[value]')">@{{ errors.first(inputName + '[value]') }}</span>
</div>
</div>

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>

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>

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;">

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;">

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>

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>

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>

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
{
@ -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

@ -2,6 +2,7 @@
namespace Webkul\Category\Http\Controllers;
use Webkul\Core\Models\Channel;
use Illuminate\Support\Facades\Event;
use Webkul\Category\Repositories\CategoryRepository;
use Webkul\Attribute\Repositories\AttributeRepository;
@ -9,7 +10,7 @@ use Webkul\Attribute\Repositories\AttributeRepository;
class CategoryController extends Controller
{
/**
* Contains route related configuration
* Contains route related configuration.
*
* @var array
*/
@ -147,15 +148,16 @@ class CategoryController extends Controller
{
$category = $this->categoryRepository->findOrFail($id);
if(strtolower($category->name) == "root") {
if ($this->isCategoryDeletable($category)) {
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
} else {
try {
Event::dispatch('catalog.category.delete.before', $id);
if($category->products->count() > 0) {
if ($category->products->count() > 0) {
$category->products()->delete();
}
$category->delete();
Event::dispatch('catalog.category.delete.after', $id);
@ -163,7 +165,7 @@ class CategoryController extends Controller
session()->flash('success', trans('admin::app.response.delete-success', ['name' => 'Category']));
return response()->json(['message' => true], 200);
} catch(\Exception $e) {
} catch (\Exception $e) {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Category']));
}
}
@ -172,7 +174,7 @@ class CategoryController extends Controller
}
/**
* Remove the specified resources from database
* Remove the specified resources from database.
*
* @return \Illuminate\Http\Response
*/
@ -185,7 +187,7 @@ class CategoryController extends Controller
$category = $this->categoryRepository->find($categoryId);
if (isset($category)) {
if(strtolower($category->name) == "root") {
if ($this->isCategoryDeletable($category)) {
$suppressFlash = false;
session()->flash('warning', trans('admin::app.response.delete-category-root', ['name' => 'Category']));
} else {
@ -193,14 +195,14 @@ class CategoryController extends Controller
$suppressFlash = true;
Event::dispatch('catalog.category.delete.before', $categoryId);
if($category->products->count() > 0) {
if ($category->products->count() > 0) {
$category->products()->delete();
}
$category->delete();
Event::dispatch('catalog.category.delete.after', $categoryId);
} catch(\Exception $e) {
} catch (\Exception $e) {
session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Category']));
}
}
@ -214,7 +216,11 @@ class CategoryController extends Controller
return redirect()->route($this->_config['redirect']);
}
/**
* Get category product count.
*
* @return \Illuminate\Http\Response
*/
public function categoryProductCount() {
$indexes = explode(",", request()->input('indexes'));
$product_count = 0;
@ -226,4 +232,24 @@ class CategoryController extends Controller
return response()->json(['product_count' => $product_count], 200);
}
/**
* Check whether the current category is deletable or not.
*
* This method will fetch all root category ids from the channel. If `id` is present,
* then it is not deletable.
*
* @param \Webkul\Category\Models\Category $category
* @return bool
*/
private function isCategoryDeletable($category)
{
static $rootIdInChannels;
if (! $rootIdInChannels) {
$rootIdInChannels = Channel::pluck('root_category_id');
}
return $category->id === 1 || $rootIdInChannels->contains($category->id);
}
}

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,24 @@ class Core
return ($channel = $this->getDefaultChannel()) ? $channelCode = $channel->code : '';
}
/**
* Returns the channel name.
*
* @return string
*/
public function getChannelName($channel): string
{
static $channelName;
if ($channelName) {
return $channelName;
}
return $channelName = $channel->name
?? $channel->translate(app()->getLocale())->name
?? $channel->translate(config('app.fallback_locale'))->name;
}
/**
* Returns all locales
*
@ -238,7 +267,7 @@ class Core
}
/**
* Returns current locale
* Returns current locale.
*
* @return \Webkul\Core\Contracts\Locale
*/
@ -260,7 +289,7 @@ class Core
}
/**
* Returns all Customer Groups
* Returns all customer groups.
*
* @return \Illuminate\Support\Collection
*/
@ -276,7 +305,7 @@ class Core
}
/**
* Returns all currencies
* Returns all currencies.
*
* @return \Illuminate\Support\Collection
*/
@ -292,7 +321,7 @@ class Core
}
/**
* Returns base channel's currency model
* Returns base channel's currency model.
*
* @return \Webkul\Core\Contracts\Currency
*/
@ -314,7 +343,7 @@ class Core
}
/**
* Returns base channel's currency code
* Returns base channel's currency code.
*
* @return string
*/
@ -330,7 +359,7 @@ class Core
}
/**
* Returns base channel's currency model
* Returns base channel's currency model.
*
* @return \Webkul\Core\Contracts\Currency
*/
@ -348,7 +377,7 @@ class Core
}
/**
* Returns base channel's currency code
* Returns base channel's currency code.
*
* @return string
*/
@ -364,7 +393,7 @@ class Core
}
/**
* Returns current channel's currency model
* Returns current channel's currency model.
*
* @return \Webkul\Core\Contracts\Currency
*/
@ -386,7 +415,7 @@ class Core
}
/**
* Returns current channel's currency code
* Returns current channel's currency code.
*
* @return string
*/
@ -402,7 +431,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 +487,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 +503,7 @@ class Core
}
/**
* Converts to base price
* Converts to base price.
*
* @param float $amount
* @param string $targetCurrencyCode
@ -485,7 +532,7 @@ class Core
}
/**
* Format and convert price with currency symbol
* Format and convert price with currency symbol.
*
* @param float $price
*
@ -501,7 +548,7 @@ class Core
}
/**
* Return currency symbol from currency code
* Return currency symbol from currency code.
*
* @param float $price
*
@ -515,7 +562,7 @@ class Core
}
/**
* Format and convert price with currency symbol
* Format and convert price with currency symbol.
*
* @param float $price
*
@ -532,7 +579,7 @@ class Core
}
/**
* Format and convert price with currency symbol
* Format and convert price with currency symbol.
*
* @return array
*/
@ -547,7 +594,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 +633,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 +667,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 +689,7 @@ class Core
}
/**
* Check whether sql date is empty
* Check whether sql date is empty.
*
* @param string $date
*
@ -675,7 +722,7 @@ class Core
}
/**
* Retrieve information from payment configuration
* Retrieve information from payment configuration.
*
* @param string $field
* @param int|string|null $channelId
@ -685,6 +732,11 @@ class Core
*/
public function getConfigData($field, $channel = null, $locale = null)
{
static $loadedConfigs = [];
if (array_key_exists($field, $loadedConfigs) && ! in_array($field, $this->coreConfigExceptions)) {
$coreConfigValue = $loadedConfigs[$field];
} else {
if (null === $channel) {
$channel = request()->get('channel') ?: ($this->getCurrentChannelCode() ?: $this->getDefaultChannelCode());
}
@ -693,43 +745,7 @@ class Core
$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,
]);
}
} 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,
]);
}
$loadedConfigs[$field] = $coreConfigValue = $this->getCoreConfigValue($field, $channel, $locale);
}
if (! $coreConfigValue) {
@ -746,7 +762,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 +774,7 @@ class Core
}
/**
* Retrieve all countries
* Retrieve all countries.
*
* @return \Illuminate\Support\Collection
*/
@ -768,7 +784,7 @@ class Core
}
/**
* Returns country name by code
* Returns country name by code.
*
* @param string $code
*
@ -782,7 +798,7 @@ class Core
}
/**
* Retrieve all country states
* Retrieve all country states.
*
* @param string $countryCode
*
@ -794,7 +810,7 @@ class Core
}
/**
* Retrieve all grouped states by country code
* Retrieve all grouped states by country code.
*
* @return \Illuminate\Support\Collection
*/
@ -810,7 +826,7 @@ class Core
}
/**
* Retrieve all grouped states by country code
* Retrieve all grouped states by country code.
*
* @return \Illuminate\Support\Collection
*/
@ -828,7 +844,7 @@ class Core
}
/**
* Returns time intervals
* Returns time intervals.
*
* @param \Illuminate\Support\Carbon $startDate
* @param \Illuminate\Support\Carbon $endDate
@ -888,7 +904,6 @@ class Core
}
/**
*
* @param string $date
* @param int $day
*
@ -910,7 +925,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 +1041,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 +1143,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

@ -67,7 +67,7 @@ class ExchangeRates extends ExchangeRate
$result = json_decode($result->getBody()->getContents(), true);
if (isset($result['success']) && ! $result['success']) {
throw new E\xception(
throw new \Exception(
isset($result['error']['info'])
? $result['error']['info']
: $result['error']['type'], 1);

View File

@ -162,9 +162,6 @@ 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);
@ -180,7 +177,6 @@ class ExchangeRateController extends Controller
session()->flash('error', trans('admin::app.response.delete-error', ['name' => 'Exchange rate']));
}
}
return response()->json(['message' => false], 400);
}

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');
}
}

View File

@ -61,7 +61,20 @@ class WishlistRepository extends Repository
*/
public function getCustomerWhishlist()
{
return $this->model->where([
$query = $this->model;
if (! core()->getConfigData('catalog.products.homepage.out_of_stock_items')) {
$query = $this->model
->leftJoin('products as ps', 'wishlist.product_id', '=', 'ps.id')
->leftJoin('product_inventories as pv', 'ps.id', '=', 'pv.product_id')
->where(function ($qb) {
$qb
->WhereIn('ps.type', ['configurable', 'grouped', 'downloadable', 'bundle', 'booking'])
->orwhereIn('ps.type', ['simple', 'virtual'])->where('pv.qty' , '>' , 0);
});
}
return $query->where([
'channel_id' => core()->getCurrentChannel()->id,
'customer_id' => auth()->guard('customer')->user()->id,
])->paginate(5);

View File

@ -15,4 +15,24 @@ class InventorySourceRepository extends Repository
{
return 'Webkul\Inventory\Contracts\InventorySource';
}
/**
* Returns channel inventory source ids.
*
* @return collection
*/
public function getChannelInventorySourceIds()
{
static $channelInventorySourceIds;
if ($channelInventorySourceIds) {
return $channelInventorySourceIds;
}
$found = core()->getCurrentChannel()->inventory_sources()
->where('status', 1)
->pluck('id');
return $channelInventorySourceIds = ($found ? $found : collect([]));
}
}

View File

@ -61,8 +61,10 @@ class Campaign
{
$campaigns = $this->campaignRepository->getModel()
->leftJoin('marketing_events', 'marketing_campaigns.marketing_event_id', 'marketing_events.id')
->leftJoin('marketing_templates', 'marketing_campaigns.marketing_template_id', 'marketing_templates.id')
->select('marketing_campaigns.*')
->where('status', 1)
->where('marketing_campaigns.status', 1)
->where('marketing_templates.status', 'active')
->where(function ($query) {
$query->where('marketing_events.date', Carbon::now()->format('Y-m-d'))
->orWhereNull('marketing_events.date');
@ -90,18 +92,9 @@ class Campaign
*/
public function getEmailAddresses($campaign)
{
$newsletterEmails = app('\Webkul\Core\Repositories\SubscribersListRepository')->getModel()
->where('is_subscribed', 1)
->where('channel_id', $campaign->channel_id)
->get('email');
$customerGroupEmails = $campaign->customer_group->customers()->where('subscribed_to_news_letter', 1)->get('email');
$emails = [];
foreach ($newsletterEmails as $row) {
$emails[] = $row->email;
}
$customerGroupEmails = $campaign->customer_group->customers()->where('subscribed_to_news_letter', 1)->get('email');
foreach ($customerGroupEmails as $row) {
$emails[] = $row->email;

View File

@ -3,8 +3,8 @@
namespace Webkul\Marketing\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Event;
use Webkul\Marketing\Console\Commands\EmailsCommand;
use Illuminate\Console\Scheduling\Schedule;
class MarketingServiceProvider extends ServiceProvider
{
@ -19,9 +19,9 @@ class MarketingServiceProvider extends ServiceProvider
$this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'marketing');
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'marketing');
$this->callAfterResolving(Schedule::class, function (Schedule $schedule) {
$schedule->command('campaign:process')->daily();
});
}
/**
@ -31,7 +31,6 @@ class MarketingServiceProvider extends ServiceProvider
*/
public function register()
{
if ($this->app->runningInConsole()) {
$this->commands([EmailsCommand::class]);
}

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