diff --git a/bower.json b/bower.json new file mode 100644 index 000000000..7db3d4c6e --- /dev/null +++ b/bower.json @@ -0,0 +1,18 @@ +{ + "name": "bagisto", + "description": "An eCommerce ecosystem for All to build and scale your business.", + "main": "", + "authors": [ + "Webkul " + ], + "license": "MIT", + "keywords": [ + "ecommerce", + "framework", + "laravel", + "php", + "store", + "commerce" + ], + "homepage": "https://github.com/bagisto/bagisto" +} diff --git a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php index 9325c1d3d..cf434c28c 100644 --- a/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/OrderDataGrid.php @@ -92,7 +92,6 @@ class OrderDataGrid return 'Completed'; else if($value == "pending") return 'Pending'; - }, ], ], diff --git a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php index 4c2fdc94d..a9c5fa443 100644 --- a/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductDataGrid.php @@ -70,19 +70,19 @@ class ProductDataGrid 'name' => 'prods.name', 'alias' => 'ProductName', 'type' => 'string', - 'label' => 'Product Name', + 'label' => 'Name', 'sortable' => false, ], [ 'name' => 'prods.type', 'alias' => 'ProductType', 'type' => 'string', - 'label' => 'Product Type', + 'label' => 'Type', 'sortable' => false, ], [ 'name' => 'prods.status', 'alias' => 'ProductStatus', 'type' => 'string', - 'label' => 'Product Status', + 'label' => 'Status', 'sortable' => false, 'wrapper' => function ($value) { if($value == 1) @@ -94,7 +94,7 @@ class ProductDataGrid 'name' => 'prods.price', 'alias' => 'ProductPrice', 'type' => 'string', - 'label' => 'Product Price', + 'label' => 'Price', 'sortable' => false, 'wrapper' => function ($value) { return core()->formatBasePrice($value); diff --git a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php b/packages/Webkul/Admin/src/DataGrids/ProductReviewDataGrid.php similarity index 89% rename from packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php rename to packages/Webkul/Admin/src/DataGrids/ProductReviewDataGrid.php index 2360e9e89..1f800dd4d 100644 --- a/packages/Webkul/Admin/src/DataGrids/CustomerReviewDataGrid.php +++ b/packages/Webkul/Admin/src/DataGrids/ProductReviewDataGrid.php @@ -13,17 +13,17 @@ use Webkul\Ui\DataGrid\Facades\DataGrid; * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CustomerReviewDataGrid +class ProductReviewDataGrid { /** - * The CustomerReviewDataGrid + * The ProductReviewDataGrid * implementation. * * @var CustomerReviewsDataGrid * for Reviews */ - public function createCustomerReviewDataGrid() + public function createProductReviewDataGrid() { return DataGrid::make([ @@ -87,6 +87,12 @@ class CustomerReviewDataGrid 'type' => 'number', 'label' => 'Status', 'sortable' => true, + 'wrapper' => function ($value) { + if($value == 'approved') + return 'Approved'; + else if($value == "pending") + return 'Pending'; + }, ], ], @@ -153,6 +159,6 @@ class CustomerReviewDataGrid public function render() { - return $this->createCustomerReviewDataGrid()->render(); + return $this->createProductReviewDataGrid()->render(); } } \ No newline at end of file diff --git a/packages/Webkul/Admin/src/Listeners/Product.php b/packages/Webkul/Admin/src/Listeners/Product.php index 97a7d0776..78a82a86e 100644 --- a/packages/Webkul/Admin/src/Listeners/Product.php +++ b/packages/Webkul/Admin/src/Listeners/Product.php @@ -50,6 +50,8 @@ class Product { */ public function prepareData($product) { $gridObject = []; + $variantObjects = []; + $gridObject = [ 'product_id' => $product->id, 'sku' => $product->sku, @@ -57,15 +59,13 @@ class Product { 'attribute_family_name' => $product->attribute_family->name, ]; - $variantObjects = []; - if($this->productGrid->findOneByField('product_id', $product->id)) { $gridObject['name'] = $product->name; $gridObject['status'] = $product->status; if($product->type == 'configurable') { $gridObject['quantity'] = 0; - $gridObject['price'] = $this->price->getMinimalPrice($product); + $gridObject['price'] = 0; $variants = $product->variants; @@ -80,13 +80,13 @@ class Product { 'status' => $variant->status, ]; - $qty = 1; - - foreach($variant->toArray()['inventories'] as $inventorySource) { - $qty = $qty + $inventorySource['qty']; + $qty = 0; + //inventories and inventory sources relation for the variants return empty or null collection objects only + foreach($variant->inventories()->get() as $inventory_source) { + $qty = $qty + $inventory_source->qty; } - $variantObject['price'] = $product->price; + $variantObject['price'] = $variant->price; $variantObject['quantity'] = $qty; array_push($variantObjects, $variantObject); @@ -97,8 +97,8 @@ class Product { } else { $qty = 0; - foreach($product->toArray()['inventories'] as $inventorySource) { - $qty = $qty + $inventorySource['qty']; + foreach($product->inventories->get() as $inventory_source) { + $qty = $qty + $inventory_source->qty; } $gridObject['price'] = $product->price; @@ -107,7 +107,6 @@ class Product { $qty = 0; } } - // dd($gridObject, $variantObjects); return [ 'parent' => $gridObject, 'variants' => $variantObjects @@ -136,15 +135,16 @@ class Product { $productGridObject = $this->productGrid->findOneByField('product_id', $product->id); // dd($product, $data, $productGridObject); - if (!is_null($productGridObject)) { + if(!is_null($productGridObject)) { if($product->type == 'simple') { $r = $productGridObject->update($data['parent']); } else { $productGridObject->update($data['parent']); + if(count($data['variants'])) { - dd($data['variants']); foreach($data['variants'] as $variant) { $variantObject = $this->productGrid->findOneByField('product_id', $variant['product_id']); + if(!is_null($variantObject)) { $variantObject->update($variant); } else { @@ -156,7 +156,7 @@ class Product { } else { $this->productGrid->create($data['parent']); - //no need for tese lines + //no need for these lines if(count($data['variants'])) { foreach($data['variants'] as $variant) { $this->productGrid->create($variant); @@ -176,37 +176,8 @@ class Product { } /** - * Event after the product update - * - * @var collection product - * - * return boolean + * Manually invoke this function when you have created the products by importing or seeding or factory. */ - public function afterProductUpdate($product) { - //update product grid here - $this->productGrid->updateWhere($product); - - return true; - } - - /** - * Event after deletion of the product - * - * @return boolean - */ - public function afterProductDelete($productId) { - return true; - } - - /** - * Fill attributes for that product after the creation - * - * @return boolean - */ - public function fillAttribute() { - - } - public function sync() { $gridObject = []; diff --git a/packages/Webkul/Admin/src/Resources/views/customers/review/index.blade.php b/packages/Webkul/Admin/src/Resources/views/customers/review/index.blade.php index b05f5f819..487788ef2 100644 --- a/packages/Webkul/Admin/src/Resources/views/customers/review/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/customers/review/index.blade.php @@ -19,7 +19,7 @@
- @inject('review','Webkul\Admin\DataGrids\CustomerReviewDataGrid') + @inject('review','Webkul\Admin\DataGrids\ProductReviewDataGrid') {!! $review->render() !!}
diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index fb95af4d1..67b255f39 100644 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -1164,4 +1164,21 @@ class Cart { return ['parent' => $parentData, 'child' => $childData]; } + + /** + * Handle the buy now process for simple as well as configurable products + * + * @return response mixed + */ + public function proceedForBuyNow($id) { + $product = $this->product->findOneByField('id', $id); + + if($product->type == 'configurable') { + session()->flash('warning', 'Please Select Options Before Buying This Product'); + + return false; + } else { + $this->moveToCart($id); + } + } } \ 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 955fdb13a..437568991 100644 --- a/packages/Webkul/Product/src/Http/Controllers/ProductController.php +++ b/packages/Webkul/Product/src/Http/Controllers/ProductController.php @@ -205,7 +205,7 @@ class ProductController extends Controller $this->product->delete($id); //before update of product - Event::fire('product.delete.after', $id); + // Event::fire('product.delete.after', $id); session()->flash('success', 'Product deleted successfully.'); diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index 136e93254..4a79f9b63 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -88,7 +88,7 @@ class CartController extends Controller public function add($id) { $data = request()->input(); - + Cart::add($id, $data); Cart::collectTotals(); @@ -143,7 +143,11 @@ class CartController extends Controller return redirect()->route('shop.products.index', $slug); } - public function test() { - $result = Cart::isConfigurable(9); + public function test($id) { + $result = Cart::proceedForBuyNow($id); + + if(!$result) { + return redirect()->back(); + } } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php b/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php index bf7a8fda9..39b75c267 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/ReviewController.php @@ -46,9 +46,9 @@ class ReviewController extends Controller */ public function __construct(Product $product, ProductReview $productReview) { - $this->middleware('admin'); + $this->middleware('admin')->only(['update', 'destroy']); - $this->middleware('customer')->only(['create', 'store']); + $this->middleware('customer')->only(['create', 'store', 'destroy']); $this->product = $product; @@ -151,4 +151,17 @@ class ReviewController extends Controller return redirect()->route($this->_config['redirect']); } + + /** + * Delete the review of the current product + * + * @return response + */ + public function destroy($id) { + $this->productReview->delete($id); + + success()->flash('success', 'Product Review Successfully Deleted'); + + return redirect()->back(); + } } diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index 9b8586aa1..7ddfe1b7c 100644 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -45,8 +45,8 @@ Route::group(['middleware' => ['web', 'theme', 'locale', 'currency']], function 'view' => 'shop::checkout.success' ])->name('shop.checkout.success'); - //dummy - Route::get('test', 'Webkul\Shop\Http\Controllers\CartController@test'); + //buy now + Route::get('buynow/{id}', 'Webkul\Shop\Http\Controllers\CartController@test')->name('shop.product.buynow'); Route::get('/products/{slug}', 'Webkul\Shop\Http\Controllers\ProductController@index')->defaults('_config', [ 'view' => 'shop::products.view' diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index f73444e11..13cf35def 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -655,13 +655,18 @@ section.slider-block { flex-direction: row; justify-content: flex-end; align-items: center; - // cursor: pointer; .currency-switcher { float: right; border-right: 2px solid $border-color; cursor: pointer; + .dropdown-toggle { + line-height: 25px; + margin-left: 14px; + margin-right: 14px; + } + .dropdown-list { width: 100px; top: 37px; @@ -675,12 +680,20 @@ section.slider-block { ul.account-dropdown-container { float: right; border-right: 2px solid $border-color; + cursor: pointer; li.account-dropdown { display: flex; flex-direction: row; - margin-right: 14px; margin-left: 14px; + margin-right: 14px; + + .account { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + } .dropdown-list { width: 300px; @@ -816,6 +829,7 @@ section.slider-block { } } } + ul.right-responsive { display: none; cursor: pointer; @@ -1052,6 +1066,7 @@ section.slider-block { ul.right-responsive { display: flex !important; + margin-left: 12px; } } @@ -1658,7 +1673,6 @@ section.product-detail { .rating-reviews { .rating-header { - font-weight: 600; padding: 20px 0; } diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php index dc4441e94..9ed2eac23 100644 --- a/packages/Webkul/Shop/src/Resources/lang/en/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php @@ -7,6 +7,17 @@ return [ 'new-products' => 'New Products' ], + 'header' => [ + 'title' => 'Account', + 'dropdown-text' => 'Manage Cart, Orders & Wishlist.', + 'sign-in' => 'Sign In', + 'sign-up' => 'Sign Up', + 'profile' => 'Profile', + 'wishlist' => 'Wishlist', + 'cart' => 'Cart', + 'logout' => 'Logout' + ], + 'footer' => [ 'subscribe-newsletter' => 'Subscribe Newsletter', 'subscribe' => 'Subscribe', diff --git a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php index 49799a87a..fc91e0539 100644 --- a/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/layouts/header/index.blade.php @@ -26,9 +26,9 @@
@if (core()->getCurrentChannel()->currencies->count() > 1) -
+
    @@ -43,27 +43,25 @@
- + @endif @@ -109,22 +102,18 @@