diff --git a/composer.json b/composer.json
index ec0706a90..7fe23c407 100644
--- a/composer.json
+++ b/composer.json
@@ -42,7 +42,8 @@
"webkul/laravel-shop": "self.version",
"webkul/laravel-theme": "self.version",
"webkul/laravel-shipping": "self.version",
- "webkul/laravel-payment": "self.version"
+ "webkul/laravel-payment": "self.version",
+ "webkul/laravel-sales": "self.version"
},
"autoload": {
"classmap": [
@@ -64,7 +65,8 @@
"Webkul\\Product\\": "packages/Webkul/Product/src",
"Webkul\\Theme\\": "packages/Webkul/Theme/src",
"Webkul\\Shipping\\": "packages/Webkul/Shipping/src",
- "Webkul\\Payment\\": "packages/Webkul/Payment/src"
+ "Webkul\\Payment\\": "packages/Webkul/Payment/src",
+ "Webkul\\Sales\\": "packages/Webkul/Sales/src"
}
},
"autoload-dev": {
diff --git a/config/app.php b/config/app.php
index c649dc388..56e8a7b5a 100644
--- a/config/app.php
+++ b/config/app.php
@@ -191,6 +191,7 @@ return [
Webkul\Cart\Providers\CartServiceProvider::class,
Webkul\Shipping\Providers\ShippingServiceProvider::class,
Webkul\Payment\Providers\PaymentServiceProvider::class,
+ Webkul\Sales\Providers\SalesServiceProvider::class,
],
/*
diff --git a/config/carriers.php b/config/carriers.php
index ca9253b71..030b22f1c 100644
--- a/config/carriers.php
+++ b/config/carriers.php
@@ -9,6 +9,14 @@ return [
'default_rate' => '10',
'type' => 'per_unit',
'class' => 'Webkul\Shipping\Carriers\FlatRate',
+ ],
+
+ 'free' => [
+ 'code' => 'free',
+ 'title' => 'Free Shipping',
+ 'description' => 'This is a free shipping',
+ 'active' => true,
+ 'class' => 'Webkul\Shipping\Carriers\Free',
]
];
diff --git a/packages/Webkul/Admin/src/Resources/views/settings/channels/edit.blade.php b/packages/Webkul/Admin/src/Resources/views/settings/channels/edit.blade.php
index dd6b2da91..085b83936 100644
--- a/packages/Webkul/Admin/src/Resources/views/settings/channels/edit.blade.php
+++ b/packages/Webkul/Admin/src/Resources/views/settings/channels/edit.blade.php
@@ -65,17 +65,17 @@
@{{ errors.first('locales[]') }}
-
+
{{ __('admin::app.settings.channels.default-locale') }}
default_locale_id ?>
-
+
@foreach(core()->getAllLocales() as $locale)
id ? 'selected' : '' }}>
{{ $locale->name }}
@endforeach
- @{{ errors.first('default_locale') }}
+ @{{ errors.first('default_locale_id') }}
@@ -91,17 +91,17 @@
@{{ errors.first('currencies[]') }}
-
+
{{ __('admin::app.settings.channels.base-currency') }}
base_currency_id ?>
-
+
@foreach(core()->getAllCurrencies() as $currency)
id ? 'selected' : '' }}>
{{ $currency->name }}
@endforeach
- @{{ errors.first('base_currency') }}
+ @{{ errors.first('base_currency_id') }}
diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php
index 21ef0a103..e2d810f48 100644
--- a/packages/Webkul/Cart/src/Cart.php
+++ b/packages/Webkul/Cart/src/Cart.php
@@ -3,108 +3,309 @@
namespace Webkul\Cart;
use Carbon\Carbon;
-
use Webkul\Cart\Repositories\CartRepository;
use Webkul\Cart\Repositories\CartItemRepository;
-
+use Webkul\Cart\Repositories\CartAddressRepository;
use Webkul\Customer\Repositories\CustomerRepository;
-
use Webkul\Product\Repositories\ProductRepository;
-
+use Webkul\Cart\Models\CartPayment;
use Cookie;
/**
- * Facade for all
- * the methods to be
- * implemented in Cart.
+ * Facade for all the methods to be implemented in Cart.
*
* @author Prashant Singh
+ * @author Jitendra Singh
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class Cart {
- protected $cart; //cart repository instance
+ /**
+ * CartRepository model
+ *
+ * @var mixed
+ */
+ protected $cart;
- protected $cartItem; //cart_item repository instance
+ /**
+ * CartItemRepository model
+ *
+ * @var mixed
+ */
+ protected $cartItem;
- protected $customer; //customer repository instance
+ /**
+ * CustomerRepository model
+ *
+ * @var mixed
+ */
+ protected $customer;
- protected $product; //product repository instance
+ /**
+ * CartAddressRepository model
+ *
+ * @var mixed
+ */
+ protected $cartAddress;
- public function __construct(CartRepository $cart,
- CartItemRepository $cartItem,
- CustomerRepository $customer,
- ProductRepository $product) {
+ /**
+ * ProductRepository model
+ *
+ * @var mixed
+ */
+ protected $product;
+ /**
+ * Create a new controller instance.
+ *
+ * @param Webkul\Cart\Repositories\CartRepository $cart
+ * @param Webkul\Cart\Repositories\CartItemRepository $cartItem
+ * @param Webkul\Cart\Repositories\CartAddressRepository $cartAddress
+ * @param Webkul\Customer\Repositories\CustomerRepository $customer
+ * @param Webkul\Product\Repositories\ProductRepository $product
+ * @return void
+ */
+ public function __construct(
+ CartRepository $cart,
+ CartItemRepository $cartItem,
+ CartAddressRepository $cartAddress,
+ CustomerRepository $customer,
+ ProductRepository $product)
+ {
$this->customer = $customer;
$this->cart = $cart;
$this->cartItem = $cartItem;
+ $this->cartAddress = $cartAddress;
+
$this->product = $product;
}
- /**
- * Create new cart
- * instance with the
- * current item added.
+ /**
+ * Method to check if the product is available and its required quantity
+ * is available or not in the inventory sources.
*
- * @param Integer $id
- * @param Mixed $data
+ * @param integer $id
*
- * @return Mixed
+ * @return Array
*/
- public function createNewCart($id, $data) {
+ public function canCheckOut($id) {
+ $cart = $this->cart->findOneByField('id', 144);
+
+ $items = $cart->items;
+
+ $allProdQty = array();
+
+ $allProdQty1 = array();
+
+ $totalQty = 0;
+
+ foreach($items as $item) {
+ $inventories = $item->product->inventories;
+
+ $inventory_sources = $item->product->inventory_sources;
+
+ $totalQty = 0;
+
+ foreach($inventory_sources as $inventory_source) {
+ if($inventory_source->status!=0) {
+ foreach($inventories as $inventory) {
+ $totalQty = $totalQty + $inventory->qty;
+ }
+
+ array_push($allProdQty1, $totalQty);
+
+ $allProdQty[$item->product->id] = $totalQty;
+ }
+ }
+ }
+
+ foreach ($items as $item) {
+ $inventories = $item->product->inventory_sources->where('status', '=', '1');
+
+ foreach($inventories as $inventory) {
+ dump($inventory->status);
+ }
+ }
+
+ dd($allProdQty);
+
+ dd([true, false]);
+ }
+
+ /**
+ * Create new cart instance with the current item added.
+ *
+ * @param integer $id
+ * @param array $data
+ *
+ * @return Response
+ */
+ public function createNewCart($id, $data)
+ {
+ $itemData = $this->prepareItemData($id, $data);
+
+ // dd($itemData);
+
$cartData['channel_id'] = core()->getCurrentChannel()->id;
+ // this will auto set the customer id for the cart instances if customer is authenticated
if(auth()->guard('customer')->check()) {
$cartData['customer_id'] = auth()->guard('customer')->user()->id;
+ $cartData['is_guest'] = 1;
+
$cartData['customer_full_name'] = auth()->guard('customer')->user()->first_name .' '. auth()->guard('customer')->user()->last_name;
}
+ $cartData['items_count'] = 1;
+
+ $cartData['items_quantity'] = $data['quantity'];
+
if($cart = $this->cart->create($cartData)) {
- $data['cart_id'] = $cart->id;
- $data['product_id'] = $id;
+ $itemData['parent']['cart_id'] = $cart->id;
if ($data['is_configurable'] == "true") {
- $temp = $data['super_attribute'];
+ //parent product entry
+ $itemData['parent']['additional'] = json_encode($data);
+ if($parent = $this->cartItem->create($itemData['parent'])) {
- unset($data['super_attribute']);
+ $itemData['child']['parent_id'] = $parent->id;
+ if($child = $this->cartItem->create($itemData['child'])) {
+ session()->put('cart', $cart);
- $data['additional'] = json_encode($temp);
- }
+ session()->flash('success', 'Item Added To Cart Successfully');
- if($result = $this->cartItem->create($data)) {
- session()->put('cart', $cart);
+ return redirect()->back();
+ }
+ }
- session()->flash('success', 'Item Added To Cart Successfully');
+ } else if($data['is_configurable'] == "false") {
+ if($result = $this->cartItem->create($itemData['parent'])) {
+ session()->put('cart', $cart);
- return redirect()->back();
+ session()->flash('success', 'Item Added To Cart Successfully');
+
+ return redirect()->back();
+ }
}
}
- session()->flash('error', 'Some error occured');
+
+ session()->flash('error', 'Some Error Occured');
return redirect()->back();
}
/**
- * Add Items in a
- * cart with some
- * cart and item
- * details.
+ * Prepare the other data for the product to be added.
+ *
+ * @param integer $id
+ * @param array $data
+ *
+ * @return array
+ */
+ public function prepareItemData($productId, $data)
+ {
+ $product = $this->product->findOneByField('id', $productId);
+
+ unset($data['_token']);
+
+ //Check if the product is salable
+ if(!isset($data['product']) ||!isset($data['quantity'])) {
+ session()->flash('error', 'Cart System Integrity Violation, Some Required Fields Missing.');
+
+ dd('Missing Essential Parameters, Cannot Proceed Further');
+
+ return redirect()->back();
+ } else {
+ if($product->type == 'configurable' && !isset($data['super_attribute'])) {
+ session()->flash('error', 'Cart System Integrity Violation, Configurable Options Not Found In Request.');
+
+ dd('Super Attributes Missing From the Request Parameters.');
+
+ return redirect()->back();
+ }
+ }
+
+ 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 shoulf final price
+ 'base_price' => $price,
+ 'item_total' => $price * $data['quantity'],
+ 'base_item_total' => $price * $data['quantity'],
+ 'weight' => ($weight = $child->weight),
+ 'item_weight' => $weight * $parentData['quantity'],
+ 'base_item_weight' => $weight * $parentData['quantity'],
+ ];
+
+
+
+ $parentData['base_item_weight'] = $parentData['weight'] * $parentData['quantity'];
+
+ //child row data
+ $childData['product_id'] = $data['selected_configurable_option'];
+
+ $childData['quantity'] = 1;
+
+ $childData['sku'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->sku;
+
+ $childData['type'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->type;
+
+ $childData['name'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->name;
+
+ return ['parent' => $parentData, 'child' => $childData];
+ } else {
+ $data['product_id'] = $productId;
+ unset($data['product']);
+
+ $data['type'] = 'simple';
+
+ $data['name'] = $this->product->findOneByField('id', $productId)->name;
+
+ $data['price'] = $this->product->findOneByField('id', $productId)->price;
+
+ $data['base_price'] = $data['price'];
+
+ $data['item_total'] = $data['price'] * $data['quantity'];
+
+ $data['base_item_total'] = $data['price'] * $data['quantity'];
+
+ $data['weight'] = $this->product->findOneByField('id', $productId)->weight;
+
+ $data['item_weight'] = $data['weight'] * $data['quantity'];
+
+ $data['base_item_weight'] = $data['weight'] * $data['quantity'];
+
+ return ['parent' => $data, 'child' => null];
+ }
+ }
+
+ /**
+ * Add Items in a cart with some cart and item details.
*
* @param @id
* @param $data
*
- * @return Mixed
+ * @return void
*/
- public function add($id, $data) {
-
+ public function add($id, $data)
+ {
// session()->forget('cart');
+
// return redirect()->back();
+ $itemData = $this->prepareItemData($id, $data);
+
if(session()->has('cart')) {
$cart = session()->get('cart');
@@ -112,34 +313,53 @@ class Cart {
if(isset($cartItems)) {
foreach($cartItems as $cartItem) {
- if($cartItem->product_id == $id) {
- $prevQty = $cartItem->quantity;
+ if($data['is_configurable'] == "false") {
- $newQty = $data['quantity'];
+ if($cartItem->product_id == $id) {
+ $prevQty = $cartItem->quantity;
- $cartItem->update(['quantity' => $prevQty + $newQty]);
+ $newQty = $data['quantity'];
- session()->flash('success', "Product Quantity Successfully Updated");
+ $cartItem->update(['quantity' => $prevQty + $newQty]);
- return redirect()->back();
+ session()->flash('success', "Product Quantity Successfully Updated");
+
+ return redirect()->back();
+ }
+ } else if($data['is_configurable'] == "true") {
+
+ //check the parent and child records that holds info abt this product.
+ if($cartItem->product_id == $data['selected_configurable_option']) {
+ $child = $cartItem;
+
+ $parentId = $child->parent_id;
+
+ $parent = $this->cartItem->findOneByField('id', $parentId);
+
+ $parentPrice = $parent->price;
+
+ $prevQty = $parent->quantity;
+
+ $newQty = $data['quantity'];
+
+ $parent->update(['quantity' => $prevQty + $newQty, 'item_total' => $parentPrice * ($prevQty + $newQty)]);
+
+ session()->flash('success', "Product Quantity Successfully Updated");
+
+ return redirect()->back();
+ }
}
}
- $data['cart_id'] = $cart->id;
+ $parent = $cart->items()->create($itemData['parent']);
- $data['product_id'] = $id;
+ $itemData['child']['parent_id'] = $parent->id;
- if ($data['is_configurable'] == "true") {
- $temp = $data['super_attribute'];
-
- unset($data['super_attribute']);
-
- $data['additional'] = json_encode($temp);
- }
-
- $cart->items()->create($data);
+ $cart->items()->create($itemData['child']);
session()->flash('success', 'Item Successfully Added To Cart');
+
+ return redirect()->back();
} else {
if(isset($cart)) {
$this->cart->delete($cart->id);
@@ -153,26 +373,24 @@ class Cart {
}
/**
- * use detach to remove the
- * current product from cart tables
+ * Use detach to remove the current product from cart tables
*
* @param Integer $id
* @return Mixed
*/
- public function remove($id) {
+ public function remove($id)
+ {
dd("Removing Item from Cart");
}
/**
- * This function handles
- * when guest has some of
- * cart products and then
- * logs in.
+ * This function handles when guest has some of cart products and then logs in.
*
- * @return Redirect
+ * @return Response
*/
- public function mergeCart() {
+ public function mergeCart()
+ {
if(session()->has('cart')) {
$cart = session()->get('cart');
@@ -184,29 +402,66 @@ class Cart {
$customerCartItems = $this->cart->items($customerCart['id']);
if(isset($customerCart)) {
- foreach($customerCartItems as $customerCartItem) {
+ foreach($cartItems as $key => $cartItem) {
+ // foreach($customerCartItems as $customerCartItem) {
- foreach($cartItems as $key => $cartItem) {
+ // // dd($customerCartItems, $cartItems[0]->parent_id);
- if($cartItem->product_id == $customerCartItem->product_id) {
+ // if($cartItem->type == "simple" && $cartItem->parent_id == "null") {
+ // if($customerCartItem->type == "simple" && $customerCartItem->parent_id == "null") {
+ // //update the customer cart item details and delete the guest instance
- $customerItemQuantity = $customerCartItem->quantity;
+ // if($customerCartItem->product_id == $cartItem->productId) {
- $cartItemQuantity = $cartItem->quantity;
+ // $prevQty = $cartItem->quantity;
+ // $newQty = $customerCartItem->quantity;
- $customerCartItem->update(['cart_id' => $customerCart->id, 'quantity' => $cartItemQuantity + $customerItemQuantity]);
+ // $customerCartItem->update([
+ // 'quantity' => $prevQty + $newQty,
+ // 'item_total' => $customerCartItem->price * ($prevQty + $newQty),
+ // 'base_item_total' => $customerCartItem->price * ($prevQty + $newQty),
+ // 'item_total_weight' => $customerCartItem->weight * ($prevQty + $newQty),
+ // 'base_item_total_weight' => $customerCartItem->weight * ($prevQty + $newQty)
+ // ]);
- $this->cartItem->delete($cartItem->id);
+ // $cartItems->forget($key);
+ // }
+ // }
- $cartItems->forget($key);
- }
- }
+ // } else if($cartItem->type == "simple" && $cartItem->parent_id != "null") {
+
+ // if($customerCartItem->type == "simple" && $customerCartItem->parent_id != "null") {
+ // //guest cartParent
+ // $cartItemParentId = $cartItem->parent_id;
+ // $cartItemParent = $this->cartItem->findOneByField('id', $cartItemParentId);
+
+ // //customer cartParent
+ // $customerItemParentId = $customerCartItem->parent_id;
+ // $customerItemParent = $this->cartItem->findOneByField('id', $customerItemParentId);
+
+ // if($cartItem->product_id == $customerCartItem->product_id) {
+ // $cartItemQuantity = $cartItemParent->quantity;
+
+ // $customerCartItemQuantity = $customerItemParent->quantity;
+
+ // $customerCartItem->update([
+ // 'quantity' => $cartItemQuantity + $customerCartItemQuantity,
+ // 'item_total' => $customerItemParent->price * ($cartItemQuantity + $customerCartItemQuantity),
+ // 'base_item_total' => $customerItemParent->price * ($cartItemQuantity + $customerCartItemQuantity),
+ // 'item_total_weight' => $customerItemParent->weight * ($cartItemQuantity + $customerCartItemQuantity),
+ // 'base_item_total_weight' => $customerItemParent->weight * ($cartItemQuantity + $customerCartItemQuantity),
+ // ]);
+
+ // $cartItems->forget($key);
+ // }
+ // }
+ // }
+ // }
}
foreach($cartItems as $cartItem) {
- $cartItem->update(['cart_id' => $customerCart->id]);
+ $cartItem->update(['cart_id' => $customerCart['id']]);
}
-
$this->cart->delete($cart->id);
return redirect()->back();
@@ -222,4 +477,174 @@ class Cart {
return redirect()->back();
}
}
+
+ /**
+ * Destroys the session
+ * maintained for cart
+ * on customer logout.
+ *
+ * @return Mixed
+ */
+ public function destroyCart() {
+ if(session()->has('cart')) {
+ session()->forget('cart');
+ return redirect()->back();
+ }
+ }
+
+ /**
+ * Returns cart
+ *
+ * @return Mixed
+ */
+ public function getCart()
+ {
+ if(!$cart = session()->get('cart'))
+ return false;
+
+ return $this->cart->find($cart->id);
+ }
+
+ /**
+ * Returns cart
+ *
+ * @return Mixed
+ */
+ public function getItemAttributeOptionDetails($item)
+ {
+ $data = [];
+
+ foreach($item->product->super_attributes as $attribute) {
+ $option = $attribute->options()->where('id', $item->child->{$attribute->code})->first();
+
+ $data['attributes'][$attribute->code] = [
+ 'attribute_name' => $attribute->name,
+ 'option_label' => $option->label,
+ ];
+ }
+
+ return $data;
+ }
+
+ /**
+ * Save customer address
+ *
+ * @return Mixed
+ */
+ public function saveCustomerAddress($data)
+ {
+ if(!$cart = $this->getCart())
+ return false;
+
+ $billingAddress = $data['billing'];
+ $shippingAddress = $data['shipping'];
+ $billingAddress['cart_id'] = $shippingAddress['cart_id'] = $cart->id;
+
+ if($billingAddressModel = $cart->biling_address) {
+ $this->cartAddress->update($billingAddress, $billingAddressModel->id);
+
+ if($shippingAddress = $cart->shipping_address) {
+ if(isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
+ $this->cartAddress->update($billingAddress, $shippingAddress->id);
+ } else {
+ $this->cartAddress->update($shippingAddress, $shippingAddress->id);
+ }
+ } else {
+ if(isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
+ $this->cartAddress->create(array_merge($billingAddress, ['address_type' => 'shipping']));
+ } else {
+ $this->cartAddress->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
+ }
+ }
+ } else {
+ $this->cartAddress->create(array_merge($billingAddress, ['address_type' => 'billing']));
+
+ if(isset($billingAddress['use_for_shipping']) && $billingAddress['use_for_shipping']) {
+ $this->cartAddress->create(array_merge($billingAddress, ['address_type' => 'shipping']));
+ } else {
+ $this->cartAddress->create(array_merge($shippingAddress, ['address_type' => 'shipping']));
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Save shipping method for cart
+ *
+ * @param string $shippingMethodCode
+ * @return Mixed
+ */
+ public function saveShippingMethod($shippingMethodCode)
+ {
+ if(!$cart = $this->getCart())
+ return false;
+
+ $cart->shipping_method = $shippingMethodCode;
+ $cart->save();
+
+ // foreach($cart->shipping_rates as $rate) {
+ // if($rate->method != $shippingMethodCode) {
+ // $rate->delete();
+ // }
+ // }
+
+ return true;
+ }
+
+ /**
+ * Save payment method for cart
+ *
+ * @param string $payment
+ * @return Mixed
+ */
+ public function savePaymentMethod($payment)
+ {
+ if(!$cart = $this->getCart())
+ return false;
+
+ if($cartPayment = $cart->payment)
+ $cartPayment->delete();
+
+ $cartPayment = new CartPayment;
+
+ $cartPayment->method = $payment['method'];
+ $cartPayment->cart_id = $cart->id;
+ $cartPayment->save();
+
+ return $cartPayment;
+ }
+
+ /**
+ * Updates cart totals
+ *
+ * @return void
+ */
+ public function collectTotals()
+ {
+ if(!$cart = $this->getCart())
+ return false;
+
+ $cart->grand_total = 0;
+ $cart->base_grand_total = 0;
+ $cart->sub_total = 0;
+ $cart->base_sub_total = 0;
+ $cart->sub_total_with_discount = 0;
+ $cart->base_sub_total_with_discount = 0;
+
+ foreach ($cart->items()->get() as $item) {
+ $cart->grand_total = (float) $cart->grand_total + $item->price;
+ $cart->base_grand_total = (float) $cart->base_grand_total + $item->base_price;
+
+ $cart->sub_total = (float) $cart->sub_total + $item->price;
+ $cart->base_sub_total = (float) $cart->base_sub_total + $item->base_price;
+ }
+
+ if($shipping = $cart->selected_shipping_rate) {
+ $cart->grand_total = (float) $cart->grand_total + $shipping->price;
+ $cart->base_grand_total = (float) $cart->base_grand_total + $shipping->base_price;
+ }
+
+ $cart->save();
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150444_create_cart_table.php b/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150444_create_cart_table.php
index 9809f692d..c11b69d97 100644
--- a/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150444_create_cart_table.php
+++ b/packages/Webkul/Cart/src/Database/Migrations/2018_09_05_150444_create_cart_table.php
@@ -17,25 +17,27 @@ class CreateCartTable extends Migration
$table->increments('id');
$table->integer('customer_id')->unsigned()->nullable();
$table->foreign('customer_id')->references('id')->on('customers');
- $table->string('session_id')->nullable();
$table->integer('channel_id')->unsigned();
$table->foreign('channel_id')->references('id')->on('channels');
+ $table->string('shipping_method')->nullable();
$table->string('coupon_code')->nullable();
- $table->boolean('is_gift')->nullable();
+ $table->boolean('is_gift')->default(0);
$table->integer('items_count')->nullable();
$table->decimal('items_qty', 12, 4)->nullable();
+ $table->decimal('exchange_rate', 12, 4)->nullable();
$table->string('global_currency_code')->nullable();
$table->string('base_currency_code')->nullable();
$table->string('store_currency_code')->nullable();
$table->string('quote_currency_code')->nullable();
- $table->decimal('grand_total', 12, 4)->nullable();
- $table->decimal('base_grand_total', 12, 4)->nullable();
- $table->decimal('sub_total', 12, 4)->nullable();
- $table->decimal('base_sub_total', 12, 4)->nullable();
- $table->decimal('sub_total_with_discount', 12, 4)->nullable();
- $table->decimal('base_sub_total_with_discount', 12, 4)->nullable();
+ $table->decimal('grand_total', 12, 4)->default(0)->nullable();
+ $table->decimal('base_grand_total', 12, 4)->default(0)->nullable();
+ $table->decimal('sub_total', 12, 4)->default(0)->nullable();
+ $table->decimal('base_sub_total', 12, 4)->default(0)->nullable();
+ $table->decimal('sub_total_with_discount', 12, 4)->default(0)->nullable();
+ $table->decimal('base_sub_total_with_discount', 12, 4)->default(0)->nullable();
$table->string('checkout_method')->nullable();
$table->boolean('is_guest')->nullable();
+ $table->boolean('is_active')->nullable()->default(0);
$table->string('customer_full_name')->nullable();
$table->dateTime('conversion_time')->nullable();
$table->timestamps();
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_items_table.php
index 5fe74cc90..e60bd6dd4 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_items_table.php
@@ -20,20 +20,35 @@ class CreateCartItemsTable extends Migration
$table->integer('quantity')->unsigned()->default(1);
$table->integer('cart_id')->unsigned();
$table->foreign('cart_id')->references('id')->on('cart');
+ $table->string('sku')->nullable();
+ $table->string('type')->nullable();
+ $table->string('name')->nullable();
+ $table->integer('parent_id')->unsigned()->nullable();
$table->integer('tax_category_id')->unsigned()->nullable();
$table->foreign('tax_category_id')->references('id')->on('tax_categories');
$table->string('coupon_code')->nullable();
- $table->decimal('weight', 12,4)->nullable();
- $table->decimal('price', 12,4)->nullable();
- $table->decimal('base_price', 12,4)->nullable();
- $table->decimal('custom_price', 12,4)->nullable();
- $table->decimal('discount_percent', 12,4)->nullable();
- $table->decimal('discount_amount', 12,4)->nullable();
- $table->decimal('base_discount_amount', 12,4)->nullable();
+ $table->decimal('weight', 12,4)->default(1);
+ $table->decimal('item_total_weight', 12,4)->default(0);
+ $table->decimal('base_item_total_weight', 12,4)->default(0);
+ $table->decimal('price', 12,4)->default(1);
+ $table->decimal('item_total', 12,4)->default(0);
+ $table->decimal('base_item_total', 12,4)->default(0);
+ $table->decimal('item_total_with_discount', 12,4)->default(0);
+ $table->decimal('base_item_total_with_discount', 12,4)->default(0);
+ $table->decimal('base_price', 12,4)->default(0);
+ $table->decimal('custom_price', 12,4)->default(0);
+ $table->decimal('discount_percent', 12,4)->default(0);
+ $table->decimal('discount_amount', 12,4)->default(0);
+ $table->decimal('base_discount_amount', 12,4)->default(0);
$table->boolean('no_discount')->nullable()->default(0);
+ $table->boolean('free_shipping')->nullable()->default(0);
$table->json('additional')->nullable();
$table->timestamps();
});
+
+ Schema::table('cart_items', function (Blueprint $table) {
+ $table->foreign('parent_id')->references('id')->on('cart_items');
+ });
}
/**
diff --git a/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_092845_create_cart_address.php b/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_092845_create_cart_address.php
index 070ea4609..2148ccf8f 100644
--- a/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_092845_create_cart_address.php
+++ b/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_092845_create_cart_address.php
@@ -15,6 +15,9 @@ class CreateCartAddress extends Migration
{
Schema::create('cart_address', function (Blueprint $table) {
$table->increments('id');
+ $table->string('first_name');
+ $table->string('last_name');
+ $table->string('email');
$table->string('address1');
$table->string('address2')->nullable();
$table->string('country');
diff --git a/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php b/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php
index 9521ad2b6..89ab7fd4d 100644
--- a/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php
+++ b/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093453_create_cart_payment.php
@@ -16,6 +16,7 @@ class CreateCartPayment extends Migration
Schema::create('cart_payment', function (Blueprint $table) {
$table->increments('id');
$table->string('method');
+ $table->string('method_title')->nullable();
$table->integer('cart_id')->nullable()->unsigned();
$table->foreign('cart_id')->references('id')->on('cart');
$table->timestamps();
diff --git a/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093508_create_cart_shipping.php b/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php
similarity index 70%
rename from packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093508_create_cart_shipping.php
rename to packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php
index 9413012ae..2565b846d 100644
--- a/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093508_create_cart_shipping.php
+++ b/packages/Webkul/Cart/src/Database/Migrations/2018_09_19_093508_create_cart_shipping_rates_table.php
@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
-class CreateCartShipping extends Migration
+class CreateCartShippingRatesTable extends Migration
{
/**
* Run the migrations.
@@ -13,16 +13,15 @@ class CreateCartShipping extends Migration
*/
public function up()
{
- Schema::create('cart_shipping', function (Blueprint $table) {
+ Schema::create('cart_shipping_rates', function (Blueprint $table) {
$table->increments('id');
$table->string('carrier');
$table->string('carrier_title');
$table->string('method');
$table->string('method_title');
$table->string('method_description')->nullable();
- $table->double('price')->nullable();
- $table->integer('cart_id')->nullable()->unsigned();
- $table->foreign('cart_id')->references('id')->on('cart');
+ $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->timestamps();
@@ -36,6 +35,6 @@ class CreateCartShipping extends Migration
*/
public function down()
{
- Schema::dropIfExists('cart_shipping');
+ Schema::dropIfExists('cart_shipping_rates');
}
}
diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Cart/src/Http/Controllers/CartController.php
index a27596180..01a9f145f 100644
--- a/packages/Webkul/Cart/src/Http/Controllers/CartController.php
+++ b/packages/Webkul/Cart/src/Http/Controllers/CartController.php
@@ -4,19 +4,13 @@ namespace Webkul\Cart\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
-
use Webkul\Cart\Repositories\CartRepository;
use Webkul\Cart\Repositories\CartItemRepository;
-
use Webkul\Product\Repositories\ProductRepository;
-
use Webkul\Customer\Repositories\CustomerRepository;
-
use Webkul\Product\Product\ProductImage;
use Webkul\Product\Product\View as ProductView;
-
use Cart;
-use Cookie;
/**
* Cart controller for the customer
@@ -31,9 +25,17 @@ class CartController extends Controller
{
/**
- * Display a listing of the resource.
+ * Protected Variables that
+ * holds instances of the
+ * repository classes.
*
- * @return \Illuminate\Http\Response
+ * @param Array $_config
+ * @param $cart
+ * @param $cartItem
+ * @param $customer
+ * @param $product
+ * @param $productImage
+ * @param $productView
*/
protected $_config;
@@ -47,9 +49,16 @@ class CartController extends Controller
protected $productView;
- public function __construct(CartRepository $cart, CartItemRepository $cartItem, CustomerRepository $customer, ProductRepository $product, ProductImage $productImage, ProductView $productView) {
+ public function __construct(
+ CartRepository $cart,
+ CartItemRepository $cartItem,
+ CustomerRepository $customer,
+ ProductRepository $product,
+ ProductImage $productImage,
+ ProductView $productView
+ ) {
- $this->middleware('customer')->except(['add', 'remove', 'test']);
+ // $this->middleware('customer')->except(['add', 'remove', 'test']);
$this->customer = $customer;
@@ -66,6 +75,19 @@ class CartController extends Controller
$this->_config = request('_config');
}
+ /**
+ * Method to populate
+ * the cart page which
+ * will be populated
+ * before the checkout
+ * process.
+ *
+ * @return Mixed
+ */
+ public function index() {
+ return view($this->_config['view'])->with('cart', Cart::getCart());
+ }
+
/**
* Function for guests
* user to add the product
@@ -75,22 +97,12 @@ class CartController extends Controller
*/
public function add($id) {
+ // session()->forget('cart');
+
+ // return redirect()->back();
+
$data = request()->input();
- if(!isset($data['is_configurable']) || !isset($data['product']) ||!isset($data['quantity'])) {
- session()->flash('error', 'Cannot Product Due to User\'s miscreancy in system\'s integrity');
-
- return redirect()->back();
- }
-
- if($data['is_configurable'] == "false") {
- $data['price'] = $this->product->findOneByField('id', $data['product'])->price;
- } else {
- $id = $data['selected_configurable_option'];
-
- $data['price'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->price;
- }
-
Cart::add($id, $data);
return redirect()->back();
@@ -107,118 +119,6 @@ class CartController extends Controller
return redirect()->back();
}
- /**
- * Method to populate
- * the cart page which
- * will be populated
- * before the checkout
- * process.
- *
- * @return Mixed
- */
- public function beforeCheckout() {
- if(auth()->guard('customer')->check()) {
- $cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
-
- if(isset($cart)) {
- $cart = $this->cart->findOneByField('id', 144);
-
- $cartItems = $this->cart->items($cart['id']);
-
- $products = array();
-
- foreach($cartItems as $cartItem) {
- $image = $this->productImage->getGalleryImages($cartItem->product);
-
- if(isset($image[0]['small_image_url'])) {
- $products[$cartItem->product->id] = [$cartItem->product->name, $cartItem->price, $image[0]['small_image_url'], $cartItem->quantity];
- }
- else {
- $products[$cartItem->product->id] = [$cartItem->product->name, $cartItem->price, 'null', $cartItem->quantity];
- }
-
- }
- }
- } else {
- if(session()->has('cart')) {
- $cart = session()->get('cart');
-
- if(isset($cart)) {
- $cart = $this->cart->findOneByField('id', 144);
-
- $cartItems = $this->cart->items($cart['id']);
-
- $products = array();
-
- foreach($cartItems as $cartItem) {
- $image = $this->productImage->getGalleryImages($cartItem->product);
-
- if(isset($image[0]['small_image_url'])) {
- $products[$cartItem->product->id] = [$cartItem->product->name, $cartItem->price, $image[0]['small_image_url'], $cartItem->quantity];
- }
- else {
- $products[$cartItem->product->id] = [$cartItem->product->name, $cartItem->price, 'null', $cartItem->quantity];
- }
-
- }
- }
- }
- }
-
- return view($this->_config['view'])->with('products', $products);
- }
-
- /**
- * This method will return
- * the quantities from
- * inventory sources whose
- * status are not false.
- *
- * @return Array
- */
- public function canAddOrUpdate() {
- $cart = $this->cart->findOneByField('id', 144);
-
- $items = $cart->items;
-
- $allProdQty = array();
-
- $allProdQty1 = array();
-
- $totalQty = 0;
-
- foreach($items as $item) {
- $inventories = $item->product->inventories;
-
- $inventory_sources = $item->product->inventory_sources;
-
- $totalQty = 0;
- foreach($inventory_sources as $inventory_source) {
-
- if($inventory_source->status!=0) {
- foreach($inventories as $inventory) {
- $totalQty = $totalQty + $inventory->qty;
- }
-
- array_push($allProdQty1, $totalQty);
-
- $allProdQty[$item->product->id] = $totalQty;
- }
-
- }
- }
-
- dd($allProdQty);
-
- foreach ($items as $item) {
- $inventories = $item->product->inventory_sources->where('status', '=', '1');
-
- foreach($inventories as $inventory) {
- dump($inventory->status);
- }
- }
- }
-
public function test() {
$cart = $this->cart->findOneByField('id', 144);
@@ -237,9 +137,17 @@ class CartController extends Controller
else {
$products[$cartItem->product->id] = [$cartItem->product->name, $cartItem->price, 'null', $cartItem->quantity];
}
-
}
-
dd($products);
}
+
+ public function mergeTest() {
+ $cartItems = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id)->items;
+
+ $tempId = 15;
+
+ foreach($cartItems as $cartItem) {
+
+ }
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php b/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php
index 8f8022a0d..d9271ad56 100644
--- a/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php
+++ b/packages/Webkul/Cart/src/Http/Controllers/CheckoutController.php
@@ -43,7 +43,10 @@ class CheckoutController extends Controller
*/
public function index()
{
- return view($this->_config['view']);
+ if(!$cart = Cart::getCart())
+ return redirect()->route('shop.checkout.cart.index');
+
+ return view($this->_config['view'])->with('cart', $cart);
}
/**
@@ -54,11 +57,10 @@ class CheckoutController extends Controller
*/
public function saveAddress(CustomerAddressForm $request)
{
- if(!Cart::saveCustomerAddress(request()->all())) {
- // return response()->json(['redirect_url' => route('store.home')], 403)
- }
+ if(!Cart::saveCustomerAddress(request()->all()) || !$rates = Shipping::collectRates())
+ return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
- return response()->json(Shipping::collectRates());
+ return response()->json($rates);
}
/**
@@ -68,6 +70,13 @@ class CheckoutController extends Controller
*/
public function saveShipping()
{
+ $shippingMethod = request()->get('shipping_method');
+
+ if(!$shippingMethod || !Cart::saveShippingMethod($shippingMethod))
+ return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
+
+ Cart::collectTotals();
+
return response()->json(Payment::getSupportedPaymentMethods());
}
@@ -78,5 +87,16 @@ class CheckoutController extends Controller
*/
public function savePayment()
{
+ $payment = request()->get('payment');
+
+ if(!$payment || !Cart::savePaymentMethod($payment))
+ return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
+
+ $cart = Cart::getCart();
+
+ return response()->json([
+ 'jump_to_section' => 'review',
+ 'html' => view('shop::checkout.onepage.review', compact('cart'))->render()
+ ]);
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php
index d1e88dfbe..f5a4a0b98 100644
--- a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php
+++ b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php
@@ -44,12 +44,12 @@ class CartComposer
}
public function compose(View $view) {
+ // session()->forget('cart');
+ // return redirect()->back();
if(auth()->guard('customer')->check()) {
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
if(isset($cart)) {
- $cart = $this->cart->findOneByField('id', 144);
-
$cartItems = $this->cart->items($cart['id']);
$products = array();
@@ -70,12 +70,8 @@ class CartComposer
$view->with('cart', $products);
}
} else {
- if(session()->has('cart')) {
- $cart = session()->get('cart');
-
+ if($cart = session()->get('cart')) {
if(isset($cart)) {
- $cart = $this->cart->findOneByField('id', 144);
-
$cartItems = $this->cart->items($cart['id']);
$products = array();
diff --git a/packages/Webkul/Cart/src/Http/helpers.php b/packages/Webkul/Cart/src/Http/helpers.php
new file mode 100644
index 000000000..4dea2757c
--- /dev/null
+++ b/packages/Webkul/Cart/src/Http/helpers.php
@@ -0,0 +1,10 @@
+
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Models/Cart.php b/packages/Webkul/Cart/src/Models/Cart.php
index 734897522..ada8f206d 100644
--- a/packages/Webkul/Cart/src/Models/Cart.php
+++ b/packages/Webkul/Cart/src/Models/Cart.php
@@ -4,19 +4,21 @@ namespace Webkul\Cart\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Product\Models\Product;
+use Webkul\Cart\Models\CartItem;
use Webkul\Cart\Models\CartAddress;
-use Webkul\Cart\Models\CartShipping;
+use Webkul\Cart\Models\CartPayment;
+use Webkul\Cart\Models\CartShippingRate;
class Cart extends Model
{
protected $table = 'cart';
- protected $fillable = ['customer_id', 'session_id', 'channel_id', 'coupon_code', 'is_gift', 'global_currency_code', 'base_currency_code', 'store_currency_code', 'quote_currency_code', 'grand_total', 'base_grand_total', 'sub_total', 'base_sub_total', 'sub_total_with_discount', 'base_sub_total_with_discount', 'checkout_method', 'is_guest', 'customer_full_name', 'conversion_time'];
+ protected $fillable = ['customer_id', 'session_id', 'channel_id', 'coupon_code', 'is_gift', 'items_count', 'items_qty', 'exchange_rate', 'global_currency_code', 'base_currency_code', 'store_currency_code', 'quote_currency_code', 'grand_total', 'base_grand_total', 'sub_total', 'base_sub_total', 'sub_total_with_discount', 'base_sub_total_with_discount', 'checkout_method', 'is_guest', 'is_active', 'customer_full_name', 'conversion_time'];
protected $hidden = ['coupon_code'];
public function items() {
- return $this->hasMany('Webkul\Cart\Models\CartItem');
+ return $this->hasMany(CartItem::class)->whereNull('parent_id');
}
/**
@@ -28,10 +30,58 @@ class Cart extends Model
}
/**
- * Get the shipping for the cart.
+ * Get the biling address for the cart.
*/
- public function shipping()
+ public function billing_address()
{
- return $this->hasMany(CartShipping::class);
+ return $this->addresses()->where('address_type', 'billing');
}
-}
+
+ /**
+ * Get all of the attributes for the attribute groups.
+ */
+ public function getBillingAddressAttribute()
+ {
+ return $this->billing_address()->first();
+ }
+
+ /**
+ * Get the shipping address for the cart.
+ */
+ public function shipping_address()
+ {
+ return $this->addresses()->where('address_type', 'shipping');
+ }
+
+ /**
+ * Get all of the attributes for the attribute groups.
+ */
+ public function getShippingAddressAttribute()
+ {
+ return $this->shipping_address()->first();
+ }
+
+ /**
+ * Get the shipping rates for the cart.
+ */
+ public function shipping_rates()
+ {
+ return $this->hasManyThrough(CartShippingRate::class, CartAddress::class, 'cart_id', 'cart_address_id');
+ }
+
+ /**
+ * Get all of the attributes for the attribute groups.
+ */
+ public function getSelectedShippingRateAttribute()
+ {
+ return $this->shipping_rates()->where('method', $this->shipping_method)->first();
+ }
+
+ /**
+ * Get the payment associated with the cart.
+ */
+ public function payment()
+ {
+ return $this->hasOne(CartPayment::class);
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Models/CartAddress.php b/packages/Webkul/Cart/src/Models/CartAddress.php
index 5ecad6830..935b09eb0 100644
--- a/packages/Webkul/Cart/src/Models/CartAddress.php
+++ b/packages/Webkul/Cart/src/Models/CartAddress.php
@@ -3,8 +3,27 @@
namespace Webkul\Cart\Models;
use Illuminate\Database\Eloquent\Model;
+use Webkul\Cart\Models\CartShippingRate;
class CartAddress extends Model
{
-
-}
+ protected $table = 'cart_address';
+
+ protected $fillable = ['first_name', 'last_name', 'email', 'address1', 'address2', 'city', 'state', 'postcode', 'country', 'email', 'phone', 'address_type', 'cart_id'];
+
+ /**
+ * Get the shipping rates for the cart address.
+ */
+ public function shipping_rates()
+ {
+ return $this->hasMany(CartShippingRate::class);
+ }
+
+ /**
+ * Get all of the attributes for the attribute groups.
+ */
+ public function getNameAttribute()
+ {
+ return $this->first_name . ' ' . $this->last_name;
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Models/CartItem.php b/packages/Webkul/Cart/src/Models/CartItem.php
index c54ba0756..f447dfa19 100644
--- a/packages/Webkul/Cart/src/Models/CartItem.php
+++ b/packages/Webkul/Cart/src/Models/CartItem.php
@@ -9,9 +9,25 @@ class CartItem extends Model
{
protected $table = 'cart_items';
- protected $fillable = ['product_id','quantity','cart_id','tax_category_id','coupon_code', 'weight', 'price', 'base_price', 'discount_percent', 'discount_amount', 'base_discount_amount', 'no_discount', 'custom_price', 'additional'];
+ protected $fillable = ['product_id', 'quantity', 'cart_id', 'sku', 'type', 'name', 'parent_id','tax_category_id', 'coupon_code', 'weight', 'item_total_weight', 'base_item_total_weight', 'price', 'item_total', 'item_total_with_discount', 'base_item_total_with_discount', 'base_price', 'custom_price', 'discount_percent', 'discount_amount', 'base_discount_amount', 'no_discount', 'free_shipping', 'additional'];
public function product() {
return $this->hasOne('Webkul\Product\Models\Product', 'id', 'product_id');
}
+
+ /**
+ * Get the phone record associated with the user.
+ */
+ public function parent()
+ {
+ return $this->hasOne(self::class, 'parent_id');
+ }
+
+ /**
+ * Get the phone record associated with the user.
+ */
+ public function child()
+ {
+ return $this->belongsTo(self::class, 'parent_id');
+ }
}
diff --git a/packages/Webkul/Cart/src/Models/CartShipping.php b/packages/Webkul/Cart/src/Models/CartPayment.php
similarity index 52%
rename from packages/Webkul/Cart/src/Models/CartShipping.php
rename to packages/Webkul/Cart/src/Models/CartPayment.php
index fd1cc7f76..1d0487e40 100644
--- a/packages/Webkul/Cart/src/Models/CartShipping.php
+++ b/packages/Webkul/Cart/src/Models/CartPayment.php
@@ -4,7 +4,7 @@ namespace Webkul\Cart\Models;
use Illuminate\Database\Eloquent\Model;
-class CartShipping extends Model
+class CartPayment extends Model
{
-
+ protected $table = 'cart_payment';
}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Models/CartShippingRate.php b/packages/Webkul/Cart/src/Models/CartShippingRate.php
new file mode 100644
index 000000000..edd477695
--- /dev/null
+++ b/packages/Webkul/Cart/src/Models/CartShippingRate.php
@@ -0,0 +1,17 @@
+belongsTo(CartAddress::class);
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Providers/CartServiceProvider.php b/packages/Webkul/Cart/src/Providers/CartServiceProvider.php
index ab3302409..b6438bc9f 100644
--- a/packages/Webkul/Cart/src/Providers/CartServiceProvider.php
+++ b/packages/Webkul/Cart/src/Providers/CartServiceProvider.php
@@ -16,6 +16,8 @@ class CartServiceProvider extends ServiceProvider
public function boot(Router $router)
{
+ include __DIR__ . '/../Http/helpers.php';
+
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$router->aliasMiddleware('admin', RedirectIfNotAdmin::class);
diff --git a/packages/Webkul/Cart/src/Repositories/CartAddressRepository.php b/packages/Webkul/Cart/src/Repositories/CartAddressRepository.php
new file mode 100644
index 000000000..9491aeefa
--- /dev/null
+++ b/packages/Webkul/Cart/src/Repositories/CartAddressRepository.php
@@ -0,0 +1,25 @@
+
+ * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
+ */
+
+class CartAddressRepository extends Repository
+{
+ /**
+ * Specify Model class name
+ *
+ * @return Mixed
+ */
+ function model()
+ {
+ return 'Webkul\Cart\Models\CartAddress';
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Cart/src/Repositories/CartRepository.php b/packages/Webkul/Cart/src/Repositories/CartRepository.php
index 362bad43c..5702461fc 100644
--- a/packages/Webkul/Cart/src/Repositories/CartRepository.php
+++ b/packages/Webkul/Cart/src/Repositories/CartRepository.php
@@ -42,7 +42,6 @@ class CartRepository extends Repository
* @param string $attribute
* @return Mixed
*/
-
public function update(array $data, $id, $attribute = "id")
{
$cart = $this->find($id);
@@ -52,60 +51,6 @@ 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 attach($cart_id, $product_id, $quantity, $price) {
- return $this->model->findOrFail($cart_id)->with_products()->attach($cart_id, ['product_id' => $product_id, 'cart_id' => $cart_id, 'quantity' => $quantity, 'price' => $price]);
- }
-
- /**
- * Create Cart Item
- * Through Cart.
- *
- * @return Collection
- */
- public function createItem($cartId, $data) {
- $cart = $this->model->findOrFail($cartId);
-
- return $cart->items()->create($data);
- }
-
- /**
- * This will update the
- * quantity of product
- * for the customer,
- * in case of merge.
- *
- * @return Mixed
- */
- public function updateRelatedForMerge($cart_id, $product_id, $column, $value) {
- $cart_product = $this->model->findOrFail($cart_id);
-
- return $cart_product->with_products()->updateExistingPivot($product_id, array($column => $value));
- }
-
- /**
- * Update the quantity of
- * previously added item
- * in the cart.
- *
- * @return Mixed
- */
-
- // public function updateRelatedInItems($cartId, $cartItemId, $column, $value) {
-
- // return $this->updateItem($cartId)->syncWithoutDetaching($cartItemId, [$column => $value]);
- // }
-
/**
* Method to detach
* associations.
@@ -121,6 +66,14 @@ class CartRepository extends Repository
return $this->model->destroy($cart_id);
}
+ /**
+ * Used to get items
+ * for cart explicitly,
+ * use cart instance
+ * instead.
+ *
+ * @return Mixed
+ */
public function items($cartId) {
return $this->model->find($cartId)->items;
}
diff --git a/packages/Webkul/Core/src/Core.php b/packages/Webkul/Core/src/Core.php
index 5c2d895c0..2375fc466 100644
--- a/packages/Webkul/Core/src/Core.php
+++ b/packages/Webkul/Core/src/Core.php
@@ -8,6 +8,7 @@ use Webkul\Core\Models\Locale as LocaleModel;
use Webkul\Core\Models\Currency as CurrencyModel;
use Webkul\Core\Models\TaxCategory as TaxCategory;
use Webkul\Core\Models\TaxRate as TaxRate;
+use Illuminate\Support\Facades\Config;
class Core
{
@@ -127,6 +128,17 @@ class Core
return $currencySymbol = $this->getCurrentCurrency()->symbol;
}
+ /**
+ * Convert price with currency symbol
+ *
+ * @param float $price
+ * @return string
+ */
+ public function convertPrice($price, $currencyCode = null)
+ {
+ return $price;
+ }
+
/**
* Format and convert price with currency symbol
*
@@ -145,6 +157,17 @@ class Core
return currency($price, $currencyCode);
}
+ /**
+ * Format and convert price with currency symbol
+ *
+ * @param float $price
+ * @return string
+ */
+ public function formatPrice($price, $currencyCode)
+ {
+ return currency($price, $currencyCode);
+ }
+
/**
* Checks if current date of the given channel (in the channel timezone) is within the range
*
@@ -254,4 +277,21 @@ class Core
return $date->format($format);
}
+
+ /**
+ * Retrieve information from payment configuration
+ *
+ * @param string $field
+ * @param int|string|null $channelId
+ *
+ * @return mixed
+ */
+ public function getConfigData($field, $channelId = null)
+ {
+ if (null === $channelId) {
+ $channelId = $this->getCurrentChannel()->id;
+ }
+
+ return Config::get($field);
+ }
}
\ No newline at end of file
diff --git a/packages/Webkul/Core/src/Http/Controllers/ChannelController.php b/packages/Webkul/Core/src/Http/Controllers/ChannelController.php
index 858b69202..5328fc3e9 100644
--- a/packages/Webkul/Core/src/Http/Controllers/ChannelController.php
+++ b/packages/Webkul/Core/src/Http/Controllers/ChannelController.php
@@ -80,7 +80,6 @@ class ChannelController extends Controller
'base_currency' => 'required'
]);
-
$this->channel->create(request()->all());
session()->flash('success', 'Channel created successfully.');
@@ -114,9 +113,9 @@ class ChannelController extends Controller
'code' => ['required', 'unique:channels,code,' . $id, new \Webkul\Core\Contracts\Validations\Code],
'name' => 'required',
'locales' => 'required|array|min:1',
- 'default_locale' => 'required',
+ 'default_locale_id' => 'required',
'currencies' => 'required|array|min:1',
- 'base_currency' => 'required'
+ 'base_currency_id' => 'required'
]);
$this->channel->update(request()->all(), $id);
diff --git a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php
index afa24027a..564777325 100644
--- a/packages/Webkul/Customer/src/Http/Controllers/SessionController.php
+++ b/packages/Webkul/Customer/src/Http/Controllers/SessionController.php
@@ -5,11 +5,8 @@ namespace Webkul\Customer\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
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
diff --git a/packages/Webkul/Payment/src/Payment.php b/packages/Webkul/Payment/src/Payment.php
index ebbd54637..da4d78114 100644
--- a/packages/Webkul/Payment/src/Payment.php
+++ b/packages/Webkul/Payment/src/Payment.php
@@ -21,7 +21,7 @@ class Payment
if($object->isAvailable()) {
$paymentMethods[] = [
'method' => $object->getCode(),
- 'title' => $object->getTitle(),
+ 'method_title' => $object->getTitle(),
'description' => $object->getDescription(),
];
}
diff --git a/packages/Webkul/Payment/src/Payment/Payment.php b/packages/Webkul/Payment/src/Payment/Payment.php
index 6b4c0a063..4f3f5242c 100644
--- a/packages/Webkul/Payment/src/Payment/Payment.php
+++ b/packages/Webkul/Payment/src/Payment/Payment.php
@@ -58,14 +58,8 @@ abstract class Payment
*
* @return mixed
*/
- public function getConfigData($field, $channelId = null)
+ public function getConfigData($field)
{
- if (null === $channelId) {
- $channelId = core()->getCurrentChannel()->id;
- }
-
- $paymentConfig = Config::get('paymentmethods.' . $this->getCode());
-
- return $paymentConfig[$field];
+ return core()->getConfigData('paymentmethods.' . $this->getCode() . '.' . $field);
}
}
\ No newline at end of file
diff --git a/packages/Webkul/Sales/composer.json b/packages/Webkul/Sales/composer.json
new file mode 100644
index 000000000..96628ca1c
--- /dev/null
+++ b/packages/Webkul/Sales/composer.json
@@ -0,0 +1,25 @@
+{
+ "name": "webkul/laravel-sales",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Jitendra Singh",
+ "email": "jitendra@webkul.com"
+ }
+ ],
+ "require": {},
+ "autoload": {
+ "psr-4": {
+ "Webkul\\Sales\\": "src/"
+ }
+ },
+ "extra": {
+ "laravel": {
+ "providers": [
+ "Webkul\\Sales\\Providers\\SalesServiceProvider"
+ ],
+ "aliases": {}
+ }
+ },
+ "minimum-stability": "dev"
+}
diff --git a/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php b/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php
new file mode 100644
index 000000000..38d971983
--- /dev/null
+++ b/packages/Webkul/Sales/src/Providers/SalesServiceProvider.php
@@ -0,0 +1,26 @@
+loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
+ }
+
+ /**
+ * Register services.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Shipping/src/Carriers/AbstractShipping.php b/packages/Webkul/Shipping/src/Carriers/AbstractShipping.php
index 55cb97848..53be021ac 100644
--- a/packages/Webkul/Shipping/src/Carriers/AbstractShipping.php
+++ b/packages/Webkul/Shipping/src/Carriers/AbstractShipping.php
@@ -67,16 +67,9 @@ abstract class AbstractShipping
*
* @return mixed
*/
- public function getConfigData($field, $channelId = null)
+ public function getConfigData($field)
{
- if (null === $channelId) {
- $channelId = core()->getCurrentChannel()->id;
- }
-
- $shippingConfig = Config::get('carriers.' . $this->getCode());
-
- return $shippingConfig[$field];
+ return core()->getConfigData('carriers.' . $this->getCode() . '.' . $field);
}
-
}
?>
\ No newline at end of file
diff --git a/packages/Webkul/Shipping/src/Carriers/FlatRate.php b/packages/Webkul/Shipping/src/Carriers/FlatRate.php
index 0d93f4cdc..715f11538 100644
--- a/packages/Webkul/Shipping/src/Carriers/FlatRate.php
+++ b/packages/Webkul/Shipping/src/Carriers/FlatRate.php
@@ -3,7 +3,7 @@
namespace Webkul\Shipping\Carriers;
use Config;
-use Webkul\Cart\Models\CartShipping;
+use Webkul\Cart\Models\CartShippingRate;
use Webkul\Shipping\Facades\Shipping;
/**
@@ -19,19 +19,25 @@ class FlatRate extends AbstractShipping
*/
protected $code = 'flatrate';
+ /**
+ * Returns rate for flatrate
+ *
+ * @return array
+ */
public function calculate()
{
if(!$this->isAvailable())
return false;
- $object = new CartShipping;
+ $object = new CartShippingRate;
$object->carrier = 'flatrate';
$object->carrier_title = $this->getConfigData('title');
$object->method = 'flatrate_flatrate';
$object->method_title = $this->getConfigData('title');
$object->method_description = $this->getConfigData('description');
- $object->price = 10;
+ $object->price = core()->convertPrice($this->getConfigData('default_rate'));
+ $object->base_price = $this->getConfigData('default_rate');
return $object;
}
diff --git a/packages/Webkul/Shipping/src/Carriers/Free.php b/packages/Webkul/Shipping/src/Carriers/Free.php
new file mode 100644
index 000000000..5ef07c928
--- /dev/null
+++ b/packages/Webkul/Shipping/src/Carriers/Free.php
@@ -0,0 +1,44 @@
+isAvailable())
+ return false;
+
+ $object = new CartShippingRate;
+
+ $object->carrier = 'free';
+ $object->carrier_title = $this->getConfigData('title');
+ $object->method = 'free_free';
+ $object->method_title = $this->getConfigData('title');
+ $object->method_description = $this->getConfigData('description');
+ $object->price = 0;
+ $object->base_price = 0;
+
+ return $object;
+ }
+}
\ No newline at end of file
diff --git a/packages/Webkul/Shipping/src/Shipping.php b/packages/Webkul/Shipping/src/Shipping.php
index 201b7af19..fb8d06406 100644
--- a/packages/Webkul/Shipping/src/Shipping.php
+++ b/packages/Webkul/Shipping/src/Shipping.php
@@ -3,6 +3,7 @@
namespace Webkul\Shipping;
use Illuminate\Support\Facades\Config;
+use Webkul\Cart\Facades\Cart;
/**
* Class Shipping.
@@ -10,10 +11,25 @@ use Illuminate\Support\Facades\Config;
*/
class Shipping
{
+ /**
+ * Rates
+ *
+ * @var array
+ */
protected $rates = [];
+ /**
+ * Collects rate from available shipping methods
+ *
+ * @return array
+ */
public function collectRates()
{
+ if(!$cart = Cart::getCart())
+ return false;
+
+ $this->removeAllShippingRates();
+
foreach(Config::get('carriers') as $shippingMethod) {
$object = new $shippingMethod['class'];
@@ -26,12 +42,53 @@ class Shipping
}
}
+ $this->saveAllShippingRates();
+
return [
'jump_to_section' => 'shipping',
'html' => view('shop::checkout.onepage.shipping', ['shippingRateGroups' => $this->getGroupedAllShippingRates()])->render()
];
}
+
+ /**
+ * Persist shipping rate to database
+ *
+ * @return void
+ */
+ public function removeAllShippingRates()
+ {
+ if(!$cart = Cart::getCart())
+ return;
+ foreach($cart->shipping_rates()->get() as $rate) {
+ $rate->delete();
+ }
+ }
+
+ /**
+ * Persist shipping rate to database
+ *
+ * @return void
+ */
+ public function saveAllShippingRates()
+ {
+ if(!$cart = Cart::getCart())
+ return;
+
+ $shippingAddress = $cart->shipping_address;
+
+ foreach($this->rates as $rate) {
+ $rate->cart_address_id = $shippingAddress->id;
+
+ $rate->save();
+ }
+ }
+
+ /**
+ * Returns shipping rates, grouped by shipping method
+ *
+ * @return void
+ */
public function getGroupedAllShippingRates()
{
$rates = [];
diff --git a/packages/Webkul/Shop/src/Http/routes.php b/packages/Webkul/Shop/src/Http/routes.php
index 053265fa3..904b265f3 100644
--- a/packages/Webkul/Shop/src/Http/routes.php
+++ b/packages/Webkul/Shop/src/Http/routes.php
@@ -4,21 +4,23 @@ Route::group(['middleware' => ['web']], function () {
Route::get('/', 'Webkul\Shop\Http\Controllers\HomeController@index')->defaults('_config', [
'view' => 'shop::home.index'
- ])->name('store.home');
+ ])->name('shop.home.index');
Route::get('/categories/{slug}', 'Webkul\Shop\Http\Controllers\CategoryController@index')->defaults('_config', [
'view' => 'shop::products.index'
]);
- Route::get('/checkout', 'Webkul\Cart\Http\Controllers\CheckoutController@index')->defaults('_config', [
+ Route::get('/checkout/cart', 'Webkul\Cart\Http\Controllers\CartController@index')->defaults('_config', [
+ 'view' => 'shop::checkout.cart.index'
+ ])->name('shop.checkout.cart.index');
+
+ Route::get('/checkout/onepage', 'Webkul\Cart\Http\Controllers\CheckoutController@index')->defaults('_config', [
'view' => 'shop::checkout.onepage'
- ])->name('shop.checkout');
+ ])->name('shop.checkout.onepage.index');
Route::get('test', 'Webkul\Cart\Http\Controllers\CartController@test');
- Route::get('cart', 'Webkul\Cart\Http\Controllers\CartController@beforeCheckout')->defaults('_config', [
- 'view' => 'shop::store.cart.index'
- ]);
+ Route::get('mtest', 'Webkul\Cart\Http\Controllers\CartController@mergeTest');
Route::post('/checkout/save-address', 'Webkul\Cart\Http\Controllers\CheckoutController@saveAddress')->name('shop.checkout.save-address');
@@ -35,9 +37,9 @@ Route::group(['middleware' => ['web']], function () {
// //Routes for product cart
- Route::post('products/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.add');
+ Route::post('checkout/cart/add/{id}', 'Webkul\Cart\Http\Controllers\CartController@add')->name('cart.add');
- Route::post('product/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove');
+ Route::post('checkout/cart/remove/{id}', 'Webkul\Cart\Http\Controllers\CartController@remove')->name('cart.remove');
//Routes for product cart ends
diff --git a/packages/Webkul/Shop/src/Resources/assets/js/app.js b/packages/Webkul/Shop/src/Resources/assets/js/app.js
index 87860f794..d4abea11f 100644
--- a/packages/Webkul/Shop/src/Resources/assets/js/app.js
+++ b/packages/Webkul/Shop/src/Resources/assets/js/app.js
@@ -63,10 +63,10 @@ $(document).ready(function () {
const flashes = this.$refs.flashes;
flashMessages.forEach(function (flash) {
- console.log(flash);
flashes.addFlash(flash);
}, this);
},
+
responsiveHeader: function () { }
}
});
diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/_variables.scss b/packages/Webkul/Shop/src/Resources/assets/sass/_variables.scss
index 67c473993..1856dce46 100644
--- a/packages/Webkul/Shop/src/Resources/assets/sass/_variables.scss
+++ b/packages/Webkul/Shop/src/Resources/assets/sass/_variables.scss
@@ -2,11 +2,14 @@
$font-color: #242424;
$border-color: #E8E8E8;
$font-size-base: 16px;
-$border-color: #c7c7c7;
-$brand-color: #0031f0;
+$border-color: #E8E8E8;
+$brand-color: #0041FF;
//shop variables ends here
+
+//=======>Need to be removed
//customer variables
$profile-content-color: #5e5e5e;
$horizontal-rule-color: #E8E8E8;
-//customer variables ends here
\ No newline at end of file
+//customer variables ends here
+//<=======Need to be removed
diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss
index a566f42f4..1498b0b69 100644
--- a/packages/Webkul/Shop/src/Resources/assets/sass/app.scss
+++ b/packages/Webkul/Shop/src/Resources/assets/sass/app.scss
@@ -1,5 +1,4 @@
@import url("https://fonts.googleapis.com/css?family=Montserrat:400,500");
-
@import "icons";
@import "mixins";
@import "variables";
@@ -299,19 +298,13 @@ body {
width: 100%;
height: 100%;
top: 0;
- left: 0;
- right: 0;
- bottom: 0;
background:white;
- z-index: 2;
- cursor: pointer;
margin-top: 60px;
.control-group {
border-top: 1px solid $border-color;
border-bottom: 1px solid $border-color;
- height: 48px;
margin-bottom: 0px;
.control {
@@ -332,17 +325,17 @@ body {
.right {
float: right;
margin-top: 10px;
+ margin-right: 10px;
}
}
.suggestion {
margin-top: 14px;
height: 32px;
- margin-bottom: 14px;
border-bottom: 1px solid $border-color;
span {
- margin-left: 48px;
+ margin-left: 52px;
}
}
}
@@ -560,12 +553,10 @@ section.slider-block {
margin-right: auto;
.content-container {
- display: inline-block;
+ display: block;
width: 100%;
}
-
-
.product-grid {
display: grid;
grid-gap: 30px;
@@ -1739,135 +1730,39 @@ section.product-detail {
/* cart pages and elements css begins here */
section.cart {
+ width: 100%;
color: $font-color;
margin-bottom: 80px;
+ margin-top: 20px;
.title {
font-size: 24px;
}
.cart-content {
- margin-top: 21px;
- padding: 1px;
- display: flex;
- flex-direction: row;
- }
-}
+ margin-top: 20px;
+ width: 100%;
+ display: inline-block;
-.cart {
- .left-side {
- width: 68.6%;
- margin-right: 2.4%;
- }
+ .left-side {
+ width: 70%;
+ float: left;
- .right-side {
- width: 29%;
- display: block;
+ .misc-controls {
+ float: right;
+ margin-top: 20px;
- .price-section {
- width: 100%;
- padding: 10px 10px 18px 18px;
- margin-bottom: 20px;
-
- .title {
- font-weight: bold;
- padding-bottom: 8px;
- margin-bottom: 10px;
- }
-
- .all-item-details {
- margin-bottom: 17px;
-
- .item-details {
- margin-bottom: 10px;
-
- .name {
- }
-
- .price {
- float: right;
- }
- }
- }
- .horizontal-rule {
- width: 100%;
- height: 1px;
- vertical-align: middle;
- background: $border-color;
- }
-
- .total-details {
- margin-top: 10px;
-
- .amount {
- float: right;
+ a.link {
+ margin-right: 15px;
}
}
}
- .coupon-section {
- padding: 10px 10px 18px 18px;
-
- .title {
- font-weight: bold;
- margin-bottom: 10px;
- }
-
- .control-group {
- margin-bottom: 12px !important;
-
- input.coupon-input::-moz-placeholder {
- font-family: "montserrat", sans-serif;
- color: $font-color;
- }
-
- input.coupon-input::-webkit-input-placeholder {
- font-family: "montserrat", sans-serif;
- color: $font-color;
- }
-
- }
-
- button {
- margin-bottom: 10px;
- background-color: #000;
- border-radius: 0px;
- }
-
- .coupon-details {
-
- .coupon {
- margin-bottom: 8px;
-
- .discount {
- float: right;
- }
- }
- }
-
- .horizontal-rule {
- width: 100%;
- height: 1px;
- vertical-align: middle;
- background: $border-color;
- margin-bottom: 9px;
- }
-
- .after-coupon-amount {
-
- .name {
- font-weight: bold;
- }
-
- .amount {
- float: right;
- font-weight: bold;
- }
-
- }
-
+ .right-side {
+ width: 30%;
+ display: inline-block;
+ padding-left: 40px;
}
-
}
}
@@ -1876,10 +1771,12 @@ section.cart {
padding: 1px;
.item {
- padding: 1.1%;
+ padding: 10px;
margin-bottom: 20px;
display: flex;
flex-direction: row;
+ border: 1px solid $border-color;
+ border-radius: 3px;
.item-image {
height: 160px;
@@ -1893,24 +1790,13 @@ section.cart {
.item-title {
font-size: 18px;
margin-bottom: 10px;
+ font-weight: 600;
}
.price {
margin-bottom: 10px;
-
- .main-price {
- font-size: 18px;
- margin-right: 4px;
- }
-
- .real-price {
- margin-right: 4px;
- text-decoration-line: line-through;
- }
-
- .discount {
- color: #FF6472;
- }
+ font-size: 18px;
+ font-weight: 600;
}
.summary {
@@ -1949,20 +1835,242 @@ section.cart {
}
}
}
+}
- .misc-controls {
- float: right;
+.order-summary {
+ h3 {
+ font-size: 16px;
+ margin-top: 0;
+ }
- span {
- margin-right: 15px;
+ .item-detail {
+ margin-top:12px;
+
+ label {
+ &.right {
+ float: right;
+ }
}
+ }
- button {
- border-radius: 0px;
+ .payble-amount {
+ margin-top: 17px;
+ border-top: 1px solid $border-color;
+ padding-top: 12px;
+
+ label {
+ font-weight: bold;
+
+ &.right {
+ float:right;
+ }
}
}
}
+// checkout starts here
+.checkout-process {
+ display: flex;
+ flex-direction: row;
+ width: 100%;
+ margin-top: 20px;
+ margin-bottom: 20px;
+
+ .col-main {
+ width: 65%;
+ padding-right: 40px;
+
+ ul.checkout-steps {
+ width: 100%;
+ display: inline-flex;
+ justify-content: space-between;
+ width: 100%;
+ padding-bottom: 15px;
+ border-bottom: 1px solid $border-color;
+
+ li {
+ height: 48px;
+ display:flex;
+
+ .decorator {
+ height: 48px;
+ width: 48px;
+ border: 1px solid black;
+ border-radius: 50%;
+ display: inline-flex;
+ border: 1px solid $border-color;
+ background-repeat: no-repeat;
+ background-position: center;
+
+ &.address-info {
+ background-image: url('../images/address.svg');
+ }
+
+ &.shipping {
+ background-image: url('../images/shipping.svg');
+ }
+
+ &.payment {
+ background-image: url('../images/payment.svg');
+ }
+
+ &.review {
+ background-image: url('../images/finish.svg');
+ }
+ }
+
+ &.completed {
+ cursor: pointer;
+
+ .decorator {
+ background-image: url('../images/complete.svg');
+ }
+ }
+
+ span {
+ margin-left: 7px;
+ margin-top: auto;
+ margin-bottom: auto;
+ }
+
+ &.active {
+ color: #2650EF;
+
+ .decorator {
+ border: 1px solid #2650EF;
+ }
+ }
+ }
+ }
+
+ .step-content {
+ padding-top: 20px;
+
+ .form-header {
+ width: 100%;
+ display: inline-block;
+
+ h1 {
+ float: left;
+ }
+
+ .btn {
+ float: right;
+ }
+ }
+
+ .form-container {
+ border-bottom: 1px solid $border-color;
+ padding-top: 20px;
+ padding-bottom: 20px;
+ }
+
+ .shipping-methods {
+ h4 {
+ margin: 0;
+ }
+ }
+
+ .payment-methods {
+ .radio {
+ font-weight: 600;
+ }
+
+ .control-info {
+ margin-left: 28px;
+ }
+ }
+
+ .address {
+ display: inline-block;
+ width: 100%;
+
+ .address-card {
+ width: 50%;
+ float: left;
+
+ .card-title span {
+ font-weight: 600;
+ }
+
+ .card-content {
+ margin-top: 15px;
+ color: #121212;
+ line-height: 25px;
+
+ .horizontal-rule {
+ margin: 12px 0;
+ display: block;
+ width: 25px;
+ background: #121212;
+ }
+ }
+ }
+ }
+
+ .cart-item-list {
+ .item {
+ .row {
+ .title {
+ width: 100px;
+ display: inline-block;
+ color: #5E5E5E;
+ font-weight: 500;
+ margin-bottom: 10px;
+ }
+
+ .value {
+ font-size: 18px;
+ font-weight: 600;
+ }
+ }
+ }
+ }
+
+ .order-description {
+ display: inline-block;
+ width: 100%;
+
+ .shipping {
+ margin-bottom: 25px;
+ }
+
+ .decorator {
+ height: 48px;
+ width: 48px;
+ border-radius: 50%;
+ border: 1px solid $border-color;
+ vertical-align: middle;
+ display: inline-block;
+ text-align: center;
+
+ .icon {
+ margin-top: 7px;
+ }
+ }
+
+ .text {
+ font-weight: 600;
+ vertical-align: middle;
+ display: inline-block;
+
+ .info {
+ font-weight: 500;
+ margin-top: 2px;
+ }
+ }
+ }
+ // complete page end here
+ }
+ }
+
+ .col-right {
+ width: 35%;
+ padding-left: 40px;
+ }
+}
+// checkout ends here
+
.attached-products-wrapper {
margin-bottom: 80px;
@@ -1995,6 +2103,9 @@ section.cart {
}
+
+
+
//=======>Need to be removed
@media all and (max-width: 480px){
@@ -2866,266 +2977,7 @@ section.cart {
//<=======Need to be removed
-// checkout starts here
-.checkout-process {
- display: flex;
- flex-direction: row;
- width: 100%;
- margin-top: 20px;
- margin-bottom: 20px;
- .col-main {
- width: 65%;
- padding-right: 40px;
-
- ul.checkout-steps {
- width: 100%;
- display: inline-flex;
- justify-content: space-between;
- width: 100%;
- padding-bottom: 15px;
- border-bottom: 1px solid $border-color;
-
- li {
- height: 48px;
- display:flex;
-
- .decorator {
- height: 48px;
- width: 48px;
- border: 1px solid black;
- border-radius: 50%;
- display: inline-flex;
- border: 1px solid $border-color;
- background-repeat: no-repeat;
- background-position: center;
-
- &.address-info {
- background-image: url('../images/address.svg');
- }
-
- &.shipping {
- background-image: url('../images/shipping.svg');
- }
-
- &.payment {
- background-image: url('../images/payment.svg');
- }
-
- &.review {
- background-image: url('../images/finish.svg');
- }
- }
-
- &.completed {
- cursor: pointer;
-
- .decorator {
- background-image: url('../images/complete.svg');
- }
- }
-
- span {
- margin-left: 7px;
- margin-top: auto;
- margin-bottom: auto;
- }
-
- &.active {
- color: #2650EF;
-
- .decorator {
- border: 1px solid #2650EF;
- }
- }
- }
- }
-
- .step-content {
- padding-top: 20px;
-
- .form-header {
- width: 100%;
- display: inline-block;
-
- h1 {
- float: left;
- }
-
- .btn {
- float: right;
- }
- }
-
- .form-container {
- border-bottom: 1px solid $border-color;
- padding-top: 20px;
- padding-bottom: 20px;
- }
-
- .shipping-methods {
- h4 {
- margin: 0;
- }
- }
-
- .payment-methods {
- .radio {
- font-weight: 600;
- }
-
- .control-info {
- margin-left: 28px;
- }
- }
-
- .address {
- display: inline-block;
- width: 100%;
-
- .address-card {
- width: 50%;
-
- &.left {
- float: left;
- }
-
- &.right {
- float: right;
- }
-
- .card-title span {
- font-weight: 600;
- }
-
- .card-content {
- margin-top: 15px;
- color: #121212;
- line-height: 25px;
-
- .horizontal-rule {
- margin: 12px 0;
- display: block;
- width: 25px;
- background: #121212;
- }
- }
- }
- }
-
- .cart-item-list {
- .item {
- border: 1px solid $border-color;
- border-radius: 3px;
- padding: 20px;
-
- .row {
- .title {
- width: 100px;
- display: inline-block;
- color: #5E5E5E;
- font-weight: 500;
- margin-bottom: 10px;
- }
-
- .value {
- font-size: 18px;
- font-weight: 600;
- }
- }
- }
- }
-
- .order-description {
- display: inline-block;
- width: 100%;
-
- .shipping {
- margin-bottom: 25px;
- }
-
- .decorator {
- height: 48px;
- width: 48px;
- border-radius: 50%;
- border: 1px solid $border-color;
- vertical-align: middle;
- display: inline-block;
- text-align: center;
-
- .icon {
- margin-top: 7px;
- }
- }
-
- .text {
- font-weight: 600;
- vertical-align: middle;
- display: inline-block;
-
- .info {
- font-weight: 500;
- margin-top: 2px;
- }
- }
- }
- // complete page end here
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
-
- .col-right {
- width: 35%;
- padding-left: 40px;
- }
-
- .order-summary {
- h3 {
- font-size: 16px;
- }
-
- .item-detail {
- margin-top:12px;
-
- label {
- &.right {
- float: right;
- }
- }
- }
-
- .payble-amount {
- margin-top: 17px;
- border-top: 1px solid $border-color;
- padding-top: 12px;
-
- label {
- font-weight: bold;
-
- &.right {
- float:right;
- }
- }
- }
- }
-}
-// checkout ends here
// review page start here
section.review {
diff --git a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss
index 79b73e7df..f94d127a9 100644
--- a/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss
+++ b/packages/Webkul/Shop/src/Resources/assets/sass/icons.scss
@@ -59,4 +59,16 @@
background-image:URL('../images/icon-menu-back.svg');
width: 24px;
height: 24px;
+}
+
+.shipping-icon {
+ background-image: url('../images/shipping.svg');
+ width: 32px;
+ height: 32px;
+}
+
+.payment-icon {
+ background-image: url('../images/payment.svg');
+ width: 32px;
+ height: 32px;
}
\ 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 f183767ed..d87981178 100644
--- a/packages/Webkul/Shop/src/Resources/lang/en/app.php
+++ b/packages/Webkul/Shop/src/Resources/lang/en/app.php
@@ -60,7 +60,10 @@ return [
'checkout' => [
'cart' => [
-
+ 'title' => 'Shopping Cart',
+ 'empty' => 'Shopping Cart Is Empty',
+ 'continue-shopping' => 'Continue Shopping',
+ 'proceed-to-checkout' => 'Proceed To Checkout'
],
'onepage' => [
@@ -86,7 +89,21 @@ return [
'use_for_shipping' => 'Ship to this address',
'continue' => 'Continue',
'shipping-method' => 'Shipping Method',
- 'payment-information' => 'Payment Information'
+ 'payment-information' => 'Payment Information',
+ 'summary' => 'Summary of Order',
+ 'price' => 'Price',
+ 'quantity' => 'Quantity',
+ 'billing-address' => 'Billing Address',
+ 'shipping-address' => 'Shipping Address',
+ 'contact' => 'Contact',
+ 'place-order' => 'Place Order'
+ ],
+
+ 'total' => [
+ 'order-summary' => 'Order Summary',
+ 'sub-total' => 'Sub Total',
+ 'grand-total' => 'Grand Total',
+ 'delivery-charges' => 'Delivery Charges'
]
]
];
\ No newline at end of file
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php
index e69de29bb..ddd754cbc 100644
--- a/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/cart/index.blade.php
@@ -0,0 +1,98 @@
+@extends('shop::layouts.master')
+
+@section('page_title')
+ {{ __('shop::app.checkout.cart.title') }}
+@stop
+
+@section('content-wrapper')
+
+ @inject ('productImageHelper', 'Webkul\Product\Product\ProductImage')
+
+
+
+ @if ($cart)
+
+
+ {{ __('shop::app.checkout.cart.title') }}
+
+
+
+
+
+
+
+ @foreach($cart->items as $item)
+
+ product;
+
+ $productBaseImage = $productImageHelper->getProductBaseImage($product);
+ ?>
+
+
+
+
+
+
+
+
+
+ {{ $product->name }}
+
+
+
+ {{ core()->currency($item->base_price) }}
+
+
+ @if ($product->type == 'configurable')
+
+
+ @foreach (cart()->getItemAttributeOptionDetails($item) as $key => $option)
+
+ {{ (!$key ? '' : ' , ') . $option['attribute_name'] . ' : ' . $option['option_label'] }}
+
+ @endforeach
+
+ @endif
+
+
+
Quantity
+
{{ $item->quantity }}
+
Remove
+
Move to Wishlist
+
+
+
+
+ @endforeach
+
+
+
+
+
+
+
+
+
+ @include('shop::checkout.total.summary', ['cart' => $cart])
+
+
+
+
+
+ @else
+
+
+ {{ __('shop::app.checkout.cart.empty') }}
+
+
+ @endif
+
+
+@endsection
\ No newline at end of file
diff --git a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php
index 9fb6fbbf0..11de9111c 100644
--- a/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php
+++ b/packages/Webkul/Shop/src/Resources/views/checkout/onepage.blade.php
@@ -55,7 +55,7 @@