From abbb79a16cb96f96dcd3a0f275ce4946eaee0746 Mon Sep 17 00:00:00 2001 From: Matt April Date: Sun, 27 Oct 2019 11:10:18 -0400 Subject: [PATCH 01/37] Fixed payment type not properly wrapped in labels (minor usability/accessability fix) --- .../Resources/views/checkout/onepage/payment.blade.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php index 20f2c30d9..ac34652ba 100755 --- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage/payment.blade.php @@ -19,12 +19,10 @@ - {{-- --}} + + {{ $payment['method_title'] }} + - - - {{ $payment['method_title'] }} -
From c54d803bbf8d768d72071358c39abe90556131d2 Mon Sep 17 00:00:00 2001 From: Herbert Date: Mon, 18 Nov 2019 16:04:45 +0100 Subject: [PATCH 02/37] introduce 'checkout.order.orderitem.save.[before/after]' events --- .../src/Repositories/OrderRepository.php | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index 7065ef8bd..18740b1b1 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -3,12 +3,11 @@ namespace Webkul\Sales\Repositories; use Illuminate\Container\Container as App; -use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Event; use Webkul\Core\Eloquent\Repository; -use Webkul\Sales\Contracts\Order; -use Webkul\Sales\Repositories\OrderItemRepository; use Webkul\Core\Models\CoreConfig; +use Webkul\Sales\Contracts\Order; /** * Order Reposotory @@ -35,8 +34,9 @@ class OrderRepository extends Repository /** * Create a new repository instance. * - * @param Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository - * @param Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository + * @param Webkul\Sales\Repositories\OrderItemRepository $orderItemRepository + * @param Webkul\Sales\Repositories\DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository + * * @return void */ public function __construct( @@ -65,6 +65,7 @@ class OrderRepository extends Repository /** * @param array $data + * * @return mixed */ public function create(array $data) @@ -101,6 +102,8 @@ class OrderRepository extends Repository $order->addresses()->create($data['billing_address']); foreach ($data['items'] as $item) { + Event::fire('checkout.order.orderitem.save.before', $data); + $orderItem = $this->orderItemRepository->create(array_merge($item, ['order_id' => $order->id])); if (isset($item['children']) && $item['children']) { @@ -112,6 +115,8 @@ class OrderRepository extends Repository $this->orderItemRepository->manageInventory($orderItem); $this->downloadableLinkPurchasedRepository->saveLinks($orderItem, 'available'); + + Event::fire('checkout.order.orderitem.save.after', $data); } Event::fire('checkout.order.save.after', $order); @@ -128,6 +133,7 @@ class OrderRepository extends Repository /** * @param int $orderId + * * @return mixed */ public function cancel($orderId) @@ -152,11 +158,11 @@ class OrderRepository extends Repository } else { $orderItems[] = $item; } - + foreach ($orderItems as $orderItem) { if ($orderItem->product) $this->orderItemRepository->returnQtyToProductInventory($orderItem); - + if ($orderItem->qty_ordered) { $orderItem->qty_canceled += $orderItem->qty_to_cancel; $orderItem->save(); @@ -188,19 +194,21 @@ class OrderRepository extends Repository { $config = new CoreConfig(); - $invoiceNumberPrefix = $config->where('code','=',"sales.orderSettings.order_number.order_number_prefix")->first() - ? $config->where('code','=',"sales.orderSettings.order_number.order_number_prefix")->first()->value : false; - - $invoiceNumberLength = $config->where('code','=',"sales.orderSettings.order_number.order_number_length")->first() - ? $config->where('code','=',"sales.orderSettings.order_number.order_number_length")->first()->value : false; - - $invoiceNumberSuffix = $config->where('code','=',"sales.orderSettings.order_number.order_number_suffix")->first() - ? $config->where('code','=',"sales.orderSettings.order_number.order_number_suffix")->first()->value: false; + foreach ([ + 'Prefix' => 'prefix', + 'Length' => 'length', + 'Suffix' => 'suffix', + ] as $varSuffix => $confKey) { + $var = "invoiceNumber{$varSuffix}"; + $$var = $config + ->where('code', '=', "sales.orderSettings.order_number.{$confKey}") + ->first() ?: false; + } $lastOrder = $this->model->orderBy('id', 'desc')->limit(1)->first(); $lastId = $lastOrder ? $lastOrder->id : 0; - if ($invoiceNumberLength && ( $invoiceNumberPrefix || $invoiceNumberSuffix) ) { + if ($invoiceNumberLength && ($invoiceNumberPrefix || $invoiceNumberSuffix)) { $invoiceNumber = $invoiceNumberPrefix . sprintf("%0{$invoiceNumberLength}d", 0) . ($lastId + 1) . $invoiceNumberSuffix; } else { $invoiceNumber = $lastId + 1; @@ -211,13 +219,14 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function isInCompletedState($order) { $totalQtyOrdered = $totalQtyInvoiced = $totalQtyShipped = $totalQtyRefunded = $totalQtyCanceled = 0; - foreach ($order->items()->get() as $item) { + foreach ($order->items()->get() as $item) { $totalQtyOrdered += $item->qty_ordered; $totalQtyInvoiced += $item->qty_invoiced; @@ -241,6 +250,7 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function isInCanceledState($order) @@ -257,13 +267,14 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function isInClosedState($order) { $totalQtyOrdered = $totalQtyRefunded = $totalQtyCanceled = 0; - foreach ($order->items()->get() as $item) { + foreach ($order->items()->get() as $item) { $totalQtyOrdered += $item->qty_ordered; $totalQtyRefunded += $item->qty_refunded; $totalQtyCanceled += $item->qty_canceled; @@ -274,6 +285,7 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return void */ public function updateOrderStatus($order) @@ -294,6 +306,7 @@ class OrderRepository extends Repository /** * @param mixed $order + * * @return mixed */ public function collectTotals($order) From 12dd5a4909f9d2ea947b28c43c545d3213d52264 Mon Sep 17 00:00:00 2001 From: Herbert Date: Thu, 21 Nov 2019 13:42:32 +0100 Subject: [PATCH 03/37] adjusted OrderRepository incrementId and added tiny unit test --- .../src/Repositories/OrderRepository.php | 17 +++++---- .../tests/sales/order/OrderRepositoryCest.php | 37 +++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index 18740b1b1..82420e34e 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -8,9 +8,10 @@ use Illuminate\Support\Facades\Event; use Webkul\Core\Eloquent\Repository; use Webkul\Core\Models\CoreConfig; use Webkul\Sales\Contracts\Order; +use Webkul\Sales\Models\Order as OrderModel; /** - * Order Reposotory + * Order Repository * * @author Jitendra Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) @@ -58,7 +59,7 @@ class OrderRepository extends Repository * @return Mixed */ - function model() + public function model() { return Order::class; } @@ -140,13 +141,13 @@ class OrderRepository extends Repository { $order = $this->findOrFail($orderId); - if (! $order->canCancel()) + if (!$order->canCancel()) return false; Event::fire('sales.order.cancel.before', $order); foreach ($order->items as $item) { - if (! $item->qty_to_cancel) + if (!$item->qty_to_cancel) continue; $orderItems = []; @@ -190,7 +191,7 @@ class OrderRepository extends Repository /** * @return integer */ - public function generateIncrementId() + public function generateIncrementId(): int { $config = new CoreConfig(); @@ -201,11 +202,11 @@ class OrderRepository extends Repository ] as $varSuffix => $confKey) { $var = "invoiceNumber{$varSuffix}"; $$var = $config - ->where('code', '=', "sales.orderSettings.order_number.{$confKey}") + ->where('code', '=', "sales.orderSettings.order_number.order_number_{$confKey}") ->first() ?: false; } - $lastOrder = $this->model->orderBy('id', 'desc')->limit(1)->first(); + $lastOrder = $this->order->orderBy('id', 'desc')->limit(1)->first(); $lastId = $lastOrder ? $lastOrder->id : 0; if ($invoiceNumberLength && ($invoiceNumberPrefix || $invoiceNumberSuffix)) { @@ -230,7 +231,7 @@ class OrderRepository extends Repository $totalQtyOrdered += $item->qty_ordered; $totalQtyInvoiced += $item->qty_invoiced; - if (! $item->isStockable()) { + if (!$item->isStockable()) { $totalQtyShipped += $item->qty_ordered; } else { $totalQtyShipped += $item->qty_shipped; diff --git a/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php b/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php new file mode 100644 index 000000000..96520ffef --- /dev/null +++ b/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php @@ -0,0 +1,37 @@ +repository = Mockery::mock(OrderRepository::class); + $this->repository + ->shouldReceive('generateIncrementId') + ->andSet('order', new Order); + } + + public function testGenerateIncrementIdOnEmptyDatabase(UnitTester $I) + { + $result = $this->repository->generateIncrementId(); + + $I->expect(1, $result); + } + + public function testGenerateIncrementIdOnFilledDatabase(UnitTester $I) + { + $order = new Order(['id' => rand(666, 1337)]); + $order->save(); + + $result = $this->repository->generateIncrementId(); + + $I->expect($order->id + 1, $result); + } +} From 835e5ce56a99a5c364152d6efb26694c0da31229 Mon Sep 17 00:00:00 2001 From: Herbert Date: Thu, 21 Nov 2019 13:48:34 +0100 Subject: [PATCH 04/37] use (! ... codestyle --- .../Webkul/Sales/src/Repositories/OrderItemRepository.php | 3 ++- packages/Webkul/Sales/src/Repositories/OrderRepository.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php index 39c8bf890..72da2f48d 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderItemRepository.php @@ -3,6 +3,7 @@ namespace Webkul\Sales\Repositories; use Illuminate\Container\Container as App; +use Illuminate\Support\Facades\Event; use Webkul\Core\Eloquent\Repository; use Webkul\Sales\Contracts\OrderItem; @@ -51,7 +52,7 @@ class OrderItemRepository extends Repository $totalInvoiced = $baseTotalInvoiced = 0; $taxInvoiced = $baseTaxInvoiced = 0; - + $totalRefunded = $baseTotalRefunded = 0; $taxRefunded = $baseTaxRefunded = 0; diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index 82420e34e..f827cc219 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -141,13 +141,13 @@ class OrderRepository extends Repository { $order = $this->findOrFail($orderId); - if (!$order->canCancel()) + if (! $order->canCancel()) return false; Event::fire('sales.order.cancel.before', $order); foreach ($order->items as $item) { - if (!$item->qty_to_cancel) + if (! $item->qty_to_cancel) continue; $orderItems = []; @@ -231,7 +231,7 @@ class OrderRepository extends Repository $totalQtyOrdered += $item->qty_ordered; $totalQtyInvoiced += $item->qty_invoiced; - if (!$item->isStockable()) { + if (! $item->isStockable()) { $totalQtyShipped += $item->qty_ordered; } else { $totalQtyShipped += $item->qty_shipped; From 64ad1e3cfbdc014e731605f4b7131488b49ec30d Mon Sep 17 00:00:00 2001 From: Herbert Date: Thu, 21 Nov 2019 13:51:08 +0100 Subject: [PATCH 05/37] added .phpcs_cache to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1eea901cd..91f23accb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ composer.lock yarn.lock package-lock.json yarn.lock +.php_cs.cache From 95684a64a516e8b8568930616b8efd60a0c90a22 Mon Sep 17 00:00:00 2001 From: Herbert Date: Thu, 21 Nov 2019 13:51:17 +0100 Subject: [PATCH 06/37] s/order/model --- packages/Webkul/Sales/src/Repositories/OrderRepository.php | 2 +- .../Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index f827cc219..aed17581d 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -206,7 +206,7 @@ class OrderRepository extends Repository ->first() ?: false; } - $lastOrder = $this->order->orderBy('id', 'desc')->limit(1)->first(); + $lastOrder = $this->model->orderBy('id', 'desc')->limit(1)->first(); $lastId = $lastOrder ? $lastOrder->id : 0; if ($invoiceNumberLength && ($invoiceNumberPrefix || $invoiceNumberSuffix)) { diff --git a/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php b/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php index 96520ffef..3934f471e 100644 --- a/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php +++ b/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php @@ -15,7 +15,7 @@ class OrderRepositoryCest $this->repository = Mockery::mock(OrderRepository::class); $this->repository ->shouldReceive('generateIncrementId') - ->andSet('order', new Order); + ->andSet('model', new Order); } public function testGenerateIncrementIdOnEmptyDatabase(UnitTester $I) From eea69a546fe1afb8291a8c0dfc1856e770dbba6a Mon Sep 17 00:00:00 2001 From: Herbert Date: Thu, 21 Nov 2019 14:47:54 +0100 Subject: [PATCH 07/37] use ReflectionClass for unit test --- .../tests/sales/order/OrderRepositoryCest.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php b/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php index 3934f471e..ea2dddbb7 100644 --- a/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php +++ b/packages/Webkul/Sales/src/tests/sales/order/OrderRepositoryCest.php @@ -1,10 +1,7 @@ repository = Mockery::mock(OrderRepository::class); - $this->repository - ->shouldReceive('generateIncrementId') - ->andSet('model', new Order); + // @see https://stackoverflow.com/a/8457580 + $reflection = new ReflectionClass(OrderRepository::class); + + $property = $reflection->getProperty('model'); + $property->setAccessible(true); + + $this->repository = $reflection->newInstanceWithoutConstructor(); + $property->setValue($this->repository, new Order()); } public function testGenerateIncrementIdOnEmptyDatabase(UnitTester $I) { $result = $this->repository->generateIncrementId(); - $I->expect(1, $result); + $I->assertEquals(1, $result); } public function testGenerateIncrementIdOnFilledDatabase(UnitTester $I) @@ -32,6 +33,6 @@ class OrderRepositoryCest $result = $this->repository->generateIncrementId(); - $I->expect($order->id + 1, $result); + $I->assertEquals($order->id + 1, $result); } } From 9a43776cc01ac3030d13c622b228aac1179338fa Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Thu, 21 Nov 2019 16:56:21 +0100 Subject: [PATCH 08/37] introduce ProductType Helper --- .../API/Http/Resources/Catalog/Product.php | 3 +- .../views/sales/refunds/create.blade.php | 6 +- .../Discount/src/Helpers/Catalog/Apply.php | 3 +- .../Helpers/Catalog/ConvertXToProductId.php | 11 +-- .../Product/src/Helpers/ProductType.php | 40 +++++++++++ .../Http/Controllers/ProductController.php | 5 +- .../Product/src/Listeners/ProductFlat.php | 3 +- .../Webkul/Product/src/Type/AbstractType.php | 67 ++++++++++++++++--- .../Webkul/Product/src/Type/Configurable.php | 13 +++- .../view/configurable-options.blade.php | 2 +- 10 files changed, 128 insertions(+), 25 deletions(-) create mode 100644 packages/Webkul/Product/src/Helpers/ProductType.php diff --git a/packages/Webkul/API/Http/Resources/Catalog/Product.php b/packages/Webkul/API/Http/Resources/Catalog/Product.php index 711ed1c42..c4a1ec895 100644 --- a/packages/Webkul/API/Http/Resources/Catalog/Product.php +++ b/packages/Webkul/API/Http/Resources/Catalog/Product.php @@ -3,6 +3,7 @@ namespace Webkul\API\Http\Resources\Catalog; use Illuminate\Http\Resources\Json\JsonResource; +use Webkul\Product\Helpers\ProductType; class Product extends JsonResource { @@ -44,7 +45,7 @@ class Product extends JsonResource 'base_image' => $this->productImageHelper->getProductBaseImage($product), 'variants' => Self::collection($this->variants), 'in_stock' => $product->haveSufficientQuantity(1), - $this->mergeWhen($product->type == 'configurable', [ + $this->mergeWhen($product->getTypeInstance()->isComposite(), [ 'super_attributes' => Attribute::collection($product->super_attributes), ]), 'special_price' => $this->when( diff --git a/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php index 8a273df8b..e0e0ac3d1 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/refunds/create.blade.php @@ -241,14 +241,14 @@ @foreach ($order->items as $item) - {{ $item->type == 'configurable' ? $item->child->sku : $item->sku }} + {{ Webkul\Product\Helpers\ProductType::hasVariants($item->type) ? $item->child->sku : $item->sku }} {{ $item->name }} @if (isset($item->additional['attributes']))
- + @foreach ($item->additional['attributes'] as $attribute) {{ $attribute['attribute_name'] }} : {{ $attribute['option_label'] }}
@endforeach @@ -417,7 +417,7 @@ if (! response.data) { window.flashMessages = [{ 'type': 'alert-error', - 'message': "{{ __('admin::app.sales.refunds.invalid-qty') }}" + 'message': "{{ __('admin::app.sales.refunds.invalid-qty') }}" }]; this_this.$root.addFlashMessages() diff --git a/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php b/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php index 855d8d065..4a8ba4d8e 100644 --- a/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php +++ b/packages/Webkul/Discount/src/Helpers/Catalog/Apply.php @@ -6,6 +6,7 @@ use Webkul\Discount\Repositories\CatalogRuleRepository as CatalogRule; use Webkul\Discount\Repositories\CatalogRuleProductsRepository as CatalogRuleProducts; use Webkul\Discount\Repositories\CatalogRuleProductsPriceRepository as CatalogRuleProductsPrice; use Webkul\Discount\Helpers\Catalog\ConvertXToProductId as ConvertX; +use Webkul\Product\Helpers\ProductType; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Discount\Helpers\Catalog\Sale; @@ -453,7 +454,7 @@ class Apply extends Sale foreach ($productIDs as $productID) { $product = $products->find($productID); - if ($product->type == 'configurable') { + if (ProductType::hasVariants($product->type)) { $variants = $product->variants; foreach($variants as $variant) { diff --git a/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php b/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php index c6e4cd79a..91df9871f 100644 --- a/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php +++ b/packages/Webkul/Discount/src/Helpers/Catalog/ConvertXToProductId.php @@ -6,6 +6,7 @@ use Webkul\Discount\Repositories\CatalogRuleRepository as CatalogRule; use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Attribute\Repositories\AttributeOptionRepository as AttributeOption; use Webkul\Category\Repositories\CategoryRepository as Category; +use Webkul\Product\Helpers\ProductType; use Webkul\Product\Repositories\ProductRepository as Product; use Webkul\Product\Models\ProductAttributeValue as ProductAttributeValue; @@ -113,7 +114,7 @@ class ConvertXToProductId $products = collect(); foreach ($attributeOptions as $attributeOption) { - if (isset($attributeOption->type) && $attributeOption->name != null && $attributeOption->condition != null && $attributeOption->value != [] && $attributeOption->type != null) { + if (isset($attributeOption->type) && $attributeOption->attribute != null && $attributeOption->condition != null && $attributeOption->value != [] && $attributeOption->type != null) { $selectedOptions = $attributeOption->value; if ($attributeOption->type == 'select' || $attributeOption->type == 'multiselect') { @@ -162,17 +163,17 @@ class ConvertXToProductId if ($testCondition == '{}') { $foundProducts = $this->product->findWhere([ ['sku', 'like', '%' . $testValue . '%'], - ['type', '!=', 'configurable'] - ])->flatten()->all(); + ['type', 'NOT IN', ProductType::getAllTypesHavingVariants()] + ])->flatten()->all(); } else if ($testCondition == '!{}') { $foundProducts = $this->product->findWhere([ ['sku', 'not like', '%' . $testValue . '%'], - ['type', '!=', 'configurable'] + ['type', 'NOT IN', ProductType::getAllTypesHavingVariants()] ])->flatten()->all(); } else if ($testCondition == '=') { $foundProducts = $this->product->findWhere([ ['sku', '=', $testValue], - ['type', '!=', 'configurable'] + ['type', 'NOT IN', ProductType::getAllTypesHavingVariants()] ])->flatten()->all(); } } diff --git a/packages/Webkul/Product/src/Helpers/ProductType.php b/packages/Webkul/Product/src/Helpers/ProductType.php new file mode 100644 index 000000000..9dcf87c32 --- /dev/null +++ b/packages/Webkul/Product/src/Helpers/ProductType.php @@ -0,0 +1,40 @@ +hasVariants(); + } + + /** + * Get all ProductTypes that are allowed to have variants + * + * @return array of product_types->keys + */ + public static function getAllTypesHavingVariants(): array + { + foreach (config('product_types') as $type) + { + if (self::hasVariants($type['key'])) + { + array_push($havingVariants, $type['key']); + } + } + + return $havingVariants; + } +} \ No newline at end of file diff --git a/packages/Webkul/Product/src/Http/Controllers/ProductController.php b/packages/Webkul/Product/src/Http/Controllers/ProductController.php index 0a4d0da0c..9134991d4 100755 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -4,6 +4,7 @@ namespace Webkul\Product\Http\Controllers; use Illuminate\Support\Facades\Event; use Webkul\Product\Http\Requests\ProductForm; +use Webkul\Product\Helpers\ProductType; use Webkul\Category\Repositories\CategoryRepository; use Webkul\Product\Repositories\ProductRepository; use Webkul\Product\Repositories\ProductDownloadableLinkRepository; @@ -140,13 +141,13 @@ class ProductController extends Controller public function store() { if (! request()->get('family') - && request()->input('type') == 'configurable' + && ProductType::hasVariants(request()->input('type')) && request()->input('sku') != '') { return redirect(url()->current() . '?type=' . request()->input('type') . '&family=' . request()->input('attribute_family_id') . '&sku=' . request()->input('sku')); } - if (request()->input('type') == 'configurable' + if (ProductType::hasVariants(request()->input('type')) && (! request()->has('super_attributes') || ! count(request()->get('super_attributes')))) { diff --git a/packages/Webkul/Product/src/Listeners/ProductFlat.php b/packages/Webkul/Product/src/Listeners/ProductFlat.php index a993a58ae..ecb8ffe9a 100644 --- a/packages/Webkul/Product/src/Listeners/ProductFlat.php +++ b/packages/Webkul/Product/src/Listeners/ProductFlat.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Attribute\Repositories\AttributeOptionRepository; +use Webkul\Product\Helpers\ProductType; use Webkul\Product\Repositories\ProductFlatRepository; use Webkul\Product\Repositories\ProductAttributeValueRepository; use Webkul\Product\Models\ProductAttributeValue; @@ -148,7 +149,7 @@ class ProductFlat { $this->createFlat($product); - if ($product->type == 'configurable') { + if (ProductType::hasVariants($product->type)) { foreach ($product->variants()->get() as $variant) { $this->createFlat($variant, $product); } diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 75abbba1e..44e6a76a5 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -3,6 +3,7 @@ namespace Webkul\Product\Type; use Illuminate\Support\Facades\Storage; +use phpDocumentor\Reflection\Types\Boolean; use Webkul\Attribute\Repositories\AttributeRepository; use Webkul\Product\Repositories\ProductRepository; use Webkul\Product\Repositories\ProductAttributeValueRepository; @@ -57,7 +58,7 @@ abstract class AbstractType /** * Product Image helper instance - * + * * @var ProductImage */ protected $productImageHelper; @@ -104,6 +105,13 @@ abstract class AbstractType */ protected $canBeMovedFromWishlistToCart = true; + /** + * Has child products aka variants + * + * @var boolean + */ + protected $hasVariants = false; + /** * Create a new product type instance. * @@ -160,16 +168,24 @@ abstract class AbstractType foreach ($product->attribute_family->custom_attributes as $attribute) { if ($attribute->type == 'boolean') + { $data[$attribute->code] = isset($data[$attribute->code]) && $data[$attribute->code] ? 1 : 0; + } if (! isset($data[$attribute->code])) + { continue; + } if ($attribute->type == 'date' && $data[$attribute->code] == '') + { $data[$attribute->code] = null; + } if ($attribute->type == 'multiselect' || $attribute->type == 'checkbox') + { $data[$attribute->code] = implode(",", $data[$attribute->code]); + } if ($attribute->type == 'image' || $attribute->type == 'file') { $data[$attribute->code] = gettype($data[$attribute->code]) == 'object' @@ -199,15 +215,19 @@ abstract class AbstractType ); if ($attribute->type == 'image' || $attribute->type == 'file') + { Storage::delete($attributeValue->text_value); + } } } - $route = request()->route() ? request()->route()->getName() : ""; + $route = request()->route() ? request()->route()->getName() : ""; if ($route != 'admin.catalog.products.massupdate') { if (isset($data['categories'])) + { $product->categories()->sync($data['categories']); + } $product->up_sells()->sync($data['up_sell'] ?? []); @@ -244,8 +264,10 @@ abstract class AbstractType public function isSaleable() { if (! $this->product->status) + { return false; - + } + return true; } @@ -260,7 +282,7 @@ abstract class AbstractType } /** - * Return true if this product can have inventory + * Return true if this product can be composite * * @return boolean */ @@ -269,6 +291,16 @@ abstract class AbstractType return $this->isComposite; } + /** + * Return true if this product can have variants + * + * @return bool + */ + public function hasVariants(): bool + { + return $this->hasVariants; + } + /** * @param integer $qty * @return bool @@ -277,7 +309,7 @@ abstract class AbstractType { return $this->haveSufficientQuantity; } - + /** * Return true if this product can have inventory * @@ -311,14 +343,17 @@ abstract class AbstractType foreach ($this->product->inventories as $inventory) { if (is_numeric($index = $channelInventorySourceIds->search($inventory->inventory_source_id))) + { $total += $inventory->qty; + } } $orderedInventory = $this->product->ordered_inventories() ->where('channel_id', core()->getCurrentChannel()->id) ->first(); - if ($orderedInventory) { + if ($orderedInventory) + { $total -= $orderedInventory->qty; } @@ -345,10 +380,14 @@ abstract class AbstractType public function getEditableAttributes($group = null, $skipSuperAttribute = true) { if ($skipSuperAttribute) + { $this->skipAttributes = array_merge($this->product->super_attributes->pluck('code')->toArray(), $this->skipAttributes); + } if (! $group) + { return $this->product->attribute_family->custom_attributes()->whereNotIn('attributes.code', $this->skipAttributes)->get(); + } return $group->custom_attributes()->whereNotIn('code', $this->skipAttributes)->get(); } @@ -381,7 +420,9 @@ abstract class AbstractType public function getMinimalPrice() { if ($this->haveSpecialPrice()) + { return $this->product->special_price; + } return $this->product->price; } @@ -422,10 +463,14 @@ abstract class AbstractType public function haveSpecialPrice() { if (is_null($this->product->special_price) || ! (float) $this->product->special_price) + { return false; + } if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to)) + { return true; + } return false; } @@ -480,7 +525,9 @@ abstract class AbstractType $data = $this->getQtyRequest($data); if (! $this->haveSufficientQuantity($data['quantity'])) + { return trans('shop::app.checkout.cart.quantity.inventory_warning'); + } $price = $this->getFinalPrice(); @@ -515,11 +562,13 @@ abstract class AbstractType public function getQtyRequest($data) { if ($item = Cart::getItemByProduct(['additional' => $data])) + { $data['quantity'] += $item->quantity; + } return $data; } - + /** * * @param array $options1 @@ -546,7 +595,7 @@ abstract class AbstractType return true; } - + /** * Returns additional information for items * @@ -591,7 +640,9 @@ abstract class AbstractType $price = $item->product->getTypeInstance()->getFinalPrice(); if ($price == $item->base_price) + { return; + } $item->base_price = $price; $item->price = core()->convertPrice($price); diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 79cb4c081..6977bf5de 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -22,7 +22,7 @@ class Configurable extends AbstractType /** * These blade files will be included in product edit page - * + * * @var array */ protected $additionalViews = [ @@ -47,6 +47,13 @@ class Configurable extends AbstractType */ protected $showQuantityBox = true; + /** + * Has child products aka variants + * + * @var boolean + */ + protected $hasVariants = true; + /** * @param array $data * @return Product @@ -416,7 +423,7 @@ class Configurable extends AbstractType return $products; } - + /** * * @param array $options1 @@ -451,7 +458,7 @@ class Configurable extends AbstractType ]; } - return $data; + return $data; } /** diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php index 154bc0815..3e4b74eca 100755 --- a/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/configurable-options.blade.php @@ -1,4 +1,4 @@ -@if ($product->type == 'configurable') +@if (Webkul\Product\Helpers\ProductType::hasVariants($product->type)) @inject ('configurableOptionHelper', 'Webkul\Product\Helpers\ConfigurableOption') From aaa398934f97fb21070df43f05efb11f451388e5 Mon Sep 17 00:00:00 2001 From: Shubham Mehrotra <41280839+shubhwebkul@users.noreply.github.com> Date: Fri, 22 Nov 2019 12:40:29 +0530 Subject: [PATCH 09/37] Update 3_Support_question.md --- .github/ISSUE_TEMPLATE/3_Support_question.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/3_Support_question.md b/.github/ISSUE_TEMPLATE/3_Support_question.md index a53ef6fa7..d6c5e5020 100644 --- a/.github/ISSUE_TEMPLATE/3_Support_question.md +++ b/.github/ISSUE_TEMPLATE/3_Support_question.md @@ -1,5 +1,5 @@ --- -name: "🧐 Support Question" +name: "❔ Support Question" about: 'This repository is only for reporting bugs or problems. If you need help, see: https://github.com/bagisto/bagisto#documentation' --- @@ -8,4 +8,4 @@ This repository is only for reporting bugs or issues. If you need support, pleas 1. Create support ticket on https://bagisto.uvdesk.com -Thanks! \ No newline at end of file +Thanks! From e65ef14ec1af8824ba3cf096096150aff0b1912c Mon Sep 17 00:00:00 2001 From: Herbert Date: Fri, 22 Nov 2019 08:49:22 +0100 Subject: [PATCH 10/37] removed type hint (int) --- .../src/Repositories/OrderRepository.php | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/Webkul/Sales/src/Repositories/OrderRepository.php b/packages/Webkul/Sales/src/Repositories/OrderRepository.php index aed17581d..c5fca17c1 100755 --- a/packages/Webkul/Sales/src/Repositories/OrderRepository.php +++ b/packages/Webkul/Sales/src/Repositories/OrderRepository.php @@ -44,8 +44,7 @@ class OrderRepository extends Repository OrderItemRepository $orderItemRepository, DownloadableLinkPurchasedRepository $downloadableLinkPurchasedRepository, App $app - ) - { + ) { $this->orderItemRepository = $orderItemRepository; $this->downloadableLinkPurchasedRepository = $downloadableLinkPurchasedRepository; @@ -97,8 +96,9 @@ class OrderRepository extends Repository $order->payment()->create($data['payment']); - if (isset($data['shipping_address'])) + if (isset($data['shipping_address'])) { $order->addresses()->create($data['shipping_address']); + } $order->addresses()->create($data['billing_address']); @@ -141,14 +141,16 @@ class OrderRepository extends Repository { $order = $this->findOrFail($orderId); - if (! $order->canCancel()) + if (! $order->canCancel()) { return false; + } Event::fire('sales.order.cancel.before', $order); foreach ($order->items as $item) { - if (! $item->qty_to_cancel) + if (! $item->qty_to_cancel) { continue; + } $orderItems = []; @@ -161,8 +163,9 @@ class OrderRepository extends Repository } foreach ($orderItems as $orderItem) { - if ($orderItem->product) + if ($orderItem->product) { $this->orderItemRepository->returnQtyToProductInventory($orderItem); + } if ($orderItem->qty_ordered) { $orderItem->qty_canceled += $orderItem->qty_to_cancel; @@ -191,7 +194,7 @@ class OrderRepository extends Repository /** * @return integer */ - public function generateIncrementId(): int + public function generateIncrementId() { $config = new CoreConfig(); @@ -243,8 +246,9 @@ class OrderRepository extends Repository if ($totalQtyOrdered != ($totalQtyRefunded + $totalQtyCanceled) && $totalQtyOrdered == $totalQtyInvoiced + $totalQtyCanceled - && $totalQtyOrdered == $totalQtyShipped + $totalQtyRefunded + $totalQtyCanceled) + && $totalQtyOrdered == $totalQtyShipped + $totalQtyRefunded + $totalQtyCanceled) { return true; + } return false; } @@ -293,13 +297,15 @@ class OrderRepository extends Repository { $status = 'processing'; - if ($this->isInCompletedState($order)) + if ($this->isInCompletedState($order)) { $status = 'completed'; + } - if ($this->isInCanceledState($order)) + if ($this->isInCanceledState($order)) { $status = 'canceled'; - else if ($this->isInClosedState($order)) + } elseif ($this->isInClosedState($order)) { $status = 'closed'; + } $order->status = $status; $order->save(); @@ -366,4 +372,4 @@ class OrderRepository extends Repository return $order; } -} \ No newline at end of file +} From 59d2a77d7d565f9af7a60b640aee370295f426fb Mon Sep 17 00:00:00 2001 From: Herbert Date: Fri, 22 Nov 2019 09:46:38 +0100 Subject: [PATCH 11/37] two more view_render_events in sales order tabs --- .../Admin/src/Resources/views/sales/orders/view.blade.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php index 534bc1bef..c635af49e 100755 --- a/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/sales/orders/view.blade.php @@ -48,6 +48,8 @@
+ {!! view_render_event('sales.order.tabs.before', ['order' => $order]) !!} +
@@ -506,8 +508,10 @@
+ + {!! view_render_event('sales.order.tabs.after', ['order' => $order]) !!}
-@stop \ No newline at end of file +@stop From 11e471e6157b5c74e7a78fece3ceea63b77ba8b1 Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Fri, 22 Nov 2019 11:57:07 +0100 Subject: [PATCH 12/37] changed code indents --- .../Product/src/Helpers/ProductType.php | 7 ++- .../Webkul/Product/src/Type/AbstractType.php | 51 +++++++------------ 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/packages/Webkul/Product/src/Helpers/ProductType.php b/packages/Webkul/Product/src/Helpers/ProductType.php index 9dcf87c32..103b1ed58 100644 --- a/packages/Webkul/Product/src/Helpers/ProductType.php +++ b/packages/Webkul/Product/src/Helpers/ProductType.php @@ -17,6 +17,7 @@ class ProductType extends AbstractProduct { /** @var AbstractType $type */ $type = app(config('product_types.' . $typeKey . '.class')); + return $type->hasVariants(); } @@ -27,10 +28,8 @@ class ProductType extends AbstractProduct */ public static function getAllTypesHavingVariants(): array { - foreach (config('product_types') as $type) - { - if (self::hasVariants($type['key'])) - { + foreach (config('product_types') as $type) { + if (self::hasVariants($type['key'])) { array_push($havingVariants, $type['key']); } } diff --git a/packages/Webkul/Product/src/Type/AbstractType.php b/packages/Webkul/Product/src/Type/AbstractType.php index 44e6a76a5..39568653d 100644 --- a/packages/Webkul/Product/src/Type/AbstractType.php +++ b/packages/Webkul/Product/src/Type/AbstractType.php @@ -167,23 +167,19 @@ abstract class AbstractType $product->update($data); foreach ($product->attribute_family->custom_attributes as $attribute) { - if ($attribute->type == 'boolean') - { + if ($attribute->type == 'boolean') { $data[$attribute->code] = isset($data[$attribute->code]) && $data[$attribute->code] ? 1 : 0; } - if (! isset($data[$attribute->code])) - { + if (! isset($data[$attribute->code])) { continue; } - if ($attribute->type == 'date' && $data[$attribute->code] == '') - { + if ($attribute->type == 'date' && $data[$attribute->code] == '') { $data[$attribute->code] = null; } - if ($attribute->type == 'multiselect' || $attribute->type == 'checkbox') - { + if ($attribute->type == 'multiselect' || $attribute->type == 'checkbox') { $data[$attribute->code] = implode(",", $data[$attribute->code]); } @@ -214,8 +210,7 @@ abstract class AbstractType ], $attributeValue->id ); - if ($attribute->type == 'image' || $attribute->type == 'file') - { + if ($attribute->type == 'image' || $attribute->type == 'file') { Storage::delete($attributeValue->text_value); } } @@ -224,8 +219,7 @@ abstract class AbstractType $route = request()->route() ? request()->route()->getName() : ""; if ($route != 'admin.catalog.products.massupdate') { - if (isset($data['categories'])) - { + if (isset($data['categories'])) { $product->categories()->sync($data['categories']); } @@ -263,8 +257,7 @@ abstract class AbstractType */ public function isSaleable() { - if (! $this->product->status) - { + if (! $this->product->status) { return false; } @@ -342,8 +335,7 @@ abstract class AbstractType ->pluck('id'); foreach ($this->product->inventories as $inventory) { - if (is_numeric($index = $channelInventorySourceIds->search($inventory->inventory_source_id))) - { + if (is_numeric($index = $channelInventorySourceIds->search($inventory->inventory_source_id))) { $total += $inventory->qty; } } @@ -352,8 +344,7 @@ abstract class AbstractType ->where('channel_id', core()->getCurrentChannel()->id) ->first(); - if ($orderedInventory) - { + if ($orderedInventory) { $total -= $orderedInventory->qty; } @@ -379,13 +370,11 @@ abstract class AbstractType */ public function getEditableAttributes($group = null, $skipSuperAttribute = true) { - if ($skipSuperAttribute) - { + if ($skipSuperAttribute) { $this->skipAttributes = array_merge($this->product->super_attributes->pluck('code')->toArray(), $this->skipAttributes); } - if (! $group) - { + if (! $group) { return $this->product->attribute_family->custom_attributes()->whereNotIn('attributes.code', $this->skipAttributes)->get(); } @@ -419,8 +408,7 @@ abstract class AbstractType */ public function getMinimalPrice() { - if ($this->haveSpecialPrice()) - { + if ($this->haveSpecialPrice()) { return $this->product->special_price; } @@ -462,13 +450,11 @@ abstract class AbstractType */ public function haveSpecialPrice() { - if (is_null($this->product->special_price) || ! (float) $this->product->special_price) - { + if (is_null($this->product->special_price) || ! (float) $this->product->special_price) { return false; } - if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to)) - { + if (core()->isChannelDateInInterval($this->product->special_price_from, $this->product->special_price_to)) { return true; } @@ -524,8 +510,7 @@ abstract class AbstractType $data = $this->getQtyRequest($data); - if (! $this->haveSufficientQuantity($data['quantity'])) - { + if (! $this->haveSufficientQuantity($data['quantity'])) { return trans('shop::app.checkout.cart.quantity.inventory_warning'); } @@ -561,8 +546,7 @@ abstract class AbstractType */ public function getQtyRequest($data) { - if ($item = Cart::getItemByProduct(['additional' => $data])) - { + if ($item = Cart::getItemByProduct(['additional' => $data])) { $data['quantity'] += $item->quantity; } @@ -639,8 +623,7 @@ abstract class AbstractType { $price = $item->product->getTypeInstance()->getFinalPrice(); - if ($price == $item->base_price) - { + if ($price == $item->base_price) { return; } From e416aef6188eb56e2e009ed2a34d1447588e1b8a Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Sat, 23 Nov 2019 23:05:38 +0100 Subject: [PATCH 13/37] add codeception and example tests --- .env.testing | 45 +++++++ codeception.yml | 10 ++ composer.json | 9 +- tests/Browser/ExampleTest.php | 32 ----- tests/Browser/Pages/HomePage.php | 41 ------ tests/Browser/Pages/Page.php | 20 --- tests/Browser/ProductCategoryTest.php | 49 ------- tests/Browser/console/.gitignore | 2 - tests/Browser/screenshots/.gitignore | 2 - tests/CreatesApplication.php | 22 ---- tests/DuskTestCase.php | 48 ------- tests/Feature/Auth/AuthTest.php | 124 ------------------ tests/Feature/GeneralTest.php | 88 ------------- tests/TestCase.php | 10 -- tests/Unit/ExampleTest.php | 19 --- tests/_data/.gitkeep | 0 tests/_output/.gitignore | 2 + tests/_support/AcceptanceTester.php | 26 ++++ tests/_support/FunctionalTester.php | 52 ++++++++ tests/_support/Helper/Acceptance.php | 10 ++ tests/_support/Helper/Functional.php | 10 ++ tests/_support/Helper/Unit.php | 10 ++ tests/_support/UnitTester.php | 26 ++++ tests/_support/_generated/.gitignore | 2 + tests/acceptance.suite.yml | 13 ++ tests/functional.suite.yml | 20 +++ .../functional/Shop/ProductControllerCest.php | 70 ++++++++++ tests/unit.suite.yml | 17 +++ .../unit/Product/Helpers/ProductTypeCest.php | 15 +++ 29 files changed, 336 insertions(+), 458 deletions(-) create mode 100644 .env.testing create mode 100644 codeception.yml delete mode 100644 tests/Browser/ExampleTest.php delete mode 100644 tests/Browser/Pages/HomePage.php delete mode 100644 tests/Browser/Pages/Page.php delete mode 100644 tests/Browser/ProductCategoryTest.php delete mode 100644 tests/Browser/console/.gitignore delete mode 100644 tests/Browser/screenshots/.gitignore delete mode 100755 tests/CreatesApplication.php delete mode 100644 tests/DuskTestCase.php delete mode 100644 tests/Feature/Auth/AuthTest.php delete mode 100644 tests/Feature/GeneralTest.php delete mode 100755 tests/TestCase.php delete mode 100755 tests/Unit/ExampleTest.php create mode 100644 tests/_data/.gitkeep create mode 100644 tests/_output/.gitignore create mode 100644 tests/_support/AcceptanceTester.php create mode 100644 tests/_support/FunctionalTester.php create mode 100644 tests/_support/Helper/Acceptance.php create mode 100644 tests/_support/Helper/Functional.php create mode 100644 tests/_support/Helper/Unit.php create mode 100644 tests/_support/UnitTester.php create mode 100644 tests/_support/_generated/.gitignore create mode 100644 tests/acceptance.suite.yml create mode 100644 tests/functional.suite.yml create mode 100644 tests/functional/Shop/ProductControllerCest.php create mode 100644 tests/unit.suite.yml create mode 100644 tests/unit/Product/Helpers/ProductTypeCest.php diff --git a/.env.testing b/.env.testing new file mode 100644 index 000000000..6b1104008 --- /dev/null +++ b/.env.testing @@ -0,0 +1,45 @@ +APP_NAME=Bagisto +APP_ENV=local +APP_VERSION=0.1.8 +APP_KEY=base64:NFtGjjFAqET6RlX3PVC/gFpzHb4jK1OxDc3cuU5Asz4= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack + +DB_CONNECTION=mysql +DB_HOST=mysql +DB_PORT=3306 +DB_DATABASE=bagisto_test +DB_USERNAME=root +DB_PASSWORD=root + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +SESSION_DRIVER=file +SESSION_LIFETIME=20 +QUEUE_DRIVER=sync + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_DRIVER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME= +MAIL_PASSWORD= +MAIL_ENCRYPTION=tls + +SHOP_MAIL_FROM= +ADMIN_MAIL_TO= + +fixer_api_key= + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 000000000..f0446cc8a --- /dev/null +++ b/codeception.yml @@ -0,0 +1,10 @@ +paths: + tests: tests + output: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +actor_suffix: Tester +extensions: + enabled: + - Codeception\Extension\RunFailed diff --git a/composer.json b/composer.json index 03d5e3e62..7df20f637 100755 --- a/composer.json +++ b/composer.json @@ -35,6 +35,7 @@ "tymon/jwt-auth": "1.0.0-rc.4" }, "require-dev": { + "codeception/codeception": "3.1.*", "barryvdh/laravel-debugbar": "^3.1", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", @@ -116,6 +117,11 @@ "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover" + ], + "test": [ + "set -e", + "vendor/bin/codecept run unit", + "vendor/bin/codecept run functional" ] }, "config": { @@ -123,5 +129,6 @@ "sort-packages": true, "optimize-autoloader": true }, - "minimum-stability": "dev" + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php deleted file mode 100644 index 8aa739cfe..000000000 --- a/tests/Browser/ExampleTest.php +++ /dev/null @@ -1,32 +0,0 @@ -all(); - - $customer = $customer->first(); - - $this->browse(function (Browser $browser) use($customer) { - $browser->visit('/customer/login') - ->type('email', $customer->email) - ->type('password', $customer->password) - ->click('input[type="submit"]') - ->screenshot('error'); - }); - } -} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php deleted file mode 100644 index 4f5a87f4c..000000000 --- a/tests/Browser/Pages/HomePage.php +++ /dev/null @@ -1,41 +0,0 @@ - '#selector', - ]; - } -} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php deleted file mode 100644 index f8d76222c..000000000 --- a/tests/Browser/Pages/Page.php +++ /dev/null @@ -1,20 +0,0 @@ - '#selector', - ]; - } -} diff --git a/tests/Browser/ProductCategoryTest.php b/tests/Browser/ProductCategoryTest.php deleted file mode 100644 index 4c8b2658b..000000000 --- a/tests/Browser/ProductCategoryTest.php +++ /dev/null @@ -1,49 +0,0 @@ -all(); - $products = app('Webkul\Product\Repositories\ProductRepository')->all(); - - $slugs = array(); - - foreach ($categories as $category) { - if ($category->slug != 'root') { - array_push($slugs, $category->slug); - } - } - - $slugIndex = array_rand($slugs); - $testSlug = $slugs[$slugIndex]; - $testProduct = array(); - - foreach ($products as $product) { - $categories = $product->categories; - - if ($categories->last()->slug == $testSlug) { - array_push($testProduct, ['name' => $product->name, 'url_key' => $product->url_key]); - - break; - } - } - - $this->browse(function (Browser $browser) use($testSlug, $testProduct) { - $browser->visit(route('shop.categories.index', $testSlug)); - $browser->assertSeeLink($testProduct[0]['name']); - $browser->pause(5000); - }); - } -} \ No newline at end of file diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/tests/Browser/console/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/tests/Browser/screenshots/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php deleted file mode 100755 index 8d8a77e99..000000000 --- a/tests/CreatesApplication.php +++ /dev/null @@ -1,22 +0,0 @@ -make(Kernel::class)->bootstrap(); - - return $app; - } -} \ No newline at end of file diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php deleted file mode 100644 index 321941f5d..000000000 --- a/tests/DuskTestCase.php +++ /dev/null @@ -1,48 +0,0 @@ -addArguments([ - '--disable-gpu', - '--headless', - '--no-sandbox' - ]); - - return RemoteWebDriver::create( - 'http://localhost:9515/', DesiredCapabilities::chrome() - ); - - // return RemoteWebDriver::create( - // 'http://localhost:9515', DesiredCapabilities::chrome()->setCapability( - // ChromeOptions::CAPABILITY, $options - // ) - // ); - } -} diff --git a/tests/Feature/Auth/AuthTest.php b/tests/Feature/Auth/AuthTest.php deleted file mode 100644 index cacb2e6e7..000000000 --- a/tests/Feature/Auth/AuthTest.php +++ /dev/null @@ -1,124 +0,0 @@ - 'http://prashant.com']); - - $response = $this->get('/customer/login'); - - $response->assertSuccessful(); - - $response->assertViewIs('shop::customers.session.index'); - } - - public function testCustomerResgistrationPage() - { - config(['app.url' => 'http://prashant.com']); - - $response = $this->get('/customer/register'); - - $response->assertSuccessful(); - - $response->assertViewIs('shop::customers.signup.index'); - } - - public function testCustomerRegistration() { - $faker = \Faker\Factory::create(); - - $allCustomers = array(); - - $customers = app(Customer::class); - - $created = $customers->create([ - 'first_name' => explode(' ', $faker->name)[0], - 'last_name' => explode(' ', $faker->name)[0], - 'channel_id' => core()->getCurrentChannel()->id, - 'gender' => $faker->randomElement($array = array ('Male','Female', 'Other')), - 'date_of_birth' => $faker->date($format = 'Y-m-d', $max = 'now'), - 'email' => $faker->email, - 'password' => bcrypt('12345678'), - 'is_verified' => 1 - ]); - - $this->assertEquals($created->id, $created->id); - } - - public function testCustomerLogin() - { - config(['app.url' => 'http://prashant.com']); - - $customers = app(Customer::class); - $customer = $customers->findOneByField('email', 'john@doe.net'); - - $response = $this->post('/customer/login', [ - 'email' => $customer->email, - 'password' => '12345678' - ]); - - $response->assertRedirect('/customer/account/profile'); - } - - /** - * Test that customer cannot login with the wrong credentials. - */ - public function willNotLoginWithWrongCredentials() - { - $customers = app(Customer::class); - $customer = $customers->findOneByField('email', 'john@doe.net'); - - $response = $this->from(route('login'))->post(route('customer.session.create'), - [ - 'email' => $customer->email, - 'password' => 'wrongpassword3428903mlndvsnljkvsd', - ]); - - $this->assertGuest(); - } - - /** - * Test to confirm that customer cannot login if user does not exist. - */ - public function willNotLoginWithNonexistingCustomer() - { - $response = $this->post(route('customer.session.create'), [ - 'email' => 'fiaiia9q2943jklq34h203qtb3o2@something.com', - 'password' => 'wrong-password', - ]); - - $this->assertGuest(); - } - - /** - * To test that customer can logout - */ - public function allowsCustomerToLogout() - { - $customer = auth()->guard('customer')->user(); - - $this->get(route('customer.session.destroy')); - - $this->assertGuest(); - } -} diff --git a/tests/Feature/GeneralTest.php b/tests/Feature/GeneralTest.php deleted file mode 100644 index 55cbc0bde..000000000 --- a/tests/Feature/GeneralTest.php +++ /dev/null @@ -1,88 +0,0 @@ - 'http://prashant.com']); - - $response = $this->get('/'); - - $response->assertStatus(200); - } - - /** - * Test for customer login - * - * @return void - */ - public function testCustomerLoginPage() - { - config(['app.url' => 'http://prashant.com']); - - $response = $this->get('/customer/login'); - - $response->assertStatus(200); - } - - /** - * Test for categories page - * - * @return void - */ - public function testCategoriesPage() - { - $categoryUrlSlug = 'marvel-figurines'; - - config(['app.url' => 'http://prashant.com']); - - $response = $this->get("/categories/{$categoryUrlSlug}"); - - $response->assertStatus(200); - } - - /** - * Test for customer registration page - * - * @return void - */ - public function testCustomerRegistrationPage() - { - // config(['app.url' => 'http://127.0.0.1:8000']); - - $response = $this->get("/customer/register"); - - $response->assertStatus(200); - } - - /** - * Test for checkout's cart page - * - * @return void - */ - public function testCartPage() - { - // config(['app.url' => 'http://127.0.0.1:8000']); - - $response = $this->get("/checkout/cart"); - - $response->assertStatus(200); - } -} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php deleted file mode 100755 index 2932d4a69..000000000 --- a/tests/TestCase.php +++ /dev/null @@ -1,10 +0,0 @@ -assertTrue(true); - } -} \ No newline at end of file diff --git a/tests/_data/.gitkeep b/tests/_data/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/tests/_output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php new file mode 100644 index 000000000..95c00ec21 --- /dev/null +++ b/tests/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +login($I->grabRecord(Admin::class, ['email' => 'admin@example.com'])); + $I->seeAuthentication('admin'); + } + + public function amOnAdminRoute(string $name, array $params = null): void + { + $I = $this; + $I->amOnRoute($name, $params); + $I->seeCurrentRouteIs($name); + + /** @var RouteCollection $routes */ + $routes = Route::getRoutes(); + $middlewares = $routes->getByName($name)->middleware(); + $I->assertContains('admin', $middlewares, 'check that admin middleware is applied'); + } + +} diff --git a/tests/_support/Helper/Acceptance.php b/tests/_support/Helper/Acceptance.php new file mode 100644 index 000000000..65b94215e --- /dev/null +++ b/tests/_support/Helper/Acceptance.php @@ -0,0 +1,10 @@ +faker = Factory::create(); + } + + public function testCreate(FunctionalTester $I) + { + $I->loginAsAdmin(); + $I->amOnAdminRoute('admin.catalog.products.index'); + $I->click(__('admin::app.catalog.products.add-product-btn-title'), '//*[contains(@class, "page-action")]'); + $I->seeCurrentRouteIs('admin.catalog.products.create'); + + $I->click(__('admin::app.catalog.products.save-btn-title'), '//*[contains(@class, "page-action")]'); + $I->seeFormHasErrors(); + + $testSku = $this->faker->uuid; + $I->selectOption('//select[@id="attribute_family_id"]', 'Default'); + $I->fillField('//input[@id="sku"]', $testSku); + $I->click(__('admin::app.catalog.products.save-btn-title'), '//*[contains(@class, "page-action")]'); + $I->dontSeeFormErrors(); + $I->seeCurrentRouteIs('admin.catalog.products.edit'); + $I->seeRecord(Product::class, ['sku' => $testSku]); + + $I->click(__('admin::app.catalog.products.save-btn-title'), '//*[contains(@class, "page-action")]'); + $I->seeFormHasErrors(); + + $testName = $this->faker->name; + $testUrlKey = $testName; + $testDescription = $this->faker->sentence; + $testDescriptionShop = $this->faker->sentence; + $testPrice = $this->faker->randomFloat(2, 1, 100); + $testWeight = $this->faker->numberBetween(1, 20); + $I->fillField('//input[@id="name"]', $testName); + $I->fillField('//input[@id="url_key"]', $testUrlKey); + $I->fillField('//textarea[@id="description"]', $testDescription); + $I->fillField('//textarea[@id="short_description"]', $testDescriptionShop); + $I->fillField('//input[@id="price"]', $testPrice); + $I->fillField('//input[@id="weight"]', $testWeight); + $I->click(__('admin::app.catalog.products.save-btn-title'), '//*[contains(@class, "page-action")]'); + $I->dontSeeFormErrors(); + $I->seeCurrentRouteIs('admin.catalog.products.index'); + $product = $I->grabRecord(Product::class, ['sku' => $testSku]); + $I->seeRecord(ProductFlat::class, [ + 'sku' => $testSku, + 'name' => $testName, + 'description' => $testDescription, + 'short_description' => $testDescriptionShop, + 'url_key' => $testUrlKey, + 'price' => $testPrice, + 'weight' => $testWeight, + 'product_id' => $product->id, + ]); + } +} diff --git a/tests/unit.suite.yml b/tests/unit.suite.yml new file mode 100644 index 000000000..3bc78d9b8 --- /dev/null +++ b/tests/unit.suite.yml @@ -0,0 +1,17 @@ +# Codeception Test Suite Configuration +# +# Suite for unit or integration tests. + +actor: UnitTester +modules: + enabled: + - Asserts + - Filesystem + - \Helper\Unit + - Laravel5: + environment_file: .env.testing + run_database_migrations: true + run_database_seeder: true + database_seeder_class: DatabaseSeeder + + step_decorators: ~ \ No newline at end of file diff --git a/tests/unit/Product/Helpers/ProductTypeCest.php b/tests/unit/Product/Helpers/ProductTypeCest.php new file mode 100644 index 000000000..da3ba9abb --- /dev/null +++ b/tests/unit/Product/Helpers/ProductTypeCest.php @@ -0,0 +1,15 @@ +assertTrue(ProductType::hasVariants('configurable')); + $I->assertFalse(ProductType::hasVariants('simple')); + } +} From b5257c0e66ef5d9cef82141a548b9829efaf7db6 Mon Sep 17 00:00:00 2001 From: Florian Bosdorff Date: Sat, 23 Nov 2019 23:09:39 +0100 Subject: [PATCH 14/37] add phpdoc for FunctionalTester --- tests/_support/FunctionalTester.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/_support/FunctionalTester.php b/tests/_support/FunctionalTester.php index be8aa3392..ea07902b1 100644 --- a/tests/_support/FunctionalTester.php +++ b/tests/_support/FunctionalTester.php @@ -29,6 +29,9 @@ class FunctionalTester extends \Codeception\Actor * Define custom actions here */ + /** + * Login as default administrator + */ public function loginAsAdmin(): void { $I = $this; @@ -37,6 +40,12 @@ class FunctionalTester extends \Codeception\Actor $I->seeAuthentication('admin'); } + /** + * Go to a specific route and check if admin guard is applied on it + * + * @param string $name name of the route + * @param array|null $params params the route will be created with + */ public function amOnAdminRoute(string $name, array $params = null): void { $I = $this; From ebcc66ab59ec4d3c26e6adf73abc36eb8dcd943a Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Mon, 25 Nov 2019 08:02:55 +0100 Subject: [PATCH 15/37] remove alkhachatryan/laravel-web-console --- composer.json | 1 - config/laravelwebconsole.php | 51 ------------------- .../Development/WebConsoleController.php | 24 --------- packages/Webkul/Admin/src/Http/routes.php | 5 +- 4 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 config/laravelwebconsole.php delete mode 100755 packages/Webkul/Admin/src/Http/Controllers/Development/WebConsoleController.php diff --git a/composer.json b/composer.json index 03d5e3e62..9a2f62ce5 100755 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "ext-pdo_mysql": "*", "ext-tokenizer": "*", "astrotomic/laravel-translatable": "^11.0.0", - "alkhachatryan/laravel-web-console": "1.5.1", "barryvdh/laravel-dompdf": "0.8.3", "doctrine/dbal": "2.9.2", "fideloper/proxy": "^4.0", diff --git a/config/laravelwebconsole.php b/config/laravelwebconsole.php deleted file mode 100644 index 1e3be3bce..000000000 --- a/config/laravelwebconsole.php +++ /dev/null @@ -1,51 +0,0 @@ - false, - - // Single-user credentials (REQUIRED) - 'user' => [ - 'name' => env('CONSOLE_USER_NAME', 'root'), - 'password' => env('CONSOLE_USER_PASSWORD', 'root'), - ], - - // Multi-user credentials (OPTIONAL) - // Example: 'user' => 'password', 'user1' => 'password1' - 'accounts' => [ - // 'user' => 'password', - ], - - // Hash incoming password - // By default it's sha256 - 'password_hash_algorithm' => '', - - // Home directory (multi-user mode supported) - // Example: 'home_dir' => '/tmp'; - // 'home_dir' => array('user1' => '/home/user1', 'user2' => '/home/user2'); - 'home_dir' => '', -]; diff --git a/packages/Webkul/Admin/src/Http/Controllers/Development/WebConsoleController.php b/packages/Webkul/Admin/src/Http/Controllers/Development/WebConsoleController.php deleted file mode 100755 index 649f3c730..000000000 --- a/packages/Webkul/Admin/src/Http/Controllers/Development/WebConsoleController.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) - */ -class WebConsoleController extends Controller -{ - /** - * Show the Web Console. - * - * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory - */ - public function index(){ - return LaravelWebConsole::show(); - } -} \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Http/routes.php b/packages/Webkul/Admin/src/Http/routes.php index 22bd07448..50c6557bd 100755 --- a/packages/Webkul/Admin/src/Http/routes.php +++ b/packages/Webkul/Admin/src/Http/routes.php @@ -765,10 +765,7 @@ Route::group(['middleware' => ['web']], function () { Route::prefix('development')->group(function () { Route::get('/', 'Webkul\Admin\Http\Controllers\Development\DashboardController@index') ->name('admin.development.index'); - - Route::get('webconsole', 'Webkul\Admin\Http\Controllers\Development\WebConsoleController@index') - ->name('admin.development.webconsole'); }); }); }); -}); \ No newline at end of file +}); From c22e8f7c9cc2e86559adc07f052a8dedeb7aeafb Mon Sep 17 00:00:00 2001 From: "shubhammehrotra.symfony@webkul.com" Date: Mon, 25 Nov 2019 14:59:51 +0530 Subject: [PATCH 16/37] Bagisto content added using post create-project event --- composer.json | 164 ++++++++++-------- .../Webkul/Core/src/Events/ComposerEvents.php | 15 ++ .../Webkul/Core/src/Templates/on-boarding.php | 14 ++ 3 files changed, 116 insertions(+), 77 deletions(-) create mode 100644 packages/Webkul/Core/src/Events/ComposerEvents.php create mode 100644 packages/Webkul/Core/src/Templates/on-boarding.php diff --git a/composer.json b/composer.json index 03d5e3e62..381676d04 100755 --- a/composer.json +++ b/composer.json @@ -2,9 +2,10 @@ "name": "bagisto/bagisto", "description": "Bagisto Laravel ECommerce", "keywords": [ - "framework", - "laravel" + "framework", + "laravel" ], + "license": "MIT", "type": "project", "require": { @@ -34,94 +35,103 @@ "prettus/l5-repository": "2.6.32", "tymon/jwt-auth": "1.0.0-rc.4" }, + "require-dev": { - "barryvdh/laravel-debugbar": "^3.1", - "filp/whoops": "^2.0", - "fzaninotto/faker": "^1.4", - "laravel/dusk": "^4.0", - "mockery/mockery": "^1.0", - "nunomaduro/collision": "^2.0", - "phpunit/phpunit": "^7.0" + "barryvdh/laravel-debugbar": "^3.1", + "filp/whoops": "^2.0", + "fzaninotto/faker": "^1.4", + "laravel/dusk": "^4.0", + "mockery/mockery": "^1.0", + "nunomaduro/collision": "^2.0", + "phpunit/phpunit": "^7.0" }, + "replace": { - "bagisto/laravel-user": "v0.1.0", - "bagisto/laravel-admin": "v0.1.0", - "bagisto/laravel-ui": "v0.1.0", - "bagisto/laravel-core": "v0.1.0", - "bagisto/laravel-attribute": "v0.1.0", - "bagisto/laravel-checkout": "v0.1.0", - "bagisto/laravel-customer": "v0.1.0", - "bagisto/laravel-inventory": "v0.1.0", - "bagisto/laravel-category": "v0.1.0", - "bagisto/laravel-product": "v0.1.0", - "bagisto/laravel-shop": "v0.1.0", - "bagisto/laravel-theme": "v0.1.0", - "bagisto/laravel-shipping": "v0.1.0", - "bagisto/laravel-payment": "v0.1.0", - "bagisto/laravel-sales": "v0.1.0", - "bagisto/laravel-tax": "v0.1.0", - "bagisto/laravel-api": "v0.1.0", - "bagisto/laravel-paypal": "v0.1.0", - "bagisto/laravel-discount": "v0.1.0" + "bagisto/laravel-user": "v0.1.0", + "bagisto/laravel-admin": "v0.1.0", + "bagisto/laravel-ui": "v0.1.0", + "bagisto/laravel-core": "v0.1.0", + "bagisto/laravel-attribute": "v0.1.0", + "bagisto/laravel-checkout": "v0.1.0", + "bagisto/laravel-customer": "v0.1.0", + "bagisto/laravel-inventory": "v0.1.0", + "bagisto/laravel-category": "v0.1.0", + "bagisto/laravel-product": "v0.1.0", + "bagisto/laravel-shop": "v0.1.0", + "bagisto/laravel-theme": "v0.1.0", + "bagisto/laravel-shipping": "v0.1.0", + "bagisto/laravel-payment": "v0.1.0", + "bagisto/laravel-sales": "v0.1.0", + "bagisto/laravel-tax": "v0.1.0", + "bagisto/laravel-api": "v0.1.0", + "bagisto/laravel-paypal": "v0.1.0", + "bagisto/laravel-discount": "v0.1.0" }, + "autoload": { - "classmap": [ - "database/seeds", - "database/factories" - ], - "psr-4": { - "App\\": "app/", - "Webkul\\User\\": "packages/Webkul/User/src", - "Webkul\\Admin\\": "packages/Webkul/Admin/src", - "Webkul\\Ui\\": "packages/Webkul/Ui/src", - "Webkul\\Category\\": "packages/Webkul/Category/src", - "Webkul\\Checkout\\": "packages/Webkul/Checkout/src", - "Webkul\\Attribute\\": "packages/Webkul/Attribute/src", - "Webkul\\Shop\\": "packages/Webkul/Shop/src", - "Webkul\\Core\\": "packages/Webkul/Core/src", - "Webkul\\Customer\\": "packages/Webkul/Customer/src", - "Webkul\\Inventory\\": "packages/Webkul/Inventory/src", - "Webkul\\Product\\": "packages/Webkul/Product/src", - "Webkul\\Theme\\": "packages/Webkul/Theme/src", - "Webkul\\Shipping\\": "packages/Webkul/Shipping/src", - "Webkul\\Payment\\": "packages/Webkul/Payment/src", - "Webkul\\Paypal\\": "packages/Webkul/Paypal/src", - "Webkul\\Sales\\": "packages/Webkul/Sales/src", - "Webkul\\Tax\\": "packages/Webkul/Tax/src", - "Webkul\\API\\": "packages/Webkul/API", - "Webkul\\Discount\\": "packages/Webkul/Discount/src", - "Webkul\\CMS\\": "packages/Webkul/CMS/src" - } + "classmap": [ + "database/seeds", + "database/factories" + ], + "psr-4": { + "App\\": "app/", + "Webkul\\User\\": "packages/Webkul/User/src", + "Webkul\\Admin\\": "packages/Webkul/Admin/src", + "Webkul\\Ui\\": "packages/Webkul/Ui/src", + "Webkul\\Category\\": "packages/Webkul/Category/src", + "Webkul\\Checkout\\": "packages/Webkul/Checkout/src", + "Webkul\\Attribute\\": "packages/Webkul/Attribute/src", + "Webkul\\Shop\\": "packages/Webkul/Shop/src", + "Webkul\\Core\\": "packages/Webkul/Core/src", + "Webkul\\Customer\\": "packages/Webkul/Customer/src", + "Webkul\\Inventory\\": "packages/Webkul/Inventory/src", + "Webkul\\Product\\": "packages/Webkul/Product/src", + "Webkul\\Theme\\": "packages/Webkul/Theme/src", + "Webkul\\Shipping\\": "packages/Webkul/Shipping/src", + "Webkul\\Payment\\": "packages/Webkul/Payment/src", + "Webkul\\Paypal\\": "packages/Webkul/Paypal/src", + "Webkul\\Sales\\": "packages/Webkul/Sales/src", + "Webkul\\Tax\\": "packages/Webkul/Tax/src", + "Webkul\\API\\": "packages/Webkul/API", + "Webkul\\Discount\\": "packages/Webkul/Discount/src", + "Webkul\\CMS\\": "packages/Webkul/CMS/src" + } }, + "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } + "psr-4": { + "Tests\\": "tests/" + } }, + "extra": { - "laravel": { - "dont-discover": [ - "barryvdh/laravel-debugbar", - "laravel/dusk" - ] - } + "laravel": { + "dont-discover": [ + "barryvdh/laravel-debugbar", + "laravel/dusk" + ] + } }, + "scripts": { - "post-root-package-install": [ - "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" - ], - "post-create-project-cmd": [ - "@php artisan key:generate" - ], - "post-autoload-dump": [ - "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", - "@php artisan package:discover" - ] + "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" + ] }, "config": { - "preferred-install": "stable", - "sort-packages": true, - "optimize-autoloader": true + "preferred-install": "stable", + "sort-packages": true, + "optimize-autoloader": true }, "minimum-stability": "dev" } diff --git a/packages/Webkul/Core/src/Events/ComposerEvents.php b/packages/Webkul/Core/src/Events/ComposerEvents.php new file mode 100644 index 000000000..0ee700715 --- /dev/null +++ b/packages/Webkul/Core/src/Events/ComposerEvents.php @@ -0,0 +1,15 @@ +writeln(file_get_contents(__DIR__ . '/../Templates/on-boarding.php')); + } +} \ No newline at end of file diff --git a/packages/Webkul/Core/src/Templates/on-boarding.php b/packages/Webkul/Core/src/Templates/on-boarding.php new file mode 100644 index 000000000..e5311fbd6 --- /dev/null +++ b/packages/Webkul/Core/src/Templates/on-boarding.php @@ -0,0 +1,14 @@ + + ____ _ _ +| __ ) __ _ __ _(_)___| |_ ___ +| _ \ / _` |/ _` | / __| __/ _ \ +| |_) | (_| | (_| | \__ \ || (_) | +|____/ \__,_|\__, |_|___/\__\___/ + |___/ + + + +Welcome to the Bagisto project! Bagisto Community is an open-source e-commerce ecosystem +which is built on top of top of Laravel and Vue.js. + +Made with 💖 by the Bagisto Team. Happy helping :) From 79d9a1d9b38e1c67249bf5ac78effac45bc42f52 Mon Sep 17 00:00:00 2001 From: rahul shukla Date: Tue, 26 Nov 2019 16:06:22 +0530 Subject: [PATCH 17/37] dtabase prefix added in raw query --- .../Webkul/Admin/src/DataGrids/AddressDataGrid.php | 10 +++++----- .../Webkul/Admin/src/DataGrids/CategoryDataGrid.php | 2 +- .../Webkul/Admin/src/DataGrids/CustomerDataGrid.php | 4 ++-- packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php | 8 ++++---- .../Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php | 4 ++-- .../Admin/src/DataGrids/OrderShipmentsDataGrid.php | 4 ++-- .../Webkul/Admin/src/DataGrids/ProductDataGrid.php | 4 ++-- .../Admin/src/Http/Controllers/DashboardController.php | 2 +- .../Shop/src/DataGrids/DownloadableProductDataGrid.php | 4 ++-- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php index 4c2de244c..0793b9fa3 100644 --- a/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/AddressDataGrid.php @@ -28,19 +28,19 @@ class AddressDataGrid extends DataGrid * @var object */ protected $customer; - + /** * Create a new controller instance. * * @param Webkul\Customer\Repositories\CustomerRepository $customer * @return void */ - public function __construct( + public function __construct( Customer $customer ) { parent::__construct(); - + $this->customer = $customer; } @@ -52,7 +52,7 @@ class AddressDataGrid extends DataGrid $queryBuilder = DB::table('customer_addresses as ca') ->leftJoin('countries', 'ca.country', '=', 'countries.code') ->leftJoin('customers as c', 'ca.customer_id', '=', 'c.id') - ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw('countries.name as country_name'), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') + ->addSelect('ca.id as address_id', 'ca.address1', 'ca.country', DB::raw(DB::getTablePrefix().('countries.name as country_name')), 'ca.state', 'ca.city', 'ca.postcode', 'ca.phone', 'ca.default_address') ->where('c.id', $customer->id); $queryBuilder = $queryBuilder->leftJoin('country_states', function($qb) { @@ -62,7 +62,7 @@ class AddressDataGrid extends DataGrid $queryBuilder ->groupBy('ca.id') - ->addSelect(DB::raw('country_states.default_name as state_name')); + ->addSelect(DB::raw(DB::getTablePrefix().('country_states.default_name as state_name'))); $this->addFilter('address_id', 'ca.id'); $this->addFilter('address1', 'ca.address1'); diff --git a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php index 7073e047c..44b174a7b 100755 --- a/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CategoryDataGrid.php @@ -21,7 +21,7 @@ class CategoryDataGrid extends DataGrid { $queryBuilder = DB::table('categories as cat') ->select('cat.id as category_id', 'ct.name', 'cat.position', 'cat.status', 'ct.locale', - DB::raw('COUNT(DISTINCT pc.product_id) as count')) + DB::raw('COUNT(DISTINCT ' . DB::getTablePrefix() . 'pc.product_id) as count')) ->leftJoin('category_translations as ct', function($leftJoin) { $leftJoin->on('cat.id', '=', 'ct.category_id') ->where('ct.locale', app()->getLocale()); diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php index 6952abca6..7345ea683 100755 --- a/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/CustomerDataGrid.php @@ -25,10 +25,10 @@ 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(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as full_name')); + ->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(customers.first_name, " ", customers.last_name)')); + $this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)')); $this->addFilter('phone', 'customers.phone'); $this->addFilter('gender', 'customers.gender'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index aa2d91b68..3e8255453 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -29,11 +29,11 @@ class OrderDataGrid extends DataGrid ->where('order_address_billing.address_type', 'billing'); }) ->addSelect('orders.id','orders.increment_id', 'orders.base_sub_total', 'orders.base_grand_total', 'orders.created_at', 'channel_name', 'status') - ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')) - ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')) + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); - $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); - $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('created_at', 'orders.created_at'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php index 2e4b09a37..787b1512e 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderRefundDataGrid.php @@ -26,9 +26,9 @@ class OrderRefundDataGrid extends DataGrid $leftJoin->on('order_address_billing.order_id', '=', 'orders.id') ->where('order_address_billing.address_type', 'billing'); }) - ->addSelect(DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name) as billed_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name) as billed_to')); - $this->addFilter('billed_to', DB::raw('CONCAT(order_address_billing.first_name, " ", order_address_billing.last_name)')); + $this->addFilter('billed_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_billing.first_name, " ", ' . DB::getTablePrefix() . 'order_address_billing.last_name)')); $this->addFilter('id', 'refunds.id'); $this->addFilter('increment_id', 'orders.increment_id'); $this->addFilter('state', 'refunds.state'); diff --git a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php index 9c94dbf69..ef5f6c647 100755 --- a/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderShipmentsDataGrid.php @@ -27,7 +27,7 @@ class OrderShipmentsDataGrid extends DataGrid ->leftJoin('orders as ors', 'shipments.order_id', '=', 'ors.id') ->leftJoin('inventory_sources as is', 'shipments.inventory_source_id', '=', 'is.id') ->select('shipments.id as shipment_id', 'ors.increment_id as shipment_order_id', 'shipments.total_qty as shipment_total_qty', 'is.name as inventory_source_name', 'ors.created_at as order_date', 'shipments.created_at as shipment_created_at') - ->addSelect(DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name) as shipped_to')); + ->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name) as shipped_to')); $this->addFilter('shipment_id', 'shipments.id'); $this->addFilter('shipment_order_id', 'ors.increment_id'); @@ -35,7 +35,7 @@ class OrderShipmentsDataGrid extends DataGrid $this->addFilter('inventory_source_name', 'is.name'); $this->addFilter('order_date', 'ors.created_at'); $this->addFilter('shipment_created_at', 'shipments.created_at'); - $this->addFilter('shipped_to', DB::raw('CONCAT(order_address_shipping.first_name, " ", order_address_shipping.last_name)')); + $this->addFilter('shipped_to', DB::raw('CONCAT(' . DB::getTablePrefix() . 'order_address_shipping.first_name, " ", ' . DB::getTablePrefix() . 'order_address_shipping.last_name)')); $this->setQueryBuilder($queryBuilder); } diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index bac760717..af1f95a7d 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -25,7 +25,7 @@ class ProductDataGrid extends DataGrid ->leftJoin('products', 'product_flat.product_id', '=', 'products.id') ->leftJoin('attribute_families', 'products.attribute_family_id', '=', 'attribute_families.id') ->leftJoin('product_inventories', 'product_flat.product_id', '=', 'product_inventories.product_id') - ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(product_inventories.qty) as quantity')) + ->select('product_flat.product_id as product_id', 'product_flat.sku as product_sku', 'product_flat.name as product_name', 'products.type as product_type', 'product_flat.status', 'product_flat.price', 'attribute_families.name as attribute_family', DB::raw('SUM(' . DB::getTablePrefix() . 'product_inventories.qty) as quantity')) ->where('channel', core()->getCurrentChannelCode()) ->where('locale', app()->getLocale()) ->groupBy('product_flat.product_id'); @@ -152,7 +152,7 @@ class ProductDataGrid extends DataGrid public function prepareMassActions() { $this->addMassAction([ 'type' => 'delete', - 'label' => 'Delete', + 'label' => 'Delete', 'action' => route('admin.catalog.products.massdelete'), 'method' => 'DELETE' ]); diff --git a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php index b9d3d47ba..08a81d355 100755 --- a/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php +++ b/packages/Webkul/Admin/src/Http/Controllers/DashboardController.php @@ -186,7 +186,7 @@ class DashboardController extends Controller ->where('order_items.created_at', '>=', $this->startDate) ->where('order_items.created_at', '<=', $this->endDate) ->addSelect(DB::raw('SUM(qty_invoiced - qty_refunded) as total_qty_invoiced')) - ->addSelect(DB::raw('COUNT(products.id) as total_products')) + ->addSelect(DB::raw('COUNT(' . DB::getTablePrefix() . 'products.id) as total_products')) ->addSelect('order_items.id', 'categories.id as category_id', 'category_translations.name') ->groupBy('categories.id') ->havingRaw('SUM(qty_invoiced - qty_refunded) > 0') diff --git a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php index 74906ae24..32398ca58 100644 --- a/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php +++ b/packages/Webkul/Shop/src/DataGrids/DownloadableProductDataGrid.php @@ -22,7 +22,7 @@ class DownloadableProductDataGrid extends DataGrid $queryBuilder = DB::table('downloadable_link_purchased') ->leftJoin('orders', 'downloadable_link_purchased.order_id', '=', 'orders.id') ->addSelect('downloadable_link_purchased.*', 'orders.increment_id') - ->addSelect(DB::raw('(downloadable_link_purchased.download_bought - downloadable_link_purchased.download_used) as remaining_downloads')) + ->addSelect(DB::raw('(' . DB::getTablePrefix() . 'downloadable_link_purchased.download_bought - ' . DB::getTablePrefix() . 'downloadable_link_purchased.download_used) as remaining_downloads')) ->where('downloadable_link_purchased.customer_id', auth()->guard('customer')->user()->id); $this->addFilter('status', 'downloadable_link_purchased.status'); @@ -97,7 +97,7 @@ class DownloadableProductDataGrid extends DataGrid 'wrapper' => function ($value) { if (! $value->download_bought) return trans('shop::app.customer.account.downloadable_products.unlimited'); - + return $value->remaining_downloads; }, ]); From 71e8e687c246dc29714ee770d996326aa990c2dc Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Tue, 26 Nov 2019 13:32:42 +0100 Subject: [PATCH 18/37] PR 1782 Enhancement: Let variants be of other types than simple --- .../views/catalog/products/create.blade.php | 2 +- .../Http/Listeners/CustomerEventsHandler.php | 33 +++++++++++++++++++ .../Webkul/Product/src/Type/Configurable.php | 9 ++++- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php index c3ff363e0..7308fd5c1 100755 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/create.blade.php @@ -64,7 +64,7 @@ @if ($familyId) - + @endif @{{ errors.first('type') }}
diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php new file mode 100755 index 000000000..f5b395c62 --- /dev/null +++ b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php @@ -0,0 +1,33 @@ +listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 6977bf5de..d604d5a63 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -143,9 +143,16 @@ class Configurable extends AbstractType ]; } + $typeOfVariants = 'simple'; + $productInstance = app(config('product_types.' . $product->type . '.class')); + if ($productInstance->variantsType && !in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) + { + $typeOfVariants = $productInstance->variantsType; + } + $variant = $this->productRepository->getModel()->create([ 'parent_id' => $product->id, - 'type' => 'simple', + 'type' => $typeOfVariants, 'attribute_family_id' => $product->attribute_family_id, 'sku' => $data['sku'], ]); From d29b8332e140c5d74b550e0d63a270e3d3b2386c Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Tue, 26 Nov 2019 13:41:04 +0100 Subject: [PATCH 19/37] undo something stupid when merging branch into recent bagisto master --- .../Http/Listeners/CustomerEventsHandler.php | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100755 packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php deleted file mode 100755 index f5b395c62..000000000 --- a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php +++ /dev/null @@ -1,33 +0,0 @@ -listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin'); - } -} \ No newline at end of file From 2d23123660fe1a9fd322d0338bd1554303408b11 Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Tue, 26 Nov 2019 13:45:02 +0100 Subject: [PATCH 20/37] adapt to code standard --- packages/Webkul/Product/src/Type/Configurable.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index d604d5a63..9b61209c4 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -145,8 +145,7 @@ class Configurable extends AbstractType $typeOfVariants = 'simple'; $productInstance = app(config('product_types.' . $product->type . '.class')); - if ($productInstance->variantsType && !in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) - { + if ($productInstance->variantsType && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) { $typeOfVariants = $productInstance->variantsType; } From 406c32012d8bef11d7ead5a893118f45ebeb683b Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Wed, 27 Nov 2019 09:53:11 +0100 Subject: [PATCH 21/37] add check if property is set --- packages/Webkul/Product/src/Type/Configurable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Type/Configurable.php b/packages/Webkul/Product/src/Type/Configurable.php index 9b61209c4..e0f1c3eea 100644 --- a/packages/Webkul/Product/src/Type/Configurable.php +++ b/packages/Webkul/Product/src/Type/Configurable.php @@ -145,7 +145,7 @@ class Configurable extends AbstractType $typeOfVariants = 'simple'; $productInstance = app(config('product_types.' . $product->type . '.class')); - if ($productInstance->variantsType && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) { + if (isset($productInstance->variantsType) && ! in_array($productInstance->variantsType , ['bundle', 'configurable', 'grouped'])) { $typeOfVariants = $productInstance->variantsType; } From 26b85fca06271ad67e55815aaff33ca831b6e82e Mon Sep 17 00:00:00 2001 From: "shubhammehrotra.symfony@webkul.com" Date: Fri, 29 Nov 2019 19:03:30 +0530 Subject: [PATCH 22/37] template correction --- packages/Webkul/Core/src/Templates/on-boarding.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Webkul/Core/src/Templates/on-boarding.php b/packages/Webkul/Core/src/Templates/on-boarding.php index e5311fbd6..21ff4eaea 100644 --- a/packages/Webkul/Core/src/Templates/on-boarding.php +++ b/packages/Webkul/Core/src/Templates/on-boarding.php @@ -9,6 +9,6 @@ Welcome to the Bagisto project! Bagisto Community is an open-source e-commerce ecosystem -which is built on top of top of Laravel and Vue.js. +which is built on top of Laravel and Vue.js. Made with 💖 by the Bagisto Team. Happy helping :) From 02ca34affac85217bde3a49eadc19c44d5a1fb4e Mon Sep 17 00:00:00 2001 From: Dirk Helbert Date: Sun, 1 Dec 2019 22:59:16 +0100 Subject: [PATCH 23/37] Take the fallback_locale from app.config when locale is not defined in shop --- packages/Webkul/Core/src/Core.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 9bfc791a3..963af1b00 100755 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -211,7 +211,13 @@ class Core if ($locale) return $locale; - return $locale = $this->localeRepository->findOneByField('code', app()->getLocale()); + $locale = $this->localeRepository->findOneByField('code', app()->getLocale()); + + if(!$locale) { + $locale = $this->localeRepository->findOneByField('code', config('app.fallback_locale')); + } + + return $locale; } /** From 3efe3a7f61bddd327ffc9ce927d74e3df75675db Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Mon, 25 Nov 2019 15:16:21 +0100 Subject: [PATCH 24/37] improve generation of slugs --- .gitignore | 3 ++- .../Resources/assets/js/directives/slugify.vue | 15 +++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 91f23accb..fa1eccb1e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ /public/js /public/vendor /public/themes -/storage/*.key /vendor /.idea /.vscode @@ -21,3 +20,5 @@ yarn.lock package-lock.json yarn.lock .php_cs.cache +storage/ +storage/*.key diff --git a/packages/Webkul/Ui/src/Resources/assets/js/directives/slugify.vue b/packages/Webkul/Ui/src/Resources/assets/js/directives/slugify.vue index 30cb16415..7e1bab0c5 100755 --- a/packages/Webkul/Ui/src/Resources/assets/js/directives/slugify.vue +++ b/packages/Webkul/Ui/src/Resources/assets/js/directives/slugify.vue @@ -1,12 +1,15 @@