diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index fca6152c3..7ac436fbf 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -12,11 +12,11 @@ class EventServiceProvider extends ServiceProvider * * @var array */ - protected $listen = [ - 'App\Events\Event' => [ - 'App\Listeners\EventListener', - ], - ]; + // protected $listen = [ + // 'App\Events\Event' => [ + // 'App\Listeners\EventListener', + // ], + // ]; /** * Register any events for your application. diff --git a/composer.json b/composer.json index b67e85057..0a58b0e6c 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,7 @@ "webkul/laravel-ui": "self.version", "webkul/laravel-core": "self.version", "webkul/laravel-attribute": "self.version", + "webkul/laravel-cart": "self.version", "webkul/laravel-customer": "self.version", "webkul/laravel-category": "self.version", "webkul/laravel-product": "self.version", @@ -52,6 +53,7 @@ "Webkul\\Admin\\": "packages/Webkul/Admin/src", "Webkul\\Ui\\": "packages/Webkul/Ui/src", "Webkul\\Category\\": "packages/Webkul/Category/src", + "Webkul\\Cart\\": "packages/Webkul/Cart/src", "Webkul\\Attribute\\": "packages/Webkul/Attribute/src", "Webkul\\Shop\\": "packages/Webkul/Shop/src", "Webkul\\Core\\": "packages/Webkul/Core/src", @@ -59,7 +61,6 @@ "Webkul\\Inventory\\": "packages/Webkul/Inventory/src", "Webkul\\Product\\": "packages/Webkul/Product/src", "Webkul\\Theme\\": "packages/Webkul/Theme/src", - "Webkul\\Cart\\": "packages/Webkul/Cart/src", "Webkul\\Shipping\\": "packages/Webkul/Shipping/src" } }, diff --git a/config/app.php b/config/app.php index b0f6ebc94..c0f4ca1dd 100644 --- a/config/app.php +++ b/config/app.php @@ -180,7 +180,7 @@ return [ Webkul\User\Providers\UserServiceProvider::class, Webkul\Admin\Providers\AdminServiceProvider::class, Webkul\Ui\Providers\UiServiceProvider::class, - Webkul\Category\Providers\CategoryServiceProvider::class, + // Webkul\Category\Providers\CategoryServiceProvider::class, Webkul\Attribute\Providers\AttributeServiceProvider::class, Webkul\Core\Providers\CoreServiceProvider::class, Webkul\Shop\Providers\ShopServiceProvider::class, @@ -243,6 +243,7 @@ return [ 'Datagrid' => Webkul\Ui\DataGrid\Facades\DataGrid::class, 'ProductGrid' => Webkul\Ui\DataGrid\Facades\ProductGrid::class, 'Image' => Intervention\Image\Facades\Image::class, + 'Cart' => Webkul\Cart\Facades\Cart::class, 'Core' => Webkul\Core\Facades\Core::class ], diff --git a/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php b/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php index d972647e2..fc4a1d6c3 100644 --- a/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/users/users/index.blade.php @@ -2,6 +2,7 @@ @section('page_title') +@endsection @stop @section('content') diff --git a/packages/Webkul/Cart/.gitignore b/packages/Webkul/Cart/.gitignore new file mode 100644 index 000000000..30bc16279 --- /dev/null +++ b/packages/Webkul/Cart/.gitignore @@ -0,0 +1 @@ +/node_modules \ No newline at end of file diff --git a/packages/Webkul/Cart/composer.json b/packages/Webkul/Cart/composer.json index ea46e9c47..205719c18 100644 --- a/packages/Webkul/Cart/composer.json +++ b/packages/Webkul/Cart/composer.json @@ -1,10 +1,9 @@ { "name": "webkul/laravel-cart", - "description": "Cart Package for customer.", "license": "MIT", "authors": [ { - "name": "prashant-webkul", + "name": "Prashant Singh", "email": "prashant.singh852@webkul.com" } ], @@ -17,9 +16,8 @@ "extra": { "laravel": { "providers": [ - "Webkul\\Cart\\Providers\\CartServiceProvider" - ], - "aliases": {} + "Webkul\\Cart\\CartServiceProvider" + ] } }, "minimum-stability": "dev" diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php new file mode 100644 index 000000000..0d9342e41 --- /dev/null +++ b/packages/Webkul/Cart/src/Cart.php @@ -0,0 +1,361 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ + +class Cart { + + protected $_config; + + protected $cart; + + protected $cartProduct; + + protected $customer; + + public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer) { + + $this->customer = $customer; + + $this->cart = $cart; + + $this->cartProduct = $cartProduct; + } + + public function guestUnitAdd($id) { + + $products = array(); + + $minutes = 10; + + if(Cookie::get('current_session_id')) { + + $cart_session_id = Cookie::get('cart_session_id'); + + $cart = $this->cart->getOneByField('session_id'. $cart_session_id); + + $cartId = $cart->id ?? $cart['id'] ; + + $products = $this->getProducts($id); + + foreach($products as $key => $value) { + if($value == $id) { + dd('product already in the cart'); + + return redirect()->back(); + } + } + + if($this->cartProduct->create($id)) { + session()->flash('Success', 'Product Added To Cart'); + return redirect()->back(); + } + return redirect()->back(); + + } else { + Cookie::queue('cart_session_id', session()->id(), $minutes); + + $data['session_id'] = Cookie::get('cart_session_id'); + + $data['channel_id'] = core()->getCurrentChannel()->id; + + if($this->cart->create($data)) { + if($this->cartProduct->create($product)) { + session()->flash('Success', 'Product Added To Cart'); + } + } + } + } + + /** + * Function for guests + * user to remove the product + * in the cart. + * + * @return Mixed + */ + public function guestUnitRemove($id) { + + //remove the products here + if(Cookie::has('session_c')) { + $products = unserialize(Cookie::get('session_c')); + + foreach($products as $key => $value) { + if($value == $id) { + unset($products[$key]); + + array_push($products, $id); + + Cookie::queue('session_c', serialize($products)); + + return redirect()->back(); + } + } + } + } + + /* + handle the after login event for the customers + when their are pruoducts in the session or cookie + of the logged in user. + */ + + public function add($id) { + + $products = array(); + + // $customerLoggedIn = auth()->guard('customer')->check(); + + // //customer is authenticated + // if ($customerLoggedIn) { + //assuming that there is data in cookie and customer's cart also. + + $data['customer_id'] = auth()->guard('customer')->user()->id; + + $data['channel_id'] = core()->getCurrentChannel()->id; + + $customerCart = $this->cart->findOneByField('customer_id', $data['customer_id']); + + //if there are products already in cart of that customer. + $customerCartId = $customerCart->id ?? $customerCart['id']; + + $customerCartProducts = $this->cart->getProducts($customerCartId); + + if (isset($customerCartProducts)) { + + foreach ($customerCartProducts as $previousCartProduct) { + + if($previousCartProduct->id == $id) { + dd('product already exists in cart'); + + session()->flash('error', 'Product already exists in cart'); + + return redirect()->back(); + } + } + //add the product in the cart + + $product['product_id'] = $id; + + $product['quantity'] = 1; + + $product['cart_id'] = $customerCartId; + + $this->cartProduct->create($product); + + return redirect()->back(); + } + // } + + // //case when cookie has products and customer also have data in cart tables + // if(isset($customerCart) && isset($cartCookie)) { + // //for unsetting the cookie for the cart uncomment after all done + // // Cookie::queue(Cookie::forget('session_c')); + + // //check if there is any repetition in the products + // $customerCartId = $customerCart->id ?? $customerCart['id']; + + // //to check if the customer is also having some products saved in the pivot + // //for the products. + // $customerCartProducts = $this->cart->getProducts($customerCartId); + + // //if there are products already in cart of that customer + // if(isset($customerCartProducts)) { + + // foreach($customerCartProducts as $previousCartProduct) { + + // dump($customerCartProducts); + + // foreach($cookieProducts as $key => $cookieProduct) { + + // if($previousCartProduct->id == $cookieProduct) { + + // unset($cookieProducts[$key]); + // } + // } + // } + // } + + // /*if the above block executes it will remove duplicates + // else product in cookies will be stored in the database.*/ + + // foreach($cookieProducts as $key => $cookieProduct) { + + // $product['product_id'] = $cookieProduct; + + // $product['quantity'] = 1; + + // $product['cart_id'] = $customerCartId; + + // $this->cartProduct->create($product); + // } + + // dump('Products in the cart synced.'); + + // return redirect()->back(); + + // } else if(isset($customerCart) && !isset($cartCookie)) { + // //case when there is no data in guest's cart + + // $customerCartId = $customerCart->id ?? $customerCart['id']; + + // $customerCartProducts = $this->cart->getProducts($customerCartId); + + // foreach($customerCartProducts as $previousCartProduct) { + + // if($previousCartProduct->id == $id) { + + // dd('product already in the cart::AUTH'); + + // return redirect()->back(); + // } + // } + // $product['product_id'] = $id; + + // $product['quantity'] = 1; + + // $product['cart_id'] = $customerCartId; + + // $this->cartProduct->create($product); + + // dump('new item added in the cart'); + + // return redirect()->back(); + + // } else if(!isset($customerCart) && isset($cartCookie)) { + + // $products = unserialize(Cookie::get('session_c')); + + // if ($cart = $this->cart->create($data)) { + + // foreach($products as $product) { + + // $product['product_id'] = $id; + + // $product['quantity'] = 1; + + // $product['cart_id'] = $cart; + + // $this->cartProduct->create($product); + // } + // return redirect()->back(); + + // } else { + // session()->flash('error', 'Cannot Add Your Items To Cart'); + + // return redirect()->back(); + // } + // } + // } + } + + /** + * use detach to remove the + * current product from cart tables + * + * @return Mixed + */ + public function remove($id) { + + dd("Removing Item from Cart"); + } + + /** + * Function to handle merge + * and sync the cookies products + * with the existing data of cart + * in the cart tables; + */ + public function handleMerge() { + + // $productsInCookie = unserialize(Cookie::get('session_c')); + + $cart_session_id = Cookie::get('cart_session_id'); + + $cart = $this->cart->findOneByField('session_id'); + + $cartId = $cart->id ?? $cart['id']; + + $data['customer_id'] = auth()->guard('customer')->user()->id; + + $data['channel_id'] = core()->getCurrentChannel()->id; + + $customerCart = $this->cart->findOneByField('customer_id', $data['customer_id']); + + if(isset($customerCart)) { + + $customerCartId = $customerCart->id ?? $customerCart['id']; + + $customerCartProducts = $this->cart->getProducts($customerCartId); + + if(isset($customerCartProducts)) { + + foreach($customerCartProducts as $previousCartProduct) { + + foreach($productsInCookie as $key => $productInCookie) { + + if($previousCartProduct->id == $productInCookie) { + + unset($productsInCookie[$key]); + } + } + } + } + + /*if the above block executes it will remove duplicates + else product in cookies will be stored in the database.*/ + + foreach($productsInCookie as $key => $cookieProduct) { + + $product['product_id'] = $cookieProduct; + + $product['quantity'] = 1; + + $product['cart_id'] = $customerCartId; + + $this->cartProduct->create($product); + } + + //forget that cookie here. + Cookie::queue(Cookie::forget('session_c')); + } else { + + if($cart = $this->cart->create($data)) { + + foreach($productsInCookie as $productInCookie) { + + $product['product_id'] = $cookieProduct; + + $product['quantity'] = 1; + + $product['cart_id'] = $cart->id; + + $this->cartProduct->create($product); + } + } + //forget the Cookie + Cookie::queue(Cookie::forget('session_c')); + + return redirect()->back(); + } + } +} \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_products_table.php similarity index 89% rename from packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php rename to packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_products_table.php index 0d739e52e..5d3f4b2ce 100644 --- a/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_items_table.php +++ b/packages/Webkul/Cart/src/Database/migrations/2018_09_05_150915_create_cart_products_table.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; -class CreateCartItemsTable extends Migration +class CreateCartProductsTable extends Migration { /** * Run the migrations. @@ -13,7 +13,7 @@ class CreateCartItemsTable extends Migration */ public function up() { - Schema::create('cart_items', function (Blueprint $table) { + Schema::create('cart_products', function (Blueprint $table) { $table->increments('id'); $table->integer('product_id')->unsigned(); $table->foreign('product_id')->references('id')->on('products'); diff --git a/packages/Webkul/Cart/src/Facades/Cart.php b/packages/Webkul/Cart/src/Facades/Cart.php new file mode 100644 index 000000000..10481133b --- /dev/null +++ b/packages/Webkul/Cart/src/Facades/Cart.php @@ -0,0 +1,18 @@ +middleware(['customer', 'guest']); + protected $customer; - $this->_config = request('_config'); + public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer) { + + $this->middleware('customer')->except(['add', 'remove']); + + $this->customer = $customer; $this->cart = $cart; + + $this->cartProduct = $cartProduct; } - public function add() { - return "Adding Items to Cart"; + /** + * Function for guests + * user to add the product + * in the cart. + * + * @return Mixed + */ + + public function add($id) { + + if(auth()->guard('customer')->check()) { + Cart::add($id); + } else { + Cart::guestUnitAdd($id); + } + } + + public function remove($id) { + + if(auth()->guard('customer')->check()) { + Cart::remove($id); + } else { + Cart::guestUnitRemove($id); + } } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Http/Controllers/Controller.php b/packages/Webkul/Cart/src/Http/Controllers/Controller.php new file mode 100644 index 000000000..3b56110cc --- /dev/null +++ b/packages/Webkul/Cart/src/Http/Controllers/Controller.php @@ -0,0 +1,13 @@ +belongsToMany(Product::class, 'cart_products'); + } } diff --git a/packages/Webkul/Cart/src/Models/CartItems.php b/packages/Webkul/Cart/src/Models/CartProduct.php similarity index 55% rename from packages/Webkul/Cart/src/Models/CartItems.php rename to packages/Webkul/Cart/src/Models/CartProduct.php index 00999f903..8b8a9d32b 100644 --- a/packages/Webkul/Cart/src/Models/CartItems.php +++ b/packages/Webkul/Cart/src/Models/CartProduct.php @@ -1,10 +1,11 @@ loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + + $router->aliasMiddleware('admin', RedirectIfNotAdmin::class); // $router->aliasMiddleware('customer', RedirectIfNotCustomer::class); - $this->loadMigrationsFrom(__DIR__ . '/../Database/migrations'); + $this->register(EventServiceProvider::class); } /** @@ -23,6 +31,24 @@ class CartServiceProvider extends ServiceProvider */ public function register() { - // $this->app->bind('datagrid', 'Webkul\Ui\DataGrid\DataGrid'); + $this->registerFacades(); + } + + /** + * Register Bouncer as a singleton. + * + * @return void + */ + protected function registerFacades() + { + $loader = AliasLoader::getInstance(); + + $loader->alias('cart', Cart::class); + + $this->app->singleton('cart', function () { + return new cart(); + }); + + $this->app->bind('cart', 'Webkul\Cart\Cart'); } } diff --git a/packages/Webkul/Cart/src/Repositories/CartItemsRepository.php b/packages/Webkul/Cart/src/Repositories/CartProductRepository.php similarity index 89% rename from packages/Webkul/Cart/src/Repositories/CartItemsRepository.php rename to packages/Webkul/Cart/src/Repositories/CartProductRepository.php index 72cd3c8d7..0c3636d5d 100644 --- a/packages/Webkul/Cart/src/Repositories/CartItemsRepository.php +++ b/packages/Webkul/Cart/src/Repositories/CartProductRepository.php @@ -11,7 +11,7 @@ use Webkul\Core\Eloquent\Repository; * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ -class CartItemsRepository extends Repository +class CartProductRepository extends Repository { /** * Specify Model class name @@ -21,7 +21,7 @@ class CartItemsRepository extends Repository function model() { - return 'Webkul\Cart\Models\CartItems'; + return 'Webkul\Cart\Models\CartProduct'; } /** diff --git a/packages/Webkul/Cart/src/Repositories/CartRepository.php b/packages/Webkul/Cart/src/Repositories/CartRepository.php index 27257051a..d75299717 100644 --- a/packages/Webkul/Cart/src/Repositories/CartRepository.php +++ b/packages/Webkul/Cart/src/Repositories/CartRepository.php @@ -51,4 +51,39 @@ class CartRepository extends Repository return $cart; } + + public function getProducts($id) { + + return $this->model->find($id)->with_products; + } + + /** + * Method to attach + * associations + * + * @return mixed + */ + // public function onlyAttach($id, $taxRates) { + + // foreach($taxRates as $key => $value) { + + // $this->model->findOrFail($id)->tax_rates()->attach($id, ['tax_category_id' => $id, 'tax_rate_id' => $value]); + // } + // } + + + /** + * Method to detach + * and attach the + * associations + * + * @return mixed + */ + // public function syncAndDetach($id, $taxRates) { + // $this->model->findOrFail($id)->tax_rates()->detach(); + + // foreach($taxRates as $key => $value) { + // $this->model->findOrFail($id)->tax_rates()->attach($id, ['tax_category_id' => $id, 'tax_rate_id' => $value]); + // } + // } } \ No newline at end of file diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 2c20e10a0..119d43b41 100644 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -140,9 +140,8 @@ class Core $channel = $this->getCurrentChannel(); - $currencyCode = $channel->base_currency; - // $currencyCode = $channel->base_currency->code; + $currencyCode = $channel->base_currency; return currency($price, $currencyCode); } diff --git a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php index 893feccac..2c036ddca 100644 --- a/packages/Webkul/Core/src/Providers/CoreServiceProvider.php +++ b/packages/Webkul/Core/src/Providers/CoreServiceProvider.php @@ -6,7 +6,8 @@ use Illuminate\Routing\Router; use Illuminate\Foundation\AliasLoader; use Webkul\Core\Http\Middleware\Locale; use Webkul\Core\Core; -use Webkul\Core\Facades\CoreFacade; +use Webkul\Core\Facades\Core as CoreFacade; + class CoreServiceProvider extends ServiceProvider { /** @@ -20,9 +21,15 @@ class CoreServiceProvider extends ServiceProvider $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'core'); $router->aliasMiddleware('locale', Locale::class); + + $router->aliasMiddleware('admin', RedirectIfNotAdmin::class); + + $router->aliasMiddleware('customer', RedirectIfNotCustomer::class); + // $this->publishes([ // __DIR__ . '/../../publishable/lang' => public_path('vendor/webkul/core/lang'), // ], 'public'); + Validator::extend('slug', 'Webkul\Core\Contracts\Validations\Slug@passes'); Validator::extend('code', 'Webkul\Core\Contracts\Validations\Code@passes'); } diff --git a/packages/Webkul/Customer/composer.json b/packages/Webkul/Customer/composer.json index e64b60909..f8d4e3ceb 100644 --- a/packages/Webkul/Customer/composer.json +++ b/packages/Webkul/Customer/composer.json @@ -4,7 +4,7 @@ "license": "MIT", "authors": [ { - "name": "prashant-webkul", + "name": "Prashant Singh", "email": "prashant.singh852@webkul.com" } ], diff --git a/packages/Webkul/Customer/src/Http/Controllers/AccountController.php b/packages/Webkul/Customer/src/Http/Controllers/AccountController.php index 17795fdb0..49f130116 100644 --- a/packages/Webkul/Customer/src/Http/Controllers/AccountController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/AccountController.php @@ -17,6 +17,7 @@ use Auth; * @author Prashant Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ + class AccountController extends Controller { /** diff --git a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php index 18a2dae23..d3017ed64 100644 --- a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php @@ -4,9 +4,13 @@ namespace Webkul\Customer\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Http\Response; -use Illuminate\Routing\Controller; -use Webkul\Customer\Models\Customer; +use Illuminate\Support\Facades\Event; +use Webkul\Customer\Models\Customer; +use Webkul\Customer\Http\Listeners\CustomerEventsHandler; + +use Cookie; +use Cart; /** * Session controller for the user customer * @@ -29,6 +33,10 @@ class SessionController extends Controller $this->_config = request('_config'); + $subscriber = new CustomerEventsHandler; + + Event::subscribe($subscriber); + } public function show() @@ -53,6 +61,10 @@ class SessionController extends Controller return back(); } + //Event passed to prepare cart after login + + Event::fire('customer.after.login', $request->input('email')); + return redirect()->intended(route($this->_config['redirect'])); } diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php new file mode 100644 index 000000000..d4b4e26b1 --- /dev/null +++ b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php @@ -0,0 +1,43 @@ +listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin'); + } +} \ No newline at end of file diff --git a/packages/Webkul/Customer/src/Providers/EventServiceProvider.php b/packages/Webkul/Customer/src/Providers/EventServiceProvider.php index b322a94b0..ebf899ea7 100644 --- a/packages/Webkul/Customer/src/Providers/EventServiceProvider.php +++ b/packages/Webkul/Customer/src/Providers/EventServiceProvider.php @@ -2,13 +2,14 @@ namespace Webkul\Customer\Providers; -use Illuminate\Support\ServiceProvider; +use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\View; use Webkul\Customer\Menu; class EventServiceProvider extends ServiceProvider { + /** * Bootstrap services. * @@ -27,6 +28,7 @@ class EventServiceProvider extends ServiceProvider public function createCustomerAccountSideMenu() { + Event::listen('customer.menu.create', function () { return Menu::create(function ($menu) { Event::fire('customer.menu.build', $menu); diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index 77f876c58..1ca1cf59c 100644 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -18,6 +18,8 @@ class Product extends Model protected $with = ['attribute_family', 'inventories']; + // protected $table = 'products'; + /** * Get the product attribute family that owns the product. */ diff --git a/packages/Webkul/Shop/composer.json b/packages/Webkul/Shop/composer.json index 87d40e3be..65367dc28 100644 --- a/packages/Webkul/Shop/composer.json +++ b/packages/Webkul/Shop/composer.json @@ -1,10 +1,11 @@ { "name": "webkul/laravel-shop", "license": "MIT", + "description" : "Shop package for store front and customers", "authors": [ { - "name": "Prashant", - "email": "prashant@webkul.com" + "name": "Prashant Singh", + "email": "prashant.singh852@webkul.com" } ], "require": {}, diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php index bbd99dd80..f37645460 100644 --- a/packages/Webkul/Shop/src/Http/routes.php +++ b/packages/Webkul/Shop/src/Http/routes.php @@ -21,6 +21,20 @@ Route::group(['middleware' => ['web']], function () { 'view' => 'shop::products.view' ])->name('shop.products.index'); + // //Routes for product cart + + Route::post('products/guest/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.add'); + + Route::post('product/guest/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove'); + + // Route::post('product/customer/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.customer.add'); + + // Route::post('product/customer/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.customer.remove'); + + Route::get('product/customer/cart/merge', 'Webkul\Cart\Http\Controllers\CartController@handleMerge')->name('cart.merge'); + + //Routes for product cart ends + // Product Review routes Route::get('/reviews/{slug}/{id}', 'Webkul\Shop\Http\Controllers\ReviewController@show')->defaults('_config', [ @@ -59,7 +73,6 @@ Route::group(['middleware' => ['web']], function () { 'redirect' => 'customer.account.index' ])->name('customer.session.create'); - // Registration Routes Route::get('register', 'Webkul\Customer\Http\Controllers\RegistrationController@show')->defaults('_config', [ 'view' => 'shop::customers.signup.index' //hint path @@ -128,7 +141,7 @@ Route::group(['middleware' => ['web']], function () { ])->name('customer.address.edit'); Route::post('address/edit', 'Webkul\Customer\Http\Controllers\AddressController@edit')->defaults('_config', [ - 'view' => 'shop::customers.account.address.address' + 'redirect' => 'customer.address.index' ])->name('customer.address.edit'); /* Routes for Addresses ends here */ diff --git a/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php b/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php index 470efa738..1fb2ebf9d 100644 --- a/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php +++ b/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php @@ -17,7 +17,7 @@ class ComposerServiceProvider extends ServiceProvider public function boot() { //using the class based composers... - View::composer('shop::layouts.header.index', 'Webkul\Shop\Http\ViewComposers\Categories\CategoryComposer'); + View::composer(['shop::layouts.header.index', 'shop::layouts.footer'], 'Webkul\Shop\Http\ViewComposers\Categories\CategoryComposer'); } /** diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index 6b594e5c4..40c9b97e0 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -767,6 +767,7 @@ section.slider-block { margin-right: 10%; .content-container { + display: inline-block; width: 100%; } @@ -777,7 +778,7 @@ section.slider-block { .product-grid { display: grid; - grid-gap: 15px; + grid-gap: 30px; &.max-2-col { grid-template-columns: repeat(2, minmax(250px, 1fr)); @@ -1285,12 +1286,11 @@ section.slider-block { //edit form .edit-form-content { - padding: 0px 25px; margin-left: 5.5%; margin-top: 1%; width: 100%; - .title { + .edit-text { margin-bottom: 2%; margin-left: auto; margin-right: auto; @@ -1300,36 +1300,13 @@ section.slider-block { .edit-form { display: flex; background: $background-color; + border: 1px solid $border-color; flex-direction: column; min-height: 345px; - // padding: 25px; + padding: 25px; } } //edit form ends - - //address form - .address-form-content { - padding: 0px 25px; - margin-left: 5.5%; - margin-top: 1%; - width: 100%; - - .title { - margin-bottom: 2%; - margin-left: auto; - margin-right: auto; - font-size: 24px; - } - - .address-form { - display: flex; - background: $background-color; - flex-direction: column; - min-height: 345px; - // padding: 25px; - } - } - //address form ends } //account ends here //customers page css ends here diff --git a/packages/Webkul/Shop/src/Resources/views/home/index.blade.php b/packages/Webkul/Shop/src/Resources/views/home/index.blade.php index 1b87d248e..0a895c627 100644 --- a/packages/Webkul/Shop/src/Resources/views/home/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/index.blade.php @@ -8,6 +8,6 @@ @include('shop::home.featured-products') @include('shop::home.new-products') - + @include('shop::home.news-updates') @endsection diff --git a/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php b/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php index f2028fbd1..a6d56c3b1 100644 --- a/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/new-products.blade.php @@ -1,6 +1,5 @@