diff --git a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php index 686a82463..4f666f839 100644 --- a/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/catalog/products/edit.blade.php @@ -7,7 +7,7 @@ @section('content')
get('locale') ?: app()->getLocale(); ?> - get('channel') ?: core()->getCurrentChannelCode(); ?> + get('channel') ?: core()->getDefaultChannelCode(); ?>
diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php index be13b1fd1..0ba206483 100644 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeFamilyTableSeeder.php @@ -31,10 +31,10 @@ class AttributeFamilyTableSeeder extends Seeder 'code' => 'url_key', 'position' => 3 ], [ - 'code' => 'new_from', + 'code' => 'new', 'position' => 4 ], [ - 'code' => 'new_to', + 'code' => 'featured', 'position' => 5 ], [ 'code' => 'visible_individually', diff --git a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php index 1833eaa12..fa7c1f887 100644 --- a/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php +++ b/packages/Webkul/Attribute/src/Database/Seeders/AttributeTableSeeder.php @@ -56,12 +56,12 @@ class AttributeTableSeeder extends Seeder 'is_configurable' => 0, 'is_user_defined' => 0 ], [ - 'code' => 'new_from', - 'admin_name' => 'New From', + 'code' => 'new', + 'admin_name' => 'New', 'en' => [ - 'name' => 'New From' + 'name' => 'New' ], - 'type' => 'datetime', + 'type' => 'boolean', 'position' => 4, 'is_required' => 0, 'value_per_locale' => 0, @@ -70,12 +70,12 @@ class AttributeTableSeeder extends Seeder 'is_configurable' => 0, 'is_user_defined' => 0 ], [ - 'code' => 'new_to', - 'admin_name' => 'New To', + 'code' => 'featured', + 'admin_name' => 'Featured', 'en' => [ - 'name' => 'New To' + 'name' => 'Featured' ], - 'type' => 'datetime', + 'type' => 'boolean', 'position' => 5, 'is_required' => 0, 'value_per_locale' => 0, diff --git a/packages/Webkul/Checkout/src/Cart.php b/packages/Webkul/Checkout/src/Cart.php index 2bcae6c20..cda729e0e 100644 --- a/packages/Webkul/Checkout/src/Cart.php +++ b/packages/Webkul/Checkout/src/Cart.php @@ -109,25 +109,11 @@ class Cart { } } + $child = $childData = null; if($product->type == 'configurable') { //Check if the product is salable $child = $this->product->findOneByField('id', $data['selected_configurable_option']); - $parentData = [ - 'sku' => $product->sku, - 'product_id' => $productId, - 'quantity' => $data['quantity'], - 'type' => 'configurable', - 'name' => $product->name, - 'price' => ($price = $child->price), //This should be price from the price helper - 'base_price' => $price, - 'total' => $price * $data['quantity'], - 'base_total' => $price * $data['quantity'], - 'weight' => ($weight = $child->weight), - 'total_weight' => $weight * $data['quantity'], - 'base_total_weight' => $weight * $data['quantity'], - ]; - //child row data $childData = [ 'product_id' => $data['selected_configurable_option'], @@ -136,33 +122,31 @@ class Cart { 'type' => $child->type, 'name' => $child->name ]; - - return ['parent' => $parentData, 'child' => $childData]; - } else { - $parentData = [ - 'sku' => $product->sku, - 'product_id' => $productId, - 'quantity' => $data['quantity'], - 'type' => 'simple', - 'name' => $product->name, - 'price' => $product->price, - 'base_price' => $product->price, - 'total' => $product->price * $data['quantity'], - 'base_total' => $product->price * $data['quantity'], - 'weight' => $product->weight, - 'total_weight' => $product->weight * $data['quantity'], - 'base_total_weight' => $product->weight * $data['quantity'], - ]; - - return ['parent' => $parentData, 'child' => null]; } + + $parentData = [ + 'sku' => $product->sku, + 'product_id' => $productId, + 'quantity' => $data['quantity'], + 'type' => $product->type, + 'name' => $product->name, + 'price' => $price = ($product->type == 'configurable' ? $child->price : $product->price), + 'base_price' => $price, + 'total' => $price * $data['quantity'], + 'base_total' => $price * $data['quantity'], + 'weight' => $weight = ($product->type == 'configurable' ? $child->weight : $product->weight), + 'total_weight' => $weight * $data['quantity'], + 'base_total_weight' => $weight * $data['quantity'] + ]; + + return ['parent' => $parentData, 'child' => $childData]; } /** * Create new cart instance with the current item success. * * @param integer $id - * @param array $data + * @param array $data * * @return Response */ @@ -175,72 +159,83 @@ class Cart { //auth user details else they will be set when the customer is guest if(auth()->guard('customer')->check()) { $cartData['customer_id'] = auth()->guard('customer')->user()->id; - $cartData['is_guest'] = 0; - $cartData['customer_first_name'] = auth()->guard('customer')->user()->first_name; - $cartData['customer_last_name'] = auth()->guard('customer')->user()->last_name; + $cartData['customer_email'] = auth()->guard('customer')->user()->email; } else { $cartData['is_guest'] = 1; } $cartData['items_count'] = 1; - $cartData['items_qty'] = $data['quantity']; if($cart = $this->cart->create($cartData)) { $itemData['parent']['cart_id'] = $cart->id; + $product = $this->product->find($id); - if ($this->product->find($id)->type == "configurable") { + if ($product->type == "configurable") { //parent item entry $itemData['parent']['additional'] = json_encode($data); - if($parent = $this->cartItem->create($itemData['parent'])) { + if($parent = $this->cartItem->create($itemData['parent'])) { //child item entry $itemData['child']['parent_id'] = $parent->id; $itemData['child']['cart_id'] = $cart->id; + if($child = $this->cartItem->create($itemData['child'])) { - session()->put('cart', $cart); + $this->putCart($cart); session()->flash('success', trans('shop::app.checkout.cart.item.success')); $this->collectTotals(); - return redirect()->back(); + return $cart; } } - } else if($this->product->find($id)->type != "configurable") { - if($result = $this->cartItem->create($itemData['parent'])) { - session()->put('cart', $cart); + } else if($product->type != "configurable") { + if($this->cartItem->create($itemData['parent'])) { + $this->putCart($cart); session()->flash('success', trans('shop::app.checkout.cart.item.success')); $this->collectTotals(); - return redirect()->back(); + return $cart; } } } session()->flash('error', trans('shop::app.checkout.cart.item.error_add')); - return redirect()->back(); + return false; + } + + /** + * Save cart + * + * @return mixed + */ + public function putCart($cart) + { + if(!auth()->guard('customer')->check()) { + session()->put('cart', $cart); + } } /** * Returns cart * - * @return Mixed + * @return mixed */ public function getCart() { $cart = null; - if(session()->has('cart')) { - $cart = $this->cart->find(session()->get('cart')->id); - } else if(auth()->guard('customer')->check()) { + if(auth()->guard('customer')->check()) { $cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id); + } elseif(session()->has('cart')) { + $cart = $this->cart->find(session()->get('cart')->id); } return $cart && $cart->is_active ? $cart : null; @@ -276,38 +271,26 @@ class Cart { */ public function canAddOrUpdate($itemId, $quantity) { - $item = $this->cartItem->findOneByField('id', $itemId); - - $inventories = $item->product->inventories; - - $inventory_sources = $item->product->inventory_sources; - - $totalQty = 0; - - foreach($inventory_sources as $inventory_source) { - if($inventory_source->status && $inventory_source->toArray()['pivot']['qty']) { - $totalQty = $totalQty + $inventory_source->toArray()['pivot']['qty']; - } - } - if ($quantity < 1) { session()->flash('warning', trans('shop::app.checkout.cart.quantity.warning')); return redirect()->back(); } - if($quantity <= $totalQty) { + $item = $this->cartItem->findOneByField('id', $itemId); + + if($item->product->haveSufficientQuantity($quantity)) { return true; - } else { - return false; } + + return false; } /** * Add Items in a cart with some cart and item details. * - * @param @id - * @param $data + * @param integer $id + * @param array $data * * @return void */ @@ -315,14 +298,14 @@ class Cart { { $itemData = $this->prepareItemData($id, $data); - if(session()->has('cart')) { - $cart = $this->getCart(); + if($cart = $this->getCart()) { + $product = $this->product->find($id); - $cartItems = $cart->items()->get(); + $cartItems = $cart->items; - if(isset($cartItems)) { + if($cartItems->count()) { foreach($cartItems as $cartItem) { - if($this->product->find($id)->type == "simple") { + if($product->type == "simple") { if($cartItem->product_id == $id) { $prevQty = $cartItem->quantity; @@ -348,7 +331,7 @@ class Cart { return redirect()->back(); } - } else if($this->product->find($id)->type == "configurable") { + } else if($product->type == "configurable") { if($cartItem->type == "configurable") { $temp = $this->cartItem->findOneByField('parent_id', $cartItem->id); if($temp->product_id == $data['selected_configurable_option']) { @@ -384,17 +367,13 @@ class Cart { } } - if($this->product->find($id)->type == "configurable") { + if($product->type == "configurable") { $parent = $cart->items()->create($itemData['parent']); $itemData['child']['parent_id'] = $parent->id; - // $this->canAddOrUpdate($parent->child->id, $parent->quantity); - $cart->items()->create($itemData['child']); - } else if($this->product->find($id)->type != "configurable"){ - // $this->canAddOrUpdate($parent->id, $parent->quantity); - + } else if($product->type != "configurable"){ $parent = $cart->items()->create($itemData['parent']); } @@ -402,16 +381,16 @@ class Cart { session()->flash('success', trans('shop::app.checkout.cart.item.success')); - return redirect()->back(); + return $cart; } else { if(isset($cart)) { $this->cart->delete($cart->id); } else { - $this->createNewCart($id, $data); + return $this->createNewCart($id, $data); } } } else { - $this->createNewCart($id, $data); + return $this->createNewCart($id, $data); } } @@ -421,9 +400,7 @@ class Cart { */ public function update($itemIds) { - if(session()->has('cart')) { - $cart = $this->getCart(); - + if($cart = $this->getCart()) { $items = $cart->items; foreach($items as $item) { @@ -438,7 +415,7 @@ class Cart { if($canBe == false) { session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning')); - return redirect()->back(); + return $cart; } $item->update(['quantity' => $quantity]); @@ -447,10 +424,11 @@ class Cart { } } } - session()->flash('success', trans('shop::app.checkout.cart.quantity.success')); - return redirect()->back(); + session()->flash('success', trans('shop::app.checkout.cart.quantity.success')); } + + return $cart; } /** @@ -460,49 +438,18 @@ class Cart { */ public function removeItem($itemId) { - if(session()->has('cart')) { - $cart = $this->getCart(); - - $items = $cart->items; - - foreach($items as $item) { - if($item->id == $itemId) { - if($item->type == "configurable") { - $child = $item->child; - - //delete the child first - $result = $this->cartItem->delete($child->id); - if($result) - $result = $this->cartItem->delete($item->id); - - $this->collectTotals(); - } else if($item->type == "simple" && $item->parent_id == null){ - $result = $this->cartItem->delete($item->id); - - $this->collectTotals(); - } - } - } - $countItems = $this->cart->findOneByField('id', $cart->id)->items->count(); + if($cart = $this->getCart()) { + $this->cartItem->delete($itemId); //delete the cart instance if no items are there - if($countItems == 0) { - $result = $this->cart->delete($cart->id); + if($cart->items()->get()->count() == 0) { + $this->cart->delete($cart->id); session()->forget('cart'); - } else { - session()->forget('cart'); - session()->put('cart', $this->cart->findOneByField('id', $cart->id)); - } - - if ($result) { - session()->flash('sucess', trans('shop::app.checkout.cart.quantity.success_remove')); - } else { - session()->flash('error', trans('shop::app.checkout.cart.quantity.error_remove')); + session()->flash('success', trans('shop::app.checkout.cart.quantity.success_remove')); } } - return redirect()->back(); } /** @@ -678,7 +625,7 @@ class Cart { if(session()->has('cart')) { $cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id); - $guestCart = $this->getCart(); + $guestCart = session()->get('cart'); if(!isset($cart)) { $guestCart->update(['customer_id' => auth()->guard('customer')->user()->id, 'is_guest' => 0]); @@ -777,9 +724,6 @@ class Cart { //forget the guest cart instance session()->forget('cart'); - //put the customer cart instance - session()->put('cart', $cart); - $this->collectTotals(); return redirect()->back(); @@ -788,22 +732,6 @@ class Cart { } } - /** - * Destroys the session maintained for cart on customer logout. - * - * @return response - */ - public function destroyCart() - { - if(session()->has('cart')) { - session()->forget('cart'); - - return redirect()->back(); - } else { - return redirect()->back(); - } - } - /** * Checks if cart has any error * diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php index 897b98c4a..02096f95c 100644 --- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php +++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_05_150915_create_cart_items_table.php @@ -48,7 +48,7 @@ class CreateCartItemsTable extends Migration $table->json('additional')->nullable(); $table->integer('product_id')->unsigned(); - $table->foreign('product_id')->references('id')->on('products'); + $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade'); $table->integer('cart_id')->unsigned(); $table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade'); $table->integer('tax_category_id')->unsigned()->nullable(); @@ -57,7 +57,7 @@ class CreateCartItemsTable extends Migration }); Schema::table('cart_items', function (Blueprint $table) { - $table->foreign('parent_id')->references('id')->on('cart_items'); + $table->foreign('parent_id')->references('id')->on('cart_items')->onDelete('cascade'); }); } diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_092845_create_cart_address.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_092845_create_cart_address.php index 1e5f9f6c6..b0825103a 100644 --- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_092845_create_cart_address.php +++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_092845_create_cart_address.php @@ -29,7 +29,7 @@ class CreateCartAddress extends Migration $table->integer('cart_id')->nullable()->unsigned(); $table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade'); $table->integer('customer_id')->nullable()->unsigned(); - $table->foreign('customer_id')->references('id')->on('customers'); + $table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade'); $table->timestamps(); }); } diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php index 89ab7fd4d..5a175add1 100644 --- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php +++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php @@ -18,7 +18,7 @@ class CreateCartPayment extends Migration $table->string('method'); $table->string('method_title')->nullable(); $table->integer('cart_id')->nullable()->unsigned(); - $table->foreign('cart_id')->references('id')->on('cart'); + $table->foreign('cart_id')->references('id')->on('cart')->onDelete('cascade'); $table->timestamps(); }); } diff --git a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php index 2565b846d..9588f961b 100644 --- a/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php +++ b/packages/Webkul/Checkout/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php @@ -23,7 +23,7 @@ class CreateCartShippingRatesTable extends Migration $table->double('price')->default(0)->nullable(); $table->double('base_price')->default(0)->nullable(); $table->integer('cart_address_id')->nullable()->unsigned(); - $table->foreign('cart_address_id')->references('id')->on('cart_address'); + $table->foreign('cart_address_id')->references('id')->on('cart_address')->onDelete('cascade'); $table->timestamps(); }); } diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php index 716f842df..7d84c73f9 100644 --- a/packages/Webkul/Core/src/Core.php +++ b/packages/Webkul/Core/src/Core.php @@ -84,6 +84,34 @@ class Core return ($channel = $this->getCurrentChannel()) ? $channelCode = $channel->code : ''; } + /** + * Returns default channel models + * + * @return mixed + */ + public function getDefaultChannel() { + static $channel; + + if($channel) + return $channel; + + return $channel = ChannelModel::first(); + } + + /** + * Returns default channel code + * + * @return string + */ + public function getDefaultChannelCode() { + static $channelCode; + + if($channelCode) + return $channelCode; + + return ($channel = $this->getDefaultChannel()) ? $channelCode = $channel->code : ''; + } + /** * Returns all locales * diff --git a/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php b/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php index 5bc939083..3aff35c82 100644 --- a/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php +++ b/packages/Webkul/Core/src/Http/Controllers/TaxCategoryController.php @@ -24,14 +24,6 @@ class TaxCategoryController extends Controller */ protected $_config; - /** - * Contains the current - * channel. - * - * @var string - */ - protected $currentChannelId; - /** * Tax Rule Repository object * @@ -49,8 +41,6 @@ class TaxCategoryController extends Controller { $this->middleware('admin'); - $this->currentChannelId = core()->getCurrentChannel()->id; - $this->taxRule = $taxRule; $this->taxRate = $taxRate; diff --git a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php index 306b40d0e..262ee3e9e 100644 --- a/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/WishlistController.php @@ -47,7 +47,10 @@ class WishlistController extends Controller * Displays the listing resources if the customer having items in wishlist. */ public function index() { - $wishlists = $this->wishlist->findWhere(['channel_id' => core()->getCurrentChannel()->id,'customer_id' => auth()->guard('customer')->user()->id]); + $wishlists = $this->wishlist->findWhere([ + 'channel_id' => core()->getCurrentChannel()->id, + 'customer_id' => auth()->guard('customer')->user()->id] + ); $wishlistItems = array(); diff --git a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php index ff92b9051..f5b395c62 100644 --- a/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php +++ b/packages/Webkul/Customer/src/Http/Listeners/CustomerEventsHandler.php @@ -12,30 +12,14 @@ class CustomerEventsHandler { public function onCustomerLogin($event) { /** - * handle the user login - * event to manage the - * after login, if - * the user has added any - * products as guest then - * the cart items from session - * will be transferred from - * cookie to the cart table - * in the database. + * handle the user login event to manage the after login, if the user has added any products as guest then + * the cart items from session will be transferred from cookie to the cart table in the database. * - * Check whether cookie is - * present or not and then - * check emptiness and then - * do the appropriate actions. + * Check whether cookie is present or not and then check emptiness and then do the appropriate actions. */ Cart::mergeCart(); } - //Customer Logout Event Handler. - public function onCustomerLogout($event) - { - Cart::destroyCart(); - } - /** * Register the listeners for the subscriber. * @@ -45,7 +29,5 @@ class CustomerEventsHandler { public function subscribe($events) { $events->listen('customer.after.login', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogin'); - - $events->listen('customer.after.logout', 'Webkul\Customer\Http\Listeners\CustomerEventsHandler@onCustomerLogout'); } } \ No newline at end of file diff --git a/packages/Webkul/Product/src/Contracts/Criteria/FeaturedProductsCriteria.php b/packages/Webkul/Product/src/Contracts/Criteria/FeaturedProductsCriteria.php new file mode 100644 index 000000000..d27474bab --- /dev/null +++ b/packages/Webkul/Product/src/Contracts/Criteria/FeaturedProductsCriteria.php @@ -0,0 +1,49 @@ +attribute = $attribute; + } + + /** + * Apply criteria in query repository + * + * @param string $model + * @param RepositoryInterface $repository + * + * @return mixed + */ + public function apply($model, RepositoryInterface $repository) + { + $attribute = $this->attribute->findOneByField('code', 'featured'); + + $model = $model->leftJoin('product_attribute_values as filter_featured', 'products.id', '=', 'filter_featured.product_id'); + + $model->where('filter_featured.boolean_value', 1) + ->where('filter_featured.attribute_id', $attribute->id); + + return $model; + } +} diff --git a/packages/Webkul/Product/src/Contracts/Criteria/NewProductsCriteria.php b/packages/Webkul/Product/src/Contracts/Criteria/NewProductsCriteria.php new file mode 100644 index 000000000..72ee4c9d4 --- /dev/null +++ b/packages/Webkul/Product/src/Contracts/Criteria/NewProductsCriteria.php @@ -0,0 +1,49 @@ +attribute = $attribute; + } + + /** + * Apply criteria in query repository + * + * @param string $model + * @param RepositoryInterface $repository + * + * @return mixed + */ + public function apply($model, RepositoryInterface $repository) + { + $attribute = $this->attribute->findOneByField('code', 'new'); + + $model = $model->leftJoin('product_attribute_values as filter_new', 'products.id', '=', 'filter_new.product_id'); + + $model->where('filter_new.boolean_value', 1) + ->where('filter_new.attribute_id', $attribute->id); + + return $model; + } +} diff --git a/packages/Webkul/Product/src/Models/Product.php b/packages/Webkul/Product/src/Models/Product.php index b6a910fd5..223bcad22 100644 --- a/packages/Webkul/Product/src/Models/Product.php +++ b/packages/Webkul/Product/src/Models/Product.php @@ -185,27 +185,7 @@ class Product extends Model $attributeModel = $this->attribute_family->custom_attributes()->where('attributes.code', $key)->first(); - if($attributeModel) { - $channel = request()->get('channel') ?: core()->getCurrentChannelCode(); - - $locale = request()->get('locale') ?: app()->getLocale(); - - if($attributeModel->value_per_channel) { - if($attributeModel->value_per_locale) { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('locale', $locale)->where('attribute_id', $attributeModel->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('attribute_id', $attributeModel->id)->first(); - } - } else { - if($attributeModel->value_per_locale) { - $attributeValue = $this->attribute_values()->where('locale', $locale)->where('attribute_id', $attributeModel->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('attribute_id', $attributeModel->id)->first(); - } - } - - $this->attributes[$key] = $attributeValue[ProductAttributeValue::$attributeTypeFields[$attributeModel->type]]; - } + $this->attributes[$key] = $this->getCustomAttributeValue($attributeModel); return $this->getAttributeValue($key); } @@ -225,36 +205,49 @@ class Product extends Model $hiddenAttributes = $this->getHidden(); if(isset($this->id)) { - $channel = request()->get('channel') ?: core()->getCurrentChannelCode(); - - $locale = request()->get('locale') ?: app()->getLocale(); - foreach ($this->attribute_family->custom_attributes as $attribute) { if (in_array($attribute->code, $hiddenAttributes)) { continue; } - if($attribute->value_per_channel) { - if($attribute->value_per_locale) { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('channel', $channel)->where('attribute_id', $attribute->id)->first(); - } - } else { - if($attribute->value_per_locale) { - $attributeValue = $this->attribute_values()->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); - } else { - $attributeValue = $this->attribute_values()->where('attribute_id', $attribute->id)->first(); - } - } - - $attributes[$attribute->code] = $attributeValue[ProductAttributeValue::$attributeTypeFields[$attribute->type]]; + $attributes[$attribute->code] = $this->getCustomAttributeValue($attribute); } } return $attributes; } + /** + * Get an product attribute value. + * + * @return mixed + */ + public function getCustomAttributeValue($attribute) + { + if(!$attribute) + return; + + $channel = request()->get('channel') ?: core()->getDefaultChannelCode(); + + $locale = request()->get('locale') ?: app()->getLocale(); + + if($attribute->value_per_channel) { + if($attribute->value_per_locale) { + $attributeValue = $this->attribute_values()->where('channel', $channel)->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); + } else { + $attributeValue = $this->attribute_values()->where('channel', $channel)->where('attribute_id', $attribute->id)->first(); + } + } else { + if($attribute->value_per_locale) { + $attributeValue = $this->attribute_values()->where('locale', $locale)->where('attribute_id', $attribute->id)->first(); + } else { + $attributeValue = $this->attribute_values()->where('attribute_id', $attribute->id)->first(); + } + } + + return $attributeValue[ProductAttributeValue::$attributeTypeFields[$attribute->type]]; + } + /** * Overrides the default Eloquent query builder * diff --git a/packages/Webkul/Product/src/Product/Review.php b/packages/Webkul/Product/src/Product/Review.php index a092ec606..dd14117fd 100644 --- a/packages/Webkul/Product/src/Product/Review.php +++ b/packages/Webkul/Product/src/Product/Review.php @@ -37,21 +37,10 @@ class Review extends AbstractProduct return $product->reviews()->where('status', 'approved')->count(); } - /** - * Returns the formated created at date - * - * @param ProductReview $review - * @return integer - */ - public function formatDate($reviewCreatedAt) - { - return core()->formatDate($reviewCreatedAt, 'd, M Y'); - } - /** * Returns the total rating of the product * - * @param Product $product + * @param Product $product * @return integer */ public function getTotalRating($product) diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 1a5b92783..c770749a8 100644 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -14,6 +14,8 @@ use Webkul\Product\Contracts\Criteria\SortCriteria; use Webkul\Product\Contracts\Criteria\AttributeToSelectCriteria; use Webkul\Product\Contracts\Criteria\FilterByAttributesCriteria; use Webkul\Product\Contracts\Criteria\FilterByCategoryCriteria; +use Webkul\Product\Contracts\Criteria\NewProductsCriteria; +use Webkul\Product\Contracts\Criteria\FeaturedProductsCriteria; use Illuminate\Database\Eloquent\ModelNotFoundException; /** @@ -423,4 +425,54 @@ class ProductRepository extends Repository get_class($this->model), $slug ); } + + /** + * Returns newly added product + * + * @return Collection + */ + public function getNewProducts() + { + $this->pushCriteria(app(NewProductsCriteria::class)); + $this->pushCriteria(app(AttributeToSelectCriteria::class)->addAttribueToSelect([ + 'name', + 'description', + 'short_description', + 'price', + 'special_price', + 'special_price_from', + 'special_price_to' + ])); + + $params = request()->input(); + + return $this->scopeQuery(function($query) { + return $query->distinct()->addSelect('products.*')->orderBy('id', 'desc'); + })->paginate(4, ['products.id']); + } + + /** + * Returns featured product + * + * @return Collection + */ + public function getFeaturedProducts() + { + $this->pushCriteria(app(FeaturedProductsCriteria::class)); + $this->pushCriteria(app(AttributeToSelectCriteria::class)->addAttribueToSelect([ + 'name', + 'description', + 'short_description', + 'price', + 'special_price', + 'special_price_from', + 'special_price_to' + ])); + + $params = request()->input(); + + return $this->scopeQuery(function($query) { + return $query->distinct()->addSelect('products.*')->orderBy('id', 'desc'); + })->paginate(4, ['products.id']); + } } \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Http/Controllers/CartController.php b/packages/Webkul/Shop/src/Http/Controllers/CartController.php index 30f4a4635..d3a66910d 100644 --- a/packages/Webkul/Shop/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Shop/src/Http/Controllers/CartController.php @@ -13,10 +13,8 @@ use Webkul\Product\Product\View as ProductView; use Cart; /** - * Cart controller for the customer - * and guest users for adding and - * removing the products in the - * cart. + * Cart controller for the customer and guest users for adding and + * removing the products in the cart. * * @author Prashant Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) @@ -25,9 +23,7 @@ class CartController extends Controller { /** - * Protected Variables that - * holds instances of the - * repository classes. + * Protected Variables that holds instances of the repository classes. * * @param Array $_config * @param $cart @@ -85,9 +81,7 @@ class CartController extends Controller } /** - * Function for guests - * user to add the product - * in the cart. + * Function for guests user to add the product in the cart. * * @return Mixed */ @@ -101,8 +95,7 @@ class CartController extends Controller } /** - * Removes the item from - * the cart if it exists + * Removes the item from the cart if it exists * * @param integer $itemId */ @@ -113,8 +106,7 @@ class CartController extends Controller } /** - * Updates the quantity of the - * items present in the cart. + * Updates the quantity of the items present in the cart. * * @return response */ diff --git a/packages/Webkul/Shop/src/Http/ViewComposers/Categories/CategoryComposer.php b/packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php similarity index 68% rename from packages/Webkul/Shop/src/Http/ViewComposers/Categories/CategoryComposer.php rename to packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php index 8d6b07511..c4885ea34 100644 --- a/packages/Webkul/Shop/src/Http/ViewComposers/Categories/CategoryComposer.php +++ b/packages/Webkul/Shop/src/Http/ViewComposers/CategoryComposer.php @@ -1,10 +1,9 @@ * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ - class CategoryComposer { /** @@ -36,13 +34,20 @@ class CategoryComposer $this->category = $category; } + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ public function compose(View $view) { - $collected_cat = array(); - $categories = $this->category->getCategoryTree(); - foreach ($categories as $category) { - array_push($collected_cat, collect($category)); + $categories = []; + + foreach ($this->category->getCategoryTree() as $category) { + array_push($categories, collect($category)); } - $view->with('categories', $collected_cat); + + $view->with('categories', $categories); } } diff --git a/packages/Webkul/Shop/src/Http/ViewComposers/FeaturedProductListComposer.php b/packages/Webkul/Shop/src/Http/ViewComposers/FeaturedProductListComposer.php new file mode 100644 index 000000000..64dd9d8d1 --- /dev/null +++ b/packages/Webkul/Shop/src/Http/ViewComposers/FeaturedProductListComposer.php @@ -0,0 +1,47 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class FeaturedProductListComposer +{ + /** + * ProductRepository object + * + * @var array + */ + protected $product; + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function __construct(Product $product) + { + $this->product = $product; + } + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function compose(View $view) + { + $products = $this->product->getFeaturedProducts(); + + $view->with('products', $products); + } +} diff --git a/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php b/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php new file mode 100644 index 000000000..08410cfd7 --- /dev/null +++ b/packages/Webkul/Shop/src/Http/ViewComposers/NewProductListComposer.php @@ -0,0 +1,47 @@ + + * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) + */ +class NewProductListComposer +{ + /** + * ProductRepository object + * + * @var array + */ + protected $product; + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function __construct(Product $product) + { + $this->product = $product; + } + + /** + * Bind data to the view. + * + * @param View $view + * @return void + */ + public function compose(View $view) + { + $products = $this->product->getNewProducts(); + + $view->with('products', $products); + } +} diff --git a/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php b/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php index fb5a97bcc..0accfe8c1 100644 --- a/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php +++ b/packages/Webkul/Shop/src/Providers/ComposerServiceProvider.php @@ -17,17 +17,19 @@ class ComposerServiceProvider extends ServiceProvider */ public function boot() { - //using the class based composers... - View::composer(['shop::layouts.header.index', 'shop::layouts.footer.footer'], 'Webkul\Shop\Http\ViewComposers\Categories\CategoryComposer'); - } + View::composer( + ['shop::layouts.header.index', 'shop::layouts.footer.footer'], + 'Webkul\Shop\Http\ViewComposers\CategoryComposer' + ); - /** - * Register the service provider. - * - * @return void - */ - public function register() - { - // + View::composer( + ['shop::home.new-products'], + 'Webkul\Shop\Http\ViewComposers\NewProductListComposer' + ); + + View::composer( + ['shop::home.featured-products'], + 'Webkul\Shop\Http\ViewComposers\FeaturedProductListComposer' + ); } -} +} \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue b/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue index e38dc943f..52961aa19 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue +++ b/packages/Webkul/Shop/src/Resources/assets/js/components/category-item.vue @@ -2,7 +2,11 @@
  • {{ this.item['translations'][0].name }}  -
      + + + +
        + \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue b/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue index 9be108eb3..baeaeffd3 100644 --- a/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue +++ b/packages/Webkul/Shop/src/Resources/assets/js/components/category-nav.vue @@ -17,10 +17,8 @@ + \ No newline at end of file diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss index c39f42f4f..89e9ef472 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss @@ -213,10 +213,6 @@ section.slider-block { margin-bottom: 21px; user-select: none; - .search-suggestion { - display: none; - } - .header-top { margin-bottom: 16px; display: flex; @@ -421,7 +417,6 @@ section.slider-block { } } } - ul.right-responsive { display: none; @@ -478,6 +473,10 @@ section.slider-block { position: relative; } + .nav li > .icon{ + display: none; + } + .nav { vertical-align: top; display: inline-block; @@ -498,10 +497,15 @@ section.slider-block { margin-bottom: 1px; } + .nav > li > a .icon{ + display: none; + } + .nav > li:last-child { display:flex; align-items:center; border-radius: 0 0 4px 0; float:right; + display: none; img { margin-right:6px; @@ -560,9 +564,45 @@ section.slider-block { right: 10px; } } + + .search-responsive { + display: none; + + .search-content { + border-bottom: 1px solid #e8e8e8; + height: 48px; + + .search { + width: 70%; + margin-left: 20px; + height: 30px; + border: none; + font-size: 16px; + position: absolute; + } + + .right { + float: right; + } + + .suggestion { + position: absolute; + margin-left:20px; + } + } + + .search-content:first-child { + border-top: 1px solid #e8e8e8; + } + } + + .responsive-nav { + display: none; + } } @media all and (max-width: 720px) { + .header-bottom { display: none !important; } @@ -583,6 +623,47 @@ section.slider-block { display: flex !important; } + .responsive-nav { + margin-top: 20px; + display: none; + + .nav a { + display:inline-block; + color: $font-color; + text-decoration: none; + padding: 12px 4.8px 12px 8px; + text-transform: uppercase; + letter-spacing: 2px; + position: relative; + width: 90%; + } + + .nav li > .icon{ + float: right; + } + + .nav li a > .icon{ + display: none; + } + + .nav > li { + border-bottom: 1px solid $border-color; + } + + .nav li:first-child { + border-top: 1px solid $border-color; + } + + .nav > li:last-child { + float:none; + height: 45px; + display: none; + + img { + margin-right:6px; + } + } + } } //footer responsive with out media query. @@ -1001,6 +1082,26 @@ section.product-detail { div.product-image-group { margin-right: 30px; + width: 604px; + height: 650px; + max-width: 604px; + + .loader { + border: 16px solid #f3f3f3; + border-top: 16px solid #3498db; + border-radius: 50%; + width: 50px; + height: 50px; + animation: spin 2s linear infinite; + margin-left: 20%; + position: absolute; + margin-top: 200px; + } + + @keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } + } div { display: flex; @@ -1010,17 +1111,17 @@ section.product-detail { display: flex; flex-direction: column; margin-right: 4px; - height: 480px; min-width: 120px; overflow: hidden; position: relative; justify-content: flex-start; + max-height: 480px; .thumb-frame { border: 2px solid transparent; background: #F2F2F2; width: 120px; - height: 120px; + max-height: 120px; &.active { border-color: #979797; @@ -1069,52 +1170,65 @@ section.product-detail { background: #F2F2F2; width: 100%; max-height: 480px; + height: 100%; img { width: 100%; - height: 480px; + height: auto; max-height: 480px; } - .wishlist-icon { - position: absolute; - height: 32px; - width: 32px; - top: 15px; - right: 15px; + .whishlist-icon { + margin-top: -480px; + float: right; + margin-right: 10px; } .share-icon { + margin-top: -480px; + float: right; + margin-right: 40px; + } + + .wishlist { position: absolute; - height: 32px; - width: 32px; - top: 15px; - right: 48px; + top: 10px; + right: 12px; + } + + .share { + position: absolute; + top: 10px; + right: 45px; } } } + .add-to-buttons { - display: flex; + display: none; flex-direction: row; margin-top: 10px; + justify-content: space-between; .addtocart { border-radius: 0px; width: 49%; background: black; + white-space: nowrap; } .buynow { border-radius: 0px; width: 49%; float:right; + white-space: nowrap; } } } .details { - width: 47.5%; + width: 50%; .product-price { margin-bottom: 14px; @@ -1190,6 +1304,76 @@ section.product-detail { } // product pages css ends here +// product pages responsive css start here +@media only screen and (max-width: 720px){ + section.product-detail div.layouter form { + flex-direction: column; + + div.product-image-group { + margin-right: 0px; + max-width: none; + width: auto; + + .loader { + margin-left: 47%; + } + + div { + flex-direction: column-reverse; + + .thumb-list { + height: 120px; + margin-top: 5px; + flex-direction: row; + overflow-x: scroll; + margin-right: 0px; + + .thumb-frame { + + img { + height: 100%; + width: auto; + } + } + + .gallery-control { + display: none; + } + } + + .product-hero-image{ + display: flex; + + img { + margin-left: auto; + margin-right: auto; + width: 480px; + } + } + } + } + + .details { + width: 100%; + margin-top: 20px; + } + } +} + +@media only screen and (max-width: 510px){ + + section.product-detail div.layouter form { + + div.product-image-group { + + .product-hero-image img { + width: 100% !important; + } + } + } +} +//product pages responsive css end here + //rating and reviews of product pages .rating-reviews { @@ -1364,11 +1548,7 @@ section.cart { .towishlist { color : $brand-color; } - } - .error-message { - color: #ff5656; - margin-top: 17px; } } } @@ -1608,17 +1788,8 @@ section.cart { } // checkout ends here -.order-success-content { - padding: 40px 0; - - .btn { - display: inline-block; - } -} - // checkout responsive start here @media only screen and (max-width: 770px) { - .checkout-process { .col-main { width: 100%; @@ -1650,7 +1821,6 @@ section.cart { display: none; } } - } // checkout responsive end here @@ -1900,3 +2070,4 @@ section.review { } // customer section css end here + diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss index dea756ecb..ba1aa8d3f 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss @@ -13,8 +13,8 @@ .icon-menu-close { background-image:URL('../images/icon-menu-close.svg'); - width: 8px; - height: 8px; + width: 24px; + height: 24px; margin-left:auto; margin-bottom: 2px; } diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/override.scss b/packages/Webkul/Shop/src/Resources/assets/sass/override.scss index b3aac40d3..884cebc8d 100644 --- a/packages/Webkul/Shop/src/Resources/assets/sass/override.scss +++ b/packages/Webkul/Shop/src/Resources/assets/sass/override.scss @@ -71,6 +71,10 @@ body { //margin-top +.mt-5 { + margin-top: 5px; +} + .mt-10 { margin-top: 10px; } @@ -299,4 +303,5 @@ body { width: 100%; float: none; padding-right: 0px; -} \ No newline at end of file +} + diff --git a/packages/Webkul/Shop/src/Resources/lang/en/app.php b/packages/Webkul/Shop/src/Resources/lang/en/app.php index 2aa802a9f..1b26b6bbf 100644 --- a/packages/Webkul/Shop/src/Resources/lang/en/app.php +++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php @@ -1,6 +1,10 @@ [ + 'featured-products' => 'Featured Products', + 'new-products' => 'New Products' + ], 'customer' => [ 'signup-text' => [ 'account_exists' => 'Already have an account', diff --git a/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php b/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php index 09f2262e6..6fe603bb1 100644 --- a/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/home/featured-products.blade.php @@ -1,31 +1,21 @@ - +@endif \ No newline at end of file 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 84eefb109..e1ac27d3b 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,92 +1,21 @@ - +@endif 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 8ff8dca40..907840536 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 @@ -284,13 +284,172 @@
      {{--
    • --}} - +
  • - @include('shop::layouts.header.nav-menu.navmenu') + @include('shop::layouts.header.nav-menu.navmenu')
    - \ No newline at end of file +
    +
    + + + +
    + +
    + + Designer sarees +
    +
    + +
    + +
    + + + + + +@push('scripts') + + + +@endpush + diff --git a/packages/Webkul/Shop/src/Resources/views/products/index.blade.php b/packages/Webkul/Shop/src/Resources/views/products/index.blade.php index 50be3f6b3..672238048 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/index.blade.php @@ -54,48 +54,5 @@ @stop -@push('scripts') - -@endpush diff --git a/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php b/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php index 880f46a3c..eeae1ad03 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/reviews/index.blade.php @@ -104,7 +104,7 @@ {{ __('shop::app.products.by', ['name' => $review->customer->name]) }} - {{ $reviewHelper->formatDate($review->created_at) }} + {{ core()->formatDate($review->created_at) }} diff --git a/packages/Webkul/Shop/src/Resources/views/products/view.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view.blade.php index dcec1ea95..9fd492848 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view.blade.php @@ -80,3 +80,4 @@ @endsection + diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php index 40ecc4717..63ea3288d 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/gallery.blade.php @@ -3,9 +3,17 @@
    +
    +
    + + @include ('shop::products.product-add') +
    + + + @push('scripts') diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/reviews.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/reviews.blade.php index f877278f7..8fc334b12 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view/reviews.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/reviews.blade.php @@ -60,7 +60,7 @@ - {{ $reviewHelper->formatDate($review->created_at) }} + {{ core()->formatDate($review->created_at) }} diff --git a/packages/Webkul/Shop/src/Resources/views/products/view/up-sells.blade.php b/packages/Webkul/Shop/src/Resources/views/products/view/up-sells.blade.php index e9b561e75..64f4aaa14 100644 --- a/packages/Webkul/Shop/src/Resources/views/products/view/up-sells.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/products/view/up-sells.blade.php @@ -7,7 +7,7 @@
    - + @foreach ($product->up_sells()->paginate(4) as $up_sell_product) @include ('shop::products.list.card', ['product' => $up_sell_product]) diff --git a/packages/Webkul/Ui/src/DataGrid/ProductGrid.php b/packages/Webkul/Ui/src/DataGrid/ProductGrid.php index 47be52540..0a35ee711 100644 --- a/packages/Webkul/Ui/src/DataGrid/ProductGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/ProductGrid.php @@ -200,7 +200,7 @@ class ProductGrid public function __construct(AttributeRepository $attributes) { - $this->channel = request()->get('channel') ?: core()->getCurrentChannelCode(); + $this->channel = request()->get('channel') ?: core()->getDefaultChannelCode(); $this->locale = request()->get('locale') ?: app()->getLocale(); $this->attributes = $attributes; diff --git a/public/themes/default/assets/css/shop.css b/public/themes/default/assets/css/shop.css index 162f941e2..494f20b4d 100644 --- a/public/themes/default/assets/css/shop.css +++ b/public/themes/default/assets/css/shop.css @@ -13,8 +13,8 @@ .icon-menu-close { background-image: URL("../images/icon-menu-close.svg"); - width: 8px; - height: 8px; + width: 24px; + height: 24px; margin-left: auto; margin-bottom: 2px; } @@ -341,6 +341,10 @@ body { margin-bottom: 90px; } +.mt-5 { + margin-top: 5px; +} + .mt-10 { margin-top: 10px; } @@ -750,10 +754,6 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { user-select: none; } -.header .search-suggestion { - display: none; -} - .header .header-top { margin-bottom: 16px; display: -webkit-box; @@ -1078,6 +1078,10 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { position: relative; } +.header .header-bottom .nav li > .icon { + display: none; +} + .header .header-bottom .nav { vertical-align: top; display: inline-block; @@ -1097,6 +1101,10 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { margin-bottom: 1px; } +.header .header-bottom .nav > li > a .icon { + display: none; +} + .header .header-bottom .nav > li:last-child { display: -webkit-box; display: -ms-flexbox; @@ -1106,6 +1114,7 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { align-items: center; border-radius: 0 0 4px 0; float: right; + display: none; } .header .header-bottom .nav > li:last-child img { @@ -1162,6 +1171,41 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { right: 10px; } +.header .search-responsive { + display: none; +} + +.header .search-responsive .search-content { + border-bottom: 1px solid #e8e8e8; + height: 48px; +} + +.header .search-responsive .search-content .search { + width: 70%; + margin-left: 20px; + height: 30px; + border: none; + font-size: 16px; + position: absolute; +} + +.header .search-responsive .search-content .right { + float: right; +} + +.header .search-responsive .search-content .suggestion { + position: absolute; + margin-left: 20px; +} + +.header .search-responsive .search-content:first-child { + border-top: 1px solid #e8e8e8; +} + +.header .responsive-nav { + display: none; +} + @media all and (max-width: 720px) { .header-bottom { display: none !important; @@ -1180,6 +1224,40 @@ section.slider-block div.slider-content div.slider-control .light-right-icon { display: -ms-flexbox !important; display: flex !important; } + .responsive-nav { + margin-top: 20px; + display: none; + } + .responsive-nav .nav a { + display: inline-block; + color: #242424; + text-decoration: none; + padding: 12px 4.8px 12px 8px; + text-transform: uppercase; + letter-spacing: 2px; + position: relative; + width: 90%; + } + .responsive-nav .nav li > .icon { + float: right; + } + .responsive-nav .nav li a > .icon { + display: none; + } + .responsive-nav .nav > li { + border-bottom: 1px solid #E8E8E8; + } + .responsive-nav .nav li:first-child { + border-top: 1px solid #E8E8E8; + } + .responsive-nav .nav > li:last-child { + float: none; + height: 45px; + display: none; + } + .responsive-nav .nav > li:last-child img { + margin-right: 6px; + } } .footer { @@ -1616,6 +1694,44 @@ section.product-detail div.layouter form { section.product-detail div.layouter form div.product-image-group { margin-right: 30px; + width: 604px; + height: 650px; + max-width: 604px; +} + +section.product-detail div.layouter form div.product-image-group .loader { + border: 16px solid #f3f3f3; + border-top: 16px solid #3498db; + border-radius: 50%; + width: 50px; + height: 50px; + -webkit-animation: spin 2s linear infinite; + animation: spin 2s linear infinite; + margin-left: 20%; + position: absolute; + margin-top: 200px; +} + +@-webkit-keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@keyframes spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } } section.product-detail div.layouter form div.product-image-group div { @@ -1637,20 +1753,20 @@ section.product-detail div.layouter form div.product-image-group div .thumb-list -ms-flex-direction: column; flex-direction: column; margin-right: 4px; - height: 480px; min-width: 120px; overflow: hidden; position: relative; -webkit-box-pack: start; -ms-flex-pack: start; justify-content: flex-start; + max-height: 480px; } section.product-detail div.layouter form div.product-image-group div .thumb-list .thumb-frame { border: 2px solid transparent; background: #F2F2F2; width: 120px; - height: 120px; + max-height: 120px; } section.product-detail div.layouter form div.product-image-group div .thumb-list .thumb-frame.active { @@ -1698,55 +1814,67 @@ section.product-detail div.layouter form div.product-image-group div .product-he background: #F2F2F2; width: 100%; max-height: 480px; + height: 100%; } section.product-detail div.layouter form div.product-image-group div .product-hero-image img { width: 100%; - height: 480px; + height: auto; max-height: 480px; } -section.product-detail div.layouter form div.product-image-group div .product-hero-image .wishlist-icon { - position: absolute; - height: 32px; - width: 32px; - top: 15px; - right: 15px; +section.product-detail div.layouter form div.product-image-group div .product-hero-image .whishlist-icon { + margin-top: -480px; + float: right; + margin-right: 10px; } section.product-detail div.layouter form div.product-image-group div .product-hero-image .share-icon { + margin-top: -480px; + float: right; + margin-right: 40px; +} + +section.product-detail div.layouter form div.product-image-group div .product-hero-image .wishlist { position: absolute; - height: 32px; - width: 32px; - top: 15px; - right: 48px; + top: 10px; + right: 12px; +} + +section.product-detail div.layouter form div.product-image-group div .product-hero-image .share { + position: absolute; + top: 10px; + right: 45px; } section.product-detail div.layouter form div.product-image-group .add-to-buttons { - display: -webkit-box; - display: -ms-flexbox; - display: flex; + display: none; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; margin-top: 10px; + -webkit-box-pack: justify; + -ms-flex-pack: justify; + justify-content: space-between; } section.product-detail div.layouter form div.product-image-group .add-to-buttons .addtocart { border-radius: 0px; width: 49%; background: black; + white-space: nowrap; } section.product-detail div.layouter form div.product-image-group .add-to-buttons .buynow { border-radius: 0px; width: 49%; float: right; + white-space: nowrap; } section.product-detail div.layouter form .details { - width: 47.5%; + width: 50%; } section.product-detail div.layouter form .details .product-price { @@ -1816,6 +1944,66 @@ section.product-detail div.layouter form .details .attributes { border-bottom: solid 1px rgba(162, 162, 162, 0.2); } +@media only screen and (max-width: 720px) { + section.product-detail div.layouter form { + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + } + section.product-detail div.layouter form div.product-image-group { + margin-right: 0px; + max-width: none; + width: auto; + } + section.product-detail div.layouter form div.product-image-group .loader { + margin-left: 47%; + } + section.product-detail div.layouter form div.product-image-group div { + -webkit-box-orient: vertical; + -webkit-box-direction: reverse; + -ms-flex-direction: column-reverse; + flex-direction: column-reverse; + } + section.product-detail div.layouter form div.product-image-group div .thumb-list { + height: 120px; + margin-top: 5px; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -ms-flex-direction: row; + flex-direction: row; + overflow-x: scroll; + margin-right: 0px; + } + section.product-detail div.layouter form div.product-image-group div .thumb-list .thumb-frame img { + height: 100%; + width: auto; + } + section.product-detail div.layouter form div.product-image-group div .thumb-list .gallery-control { + display: none; + } + section.product-detail div.layouter form div.product-image-group div .product-hero-image { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + } + section.product-detail div.layouter form div.product-image-group div .product-hero-image img { + margin-left: auto; + margin-right: auto; + width: 480px; + } + section.product-detail div.layouter form .details { + width: 100%; + margin-top: 20px; + } +} + +@media only screen and (max-width: 510px) { + section.product-detail div.layouter form div.product-image-group .product-hero-image img { + width: 100% !important; + } +} + .rating-reviews .rating-header { font-weight: 600; padding: 20px 0; @@ -2017,11 +2205,6 @@ section.cart .cart-content .right-side { color: #0041FF; } -.cart-item-list .item .item-details .error-message { - color: #ff5656; - margin-top: 17px; -} - .order-summary h3 { font-size: 16px; margin-top: 0; @@ -2252,14 +2435,6 @@ section.cart .cart-content .right-side { padding-left: 40px; } -.order-success-content { - padding: 40px 0; -} - -.order-success-content .btn { - display: inline-block; -} - @media only screen and (max-width: 770px) { .checkout-process .col-main { width: 100%; diff --git a/public/themes/default/assets/js/shop.js b/public/themes/default/assets/js/shop.js index c51a232d6..268ddbaa4 100644 --- a/public/themes/default/assets/js/shop.js +++ b/public/themes/default/assets/js/shop.js @@ -30701,10 +30701,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); // // - // define the item component /* harmony default export */ __webpack_exports__["default"] = ({ - props: { categories: { type: [Array, String, Object], @@ -30715,14 +30713,12 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); }, url: String }, - data: function data() { return { items_count: 0 }; }, - computed: { items: function items() { return JSON.parse(this.categories); @@ -30846,27 +30842,41 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); // // // - +// +// +// +// // define the item component - /* harmony default export */ __webpack_exports__["default"] = ({ props: { item: Object, url: String }, - data: function data() { return { - items_count: 0 + items_count: 0, + show: false }; }, + mounted: function mounted() { + if (window.innerWidth > 770) { + this.show = true; + } + }, + computed: { haveChildren: function haveChildren() { return this.item.children.length ? true : false; } + }, + + methods: { + showOrHide: function showOrHide() { + this.show = !this.show; + } } }); @@ -30886,7 +30896,18 @@ var render = function() { : _vm._e() ]), _vm._v(" "), - _vm.haveChildren + _vm.haveChildren || _vm.item.parent_id == null + ? _c("i", { + class: [ + _vm.show + ? "icon arrow-down-icon mt-15" + : "icon dropdown-right-icon mt-15" + ], + on: { click: _vm.showOrHide } + }) + : _vm._e(), + _vm._v(" "), + _vm.haveChildren && _vm.show ? _c( "ul", _vm._l(_vm.item.children, function(child, index) {