reponsive header

This commit is contained in:
rahul shukla 2018-09-28 19:54:55 +05:30
commit 368cf864a7
64 changed files with 2031 additions and 1936 deletions

View File

@ -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": {

View File

@ -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,
],
/*

View File

@ -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',
]
];

View File

@ -65,17 +65,17 @@
<span class="control-error" v-if="errors.has('locales[]')">@{{ errors.first('locales[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('default_locale') ? 'has-error' : '']">
<div class="control-group" :class="[errors.has('default_locale_id') ? 'has-error' : '']">
<label for="default_locale" class="required">{{ __('admin::app.settings.channels.default-locale') }}</label>
<?php $selectedOption = old('default_locale') ?: $channel->default_locale_id ?>
<select v-validate="'required'" class="control" id="default_locale" name="default_locale">
<select v-validate="'required'" class="control" id="default_locale" name="default_locale_id">
@foreach(core()->getAllLocales() as $locale)
<option value="{{ $locale->id }}" {{ $selectedOption == $locale->id ? 'selected' : '' }}>
{{ $locale->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('default_locale')">@{{ errors.first('default_locale') }}</span>
<span class="control-error" v-if="errors.has('default_locale_id')">@{{ errors.first('default_locale_id') }}</span>
</div>
<div class="control-group" :class="[errors.has('currencies[]') ? 'has-error' : '']">
@ -91,17 +91,17 @@
<span class="control-error" v-if="errors.has('currencies[]')">@{{ errors.first('currencies[]') }}</span>
</div>
<div class="control-group" :class="[errors.has('base_currency') ? 'has-error' : '']">
<div class="control-group" :class="[errors.has('base_currency_id') ? 'has-error' : '']">
<label for="base_currency" class="required">{{ __('admin::app.settings.channels.base-currency') }}</label>
<?php $selectedOption = old('base_currency') ?: $channel->base_currency_id ?>
<select v-validate="'required'" class="control" id="base_currency" name="base_currency">
<select v-validate="'required'" class="control" id="base_currency" name="base_currency_id">
@foreach(core()->getAllCurrencies() as $currency)
<option value="{{ $currency->id }}" {{ $selectedOption == $currency->id ? 'selected' : '' }}>
{{ $currency->name }}
</option>
@endforeach
</select>
<span class="control-error" v-if="errors.has('base_currency')">@{{ errors.first('base_currency') }}</span>
<span class="control-error" v-if="errors.has('base_currency_id')">@{{ errors.first('base_currency_id') }}</span>
</div>
</div>

View File

@ -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 <prashant.singh852@webkul.com>
* @author Jitendra Singh <jitendra@webkul.com>
* @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();
}
}

View File

@ -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();

View File

@ -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');
});
}
/**

View File

@ -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');

View File

@ -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();

View File

@ -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');
}
}

View File

@ -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) {
}
}
}

View File

@ -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()
]);
}
}

View File

@ -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();

View File

@ -0,0 +1,10 @@
<?php
use Webkul\Cart\Cart;
if (! function_exists('cart')) {
function cart()
{
return new Cart;
}
}
?>

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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');
}
}

View File

@ -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';
}

View File

@ -0,0 +1,17 @@
<?php
namespace Webkul\Cart\Models;
use Illuminate\Database\Eloquent\Model;
use Webkul\Cart\Models\CartAddress;
class CartShippingRate extends Model
{
/**
* Get the post that owns the comment.
*/
public function shipping_address()
{
return $this->belongsTo(CartAddress::class);
}
}

View File

@ -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);

View File

@ -0,0 +1,25 @@
<?php
namespace Webkul\Cart\Repositories;
use Webkul\Core\Eloquent\Repository;
/**
* Cart Address Reposotory
*
* @author Prashant Singh <prashant.singh852@webkul.com>
* @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';
}
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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

View File

@ -21,7 +21,7 @@ class Payment
if($object->isAvailable()) {
$paymentMethods[] = [
'method' => $object->getCode(),
'title' => $object->getTitle(),
'method_title' => $object->getTitle(),
'description' => $object->getDescription(),
];
}

View File

@ -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);
}
}

View File

@ -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"
}

View File

@ -0,0 +1,26 @@
<?php
namespace Webkul\Sales\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use Illuminate\Routing\Router;
use Illuminate\Foundation\AliasLoader;
class SalesServiceProvider extends ServiceProvider
{
public function boot(Router $router)
{
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
}
/**
* Register services.
*
* @return void
*/
public function register()
{
}
}

View File

@ -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);
}
}
?>

View File

@ -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;
}

View File

@ -0,0 +1,44 @@
<?php
namespace Webkul\Shipping\Carriers;
use Config;
use Webkul\Cart\Models\CartShippingRate;
use Webkul\Shipping\Facades\Shipping;
/**
* Class Rate.
*
*/
class Free extends AbstractShipping
{
/**
* Payment method code
*
* @var string
*/
protected $code = 'free';
/**
* Returns rate for flatrate
*
* @return array
*/
public function calculate()
{
if(!$this->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;
}
}

View File

@ -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 = [];

View File

@ -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

View File

@ -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 () { }
}
});

View File

@ -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
//customer variables ends here
//<=======Need to be removed

View File

@ -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 {

View File

@ -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;
}

View File

@ -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'
]
]
];

View File

@ -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')
<section class="cart">
@if ($cart)
<div class="title">
{{ __('shop::app.checkout.cart.title') }}
</div>
<div class="cart-content">
<div class="left-side">
<div class="cart-item-list" style="margin-top: 0">
@foreach($cart->items as $item)
<?php
$product = $item->product;
$productBaseImage = $productImageHelper->getProductBaseImage($product);
?>
<div class="item">
<div style="margin-right: 15px;">
<img class="item-image" src="{{ $productBaseImage['medium_image_url'] }}" />
</div>
<div class="item-details">
<div class="item-title">
{{ $product->name }}
</div>
<div class="price">
{{ core()->currency($item->base_price) }}
</div>
@if ($product->type == 'configurable')
<div class="summary" >
@foreach (cart()->getItemAttributeOptionDetails($item) as $key => $option)
{{ (!$key ? '' : ' , ') . $option['attribute_name'] . ' : ' . $option['option_label'] }}
@endforeach
</div>
@endif
<div class="misc">
<div class="qty-text">Quantity</div>
<div class="box">{{ $item->quantity }}</div>
<span class="remove">Remove</span>
<span class="towishlist">Move to Wishlist</span>
</div>
</div>
</div>
@endforeach
</div>
<div class="misc-controls">
<a href="{{ route('shop.home.index') }}" class="link">{{ __('shop::app.checkout.cart.continue-shopping') }}</a>
<a href="{{ route('shop.checkout.onepage.index') }}" class="btn btn-lg btn-primary">
{{ __('shop::app.checkout.cart.proceed-to-checkout') }}
</a>
</div>
</div>
<div class="right-side">
@include('shop::checkout.total.summary', ['cart' => $cart])
</div>
</div>
@else
<div class="title">
{{ __('shop::app.checkout.cart.empty') }}
</div>
@endif
</section>
@endsection

View File

@ -55,7 +55,7 @@
<div class="step-content shipping" v-show="currentStep == 2">
<shipping-section v-if="currentStep == 2"></shipping-section>
<shipping-section v-if="currentStep == 2" @onShippingMethodSelected="shippingMethodSelected($event)"></shipping-section>
<div class="button-group">
@ -69,7 +69,7 @@
<div class="step-content payment" v-show="currentStep == 3">
<payment-section v-if="currentStep == 3"></payment-section>
<payment-section v-if="currentStep == 3" @onPaymentMethodSelected="paymentMethodSelected($event)"></payment-section>
<div class="button-group">
@ -83,21 +83,34 @@
<div class="step-content review" v-show="currentStep == 4">
@include('shop::checkout.onepage.review')
<review-section v-if="currentStep == 4"></review-section>
<div class="button-group">
<button type="button" class="btn btn-lg btn-primary" @click="placeOrder()">
{{ __('shop::app.checkout.onepage.place-order') }}
</button>
</div>
</div>
</div>
@include('shop::checkout.onepage.summary')
<div class="col-right" v-show="currentStep != 4">
<summary-section></summary-section>
</div>
</div>
</script>
<script>
var shippingHtml = '';
var paymentHtml = '';
var reviewHtml = '';
var summaryHtml = Vue.compile(`<?php echo view('shop::checkout.total.summary', ['cart' => $cart])->render(); ?>`);
Vue.component('checkout', {
@ -120,9 +133,7 @@
selected_shipping_method: '',
selected_payment: {
method: ''
},
selected_payment_method: '',
}),
methods: {
@ -167,7 +178,7 @@
this.$http.post("{{ route('shop.checkout.save-shipping') }}", {'shipping_method': this.selected_shipping_method})
.then(function(response) {
if(response.data.jump_to_section == 'payment') {
shippingHtml = Vue.compile(response.data.html)
paymentHtml = Vue.compile(response.data.html)
this_this.completedStep = 2;
this_this.currentStep = 3;
}
@ -179,10 +190,10 @@
savePayment () {
var this_this = this;
this.$http.post("{{ route('shop.checkout.save-payment') }}", {'shipping_method': this.selected_payment_method})
this.$http.post("{{ route('shop.checkout.save-payment') }}", {'payment': this.selected_payment_method})
.then(function(response) {
if(response.data.jump_to_section == 'payment') {
shippingHtml = Vue.compile(response.data.html)
if(response.data.jump_to_section == 'review') {
reviewHtml = Vue.compile(response.data.html)
this_this.completedStep = 3;
this_this.currentStep = 4;
}
@ -192,6 +203,10 @@
})
},
placeOrder () {
},
handleErrorResponse (response, scope) {
if(response.status == 422) {
serverErrors = response.data.errors;
@ -201,10 +216,46 @@
window.location.href = response.data.redirect_url;
}
}
},
shippingMethodSelected (shippingMethod) {
this.selected_shipping_method = shippingMethod;
},
paymentMethodSelected (paymentMethod) {
this.selected_payment_method = paymentMethod;
}
}
})
var summaryTemplateRenderFns = [];
Vue.component('summary-section', {
inject: ['$validator'],
data: () => ({
templateRender: null
}),
staticRenderFns: summaryTemplateRenderFns,
mounted() {
this.templateRender = summaryHtml.render;
for (var i in summaryHtml.staticRenderFns) {
summaryTemplateRenderFns.push(summaryHtml.staticRenderFns[i]);
}
},
render(h) {
return h('div', [
(this.templateRender ?
this.templateRender() :
'')
]);
}
})
var shippingTemplateRenderFns = [];
Vue.component('shipping-section', {
@ -221,7 +272,7 @@
mounted() {
this.templateRender = shippingHtml.render;
for (var i in shippingHtml.staticRenderFns) {
shippingTemplateRenderFns.push(shippingHtml.staticRenderFns[i]);
shippingTemplateRenderFns.unshift(shippingHtml.staticRenderFns[i]);
}
},
@ -231,6 +282,12 @@
this.templateRender() :
'')
]);
},
methods: {
methodSelected () {
this.$emit('onShippingMethodSelected', this.selected_shipping_method)
}
}
})
@ -242,16 +299,50 @@
data: () => ({
templateRender: null,
selected_payment_method: '',
payment: {
method: ""
},
}),
staticRenderFns: paymentTemplateRenderFns,
mounted() {
this.templateRender = shippingHtml.render;
this.templateRender = paymentHtml.render;
for (var i in shippingHtml.staticRenderFns) {
paymentTemplateRenderFns.push(shippingHtml.staticRenderFns[i]);
for (var i in paymentHtml.staticRenderFns) {
paymentTemplateRenderFns.unshift(paymentHtml.staticRenderFns[i]);
}
},
render(h) {
return h('div', [
(this.templateRender ?
this.templateRender() :
'')
]);
},
methods: {
methodSelected () {
this.$emit('onPaymentMethodSelected', this.payment)
}
}
})
var reviewTemplateRenderFns = [];
Vue.component('review-section', {
data: () => ({
templateRender: null
}),
staticRenderFns: reviewTemplateRenderFns,
mounted() {
this.templateRender = reviewHtml.render;
for (var i in reviewHtml.staticRenderFns) {
reviewTemplateRenderFns.unshift(reviewHtml.staticRenderFns[i]);
}
},

View File

@ -124,7 +124,7 @@
@foreach (country()->all() as $code => $country)
<option value="{{ $country}}">{{ $country }}</option>
<option value="{{ $code }}">{{ $country }}</option>
@endforeach
</select>
@ -264,7 +264,7 @@
@foreach (country()->all() as $code => $country)
<option value="{{ $country}}">{{ $country }}</option>
<option value="{{ $code }}">{{ $country }}</option>
@endforeach
</select>

View File

@ -11,9 +11,9 @@
@foreach ($paymentMethods as $payment)
<span class="radio" >
<input v-validate="'required'" type="radio" id="{{ $payment['method'] }}" name="payment[method]" value="{{ $payment['method'] }}" v-model="selected_payment_method">
<input v-validate="'required'" type="radio" id="{{ $payment['method'] }}" name="payment[method]" value="{{ $payment['method'] }}" v-model="payment.method" @change="methodSelected()">
<label class="radio-view" for="{{ $payment['method'] }}"></label>
{{ $payment['title'] }}
{{ $payment['method_title'] }}
</span>
<span class="control-info">{{ $payment['description'] }}</span>

View File

@ -0,0 +1,141 @@
<div class="form-container">
<div class="form-header">
<h1>{{ __('shop::app.checkout.onepage.summary') }}</h1>
</div>
<div class="address">
@if ($billingAddress = $cart->billing_address)
<div class="address-card billing-address">
<div class="card-title">
<span>{{ __('shop::app.checkout.onepage.billing-address') }}</span>
</div>
<div class="card-content">
{{ $billingAddress->name }}</br>
{{ $billingAddress->address1 }}, {{ $billingAddress->address2 ? $billingAddress->address2 . ',' : '' }} {{ $billingAddress->state }}</br>
{{ country()->name($billingAddress->country) }} {{ $billingAddress->postcode }}</br>
<span class="horizontal-rule"></span>
{{ __('shop::app.checkout.onepage.contact') }} : {{ $billingAddress->phone }}
</div>
</div>
@endif
@if ($shippingAddress = $cart->shipping_address)
<div class="address-card shipping-address">
<div class="card-title">
<span>{{ __('shop::app.checkout.onepage.shipping-address') }}</span>
</div>
<div class="card-content">
{{ $shippingAddress->name }}</br>
{{ $shippingAddress->address1 }}, {{ $shippingAddress->address2 ? $shippingAddress->address2 . ',' : '' }} , {{ $shippingAddress->state }}</br>
{{ country()->name($shippingAddress->country) }} {{ $shippingAddress->postcode }}</br>
<span class="horizontal-rule"></span>
{{ __('shop::app.checkout.onepage.contact') }} : {{ $shippingAddress->phone }}
</div>
</div>
@endif
</div>
@inject ('productImageHelper', 'Webkul\Product\Product\ProductImage')
<div class="cart-item-list">
@foreach($cart->items as $item)
<?php
$product = $item->product;
$productBaseImage = $productImageHelper->getProductBaseImage($product);
?>
<div class="item">
<div style="margin-right: 15px;">
<img class="item-image" src="{{ $productBaseImage['medium_image_url'] }}" />
</div>
<div class="item-details">
<div class="item-title">
{{ $product->name }}
</div>
<div class="row">
<span class="title">
{{ __('shop::app.checkout.onepage.price') }}
</span>
<span class="value">
{{ core()->currency($item->base_price) }}
</span>
</div>
<div class="row">
<span class="title">
{{ __('shop::app.checkout.onepage.quantity') }}
</span>
<span class="value">
{{ $item->quantity }}
</span>
</div>
@if ($product->type == 'configurable')
<div class="summary" >
@foreach (cart()->getItemAttributeOptionDetails($item) as $key => $option)
{{ (!$key ? '' : ' , ') . $option['attribute_name'] . ' : ' . $option['option_label'] }}
@endforeach
</div>
@endif
</div>
</div>
@endforeach
</div>
<div class="order-description">
<div class="pull-left" style="width: 50%;">
<div class="shipping">
<div class="decorator">
<i class="icon shipping-icon"></i>
</div>
<div class="text">
{{ core()->currency($cart->selected_shipping_rate->base_price) }}
<div class="info">
{{ $cart->selected_shipping_rate->method_title }}
</div>
</div>
</div>
<div class="payment">
<div class="decorator">
<i class="icon payment-icon"></i>
</div>
<div class="text">
{{ core()->getConfigData('paymentmethods.' . $cart->payment->method . '.title') }}
</div>
</div>
</div>
<div class="pull-right" style="width: 50%;">
@include('shop::checkout.total.summary', ['cart' => $cart])
</div>
</div>
</div>

View File

@ -13,10 +13,10 @@
@foreach ($rateGroup['rates'] as $rate)
<span class="radio" >
<input v-validate="'required'" type="radio" id="{{ $rate->method }}" name="shipping_method" value="{{ $rate->method }}" v-model="selected_shipping_method">
<input v-validate="'required'" type="radio" id="{{ $rate->method }}" name="shipping_method" value="{{ $rate->method }}" v-model="selected_shipping_method" @change="methodSelected()">
<label class="radio-view" for="{{ $rate->method }}"></label>
{{ $rate->method_title }}
<b>{{ $rate->price }}</b>
<b>{{ core()->currency($rate->base_price) }}</b>
</span>
@endforeach

View File

@ -1,37 +0,0 @@
<div class="col-right">
<div class="order-summary">
<div class="price">
<span>{{ __('shop::app.checkout.onepage.order-summary') }}</span>
</div>
<div class="item-detail">
<span>
<label>2 Items Price</label>
<label class="right">$ 2,506.00</label>
</span>
</div>
<div class="item-detail">
<span>
<label>Delivery Charges</label>
<label class="right">$ 40.00</label>
</span>
</div>
<div class="item-detail">
<span>
<label>Coupan Discount</label>
<label class="right">$ 25.00</label>
</span>
</div>
<div class="horizontal-rule">
</div>
<div class="payble-amount">
<span>
<label>Amount Payble</label>
<label class="right">$ 2571.00</label>
</span>
</div>
</div>
</div>

View File

@ -0,0 +1,20 @@
<div class="order-summary">
<h3>{{ __('shop::app.checkout.total.order-summary') }}</h3>
<div class="item-detail">
<label>{{ __('shop::app.checkout.total.sub-total') }}</label>
<label class="right">{{ core()->currency($cart->sub_total) }}</label>
</div>
@if ($cart->selected_shipping_rate)
<div class="item-detail">
<label>{{ __('shop::app.checkout.total.delivery-charges') }}</label>
<label class="right">{{ core()->currency($cart->selected_shipping_rate->price) }}</label>
</div>
@endif
<div class="payble-amount">
<label>{{ __('shop::app.checkout.total.grand-total') }}</label>
<label class="right">{{ core()->currency($cart->grand_total) }}</label>
</div>
</div>

View File

@ -1,8 +0,0 @@
<div class="checkout-process">
@include('shop::customers.checkout.common.nav-left')
@include('shop::customers.checkout.common.nav-right')
</div>

View File

@ -1,53 +0,0 @@
<div class="left-side">
<div class="checkout-menu">
<ul class="checkout-detail">
<li>
<div class="wrapper">
<div class="decorator" v-bind:class="{ active: isGuest }">
<img src="{{asset('themes/default/assets/images/address.svg')}}" />
</div>
<span>Information</span>
</div>
</li>
<li>
<div class="wrapper" >
<div class="decorator" v-bind:class="{ active: isShip }">
<img src="{{asset('themes/default/assets/images/shipping.svg')}}"/>
</div>
<span>Shipping</span>
</div>
</li>
<li>
<div class="wrapper">
<div class="decorator">
<img src="{{asset('themes/default/assets/images/payment.svg')}}" />
</div>
<span>Payment</span>
</div>
</li>
<li>
<div class="wrapper">
<div class="decorator">
<img src="{{asset('themes/default/assets/images/finish.svg')}}" />
</div>
<span>Complete</span>
</div>
</li>
</ul>
<div class="horizontal-rule">
</div>
</div>
</div>

View File

@ -1,3 +0,0 @@
<div class="right-side">
</div>

View File

@ -1,265 +0,0 @@
@extends('shop::layouts.master')
@section('content-wrapper')
<div class="checkout-process">
<div class="left-side">
<div class="checkout-menu">
<ul class="checkout-detail">
<li>
<div class="wrapper">
<div class="decorator active">
<img src="{{asset('themes/default/assets/images/completed.svg')}}" />
</div>
<span>Information</span>
</div>
</li>
<li>
<div class="wrapper">
<div class="decorator">
<img src="{{asset('themes/default/assets/images/completed.svg')}}" />
</div>
<span>Shipping</span>
</div>
</li>
<li>
<div class="wrapper">
<div class="decorator">
<img src="{{asset('themes/default/assets/images/completed.svg')}}" />
</div>
<span>Payment</span>
</div>
</li>
<li>
<div class="wrapper">
<div class="decorator">
<img src="{{asset('themes/default/assets/images/finish.svg')}}" />
</div>
<span>Complete</span>
</div>
</li>
</ul>
<div class="horizontal-rule">
</div>
</div>
</div>
</div>
<div class="complete-page">
<div class="order-summary">
<span>Summary of Order<span>
</div>
<div class="address">
<div class="shipping-address">
<div class="shipping-title">
<span>Shipping address</span>
</div>
<div class="shipping-content">
<div class="name">
<span>John Doe </span>
</div>
<div class="addr">
<span>
25 , Washington USA 5751434
</span>
</div>
<div class="horizontal-rule">
</div>
<div class="contact">
<span>Contact : 9876543210 </span>
</div>
</div>
</div>
<div class="billing-address">
<div class="shipping-title">
<span>Billing address</span>
</div>
<div class="shipping-content">
<div class="name">
<span>John Doe </span>
</div>
<div class="addr">
<span>
25 , Washington USA 5751434
</span>
</div>
<div class="horizontal-rule">
</div>
<div class="contact">
<span>Contact : 9876543210 </span>
</div>
</div>
</div>
</div>
<div class="product-detail">
<div class="product-image">
<img src="{{asset('themes/default/assets/images/1.png')}}" />
</div>
<div class="product-desc">
<div class="product-title">
<span>
Rainbow creation Embroidered
</span>
</div>
<div class="price">
<span>
<label>Price </label>
<label class="bold"> $40.00 </label>
<span>
</div>
<div class="quantity">
<span>
<label>Quantity</label>
<label class="quat-bold"> 1 </label>
<span>
</div>
<div class="pro-attribute">
<span>
Color : Grey, Size : S,Sleeve Type : Puffed Sleeves,Occasion : Birthday ,Marriage Anniversary
</span>
</div>
</div>
</div>
<div class="product-detail">
<div class="product-image">
<img src="{{asset('themes/default/assets/images/1.png')}}" />
</div>
<div class="product-desc">
<div class="product-title">
<span>
Rainbow creation Embroidered
</span>
</div>
<div class="price">
<span>
<label>Price </label>
<label class="bold"> $40.00 </label>
</span>
</div>
<div class="quantity">
<span>
<label>Quantity</label>
<label class="quat-bold"> 1 </label>
</span>
</div>
<div class="pro-attribute">
<span>
Color : Grey, Size : S,Sleeve Type : Puffed Sleeves,Occasion : Birthday ,Marriage Anniversary
</span>
</div>
</div>
</div>
<div class="order-description">
<div class="payment">
<div class="shipping">
<div class="pay-icon">
<img src="{{asset('themes/default/assets/images/shipping.svg')}}" />
</div>
<div class="shipping-text">
<div class="price">
<span>
$ 25.00
</span>
</div>
<div class="fedex-shipping">
<span>
FedEx Shipping
</span>
</div>
</div>
</div>
<div class="net-banking">
<div class="pay-icon">
<img src="{{asset('themes/default/assets/images/payment.svg')}}" />
</div>
<span>Net banking </span>
</div>
</div>
<div class="product-bill">
<div class="sub-total">
<span>
Subtotal
</span>
<span class="right">
$ 2,506.00
</span>
</div>
<div class="charge-discount">
<span>
Delivery Charges
</span>
<span class="right">
$ 40.00
</span>
</div>
<div class="charge-discount">
<span>
Coupan discount
</span>
<span class="right">
$ 25.00
</span>
</div>
<div class="horizontal-rule">
</div>
<div class="amount-pay">
<span>
Amount payable
</span>
<span class="right">
$ 2,571.00
</span>
</div>
</div>
</div>
<div class="horizontal-rule">
</div>
<div class="palce-order-button">
<button>PLACE ORDER </button>
</div>
</div>
@endsection

View File

@ -1,73 +0,0 @@
<div class="order-info">
<div class="order-guest">
<span class="order-text">
Order as Guest
</span>
<button class="btn btn-lg btn-primary sign-in">
SIGN IN
</button>
</div>
<div class="control-group">
<label for="first_name">Email address <span>*</span></label>
<input type="text" class="control" name="email_address">
</div>
<div class="control-group">
<label for="first_name">First Name <span>*</span> </label>
<input type="text" class="control" name="first_name">
</div>
<div class="control-group">
<label for="first_name">Last Name <span>*</span> </label>
<input type="text" class="control" name="last_name">
</div>
<div class="control-group">
<label for="first_name">Company Name <span>*</span> </label>
<input type="text" class="control" name="company_name">
</div>
<div class="control-group">
<label for="first_name">Street address <span>*</span> </label>
<input type="text" class="control" name="street_address">
</div>
<div class="control-group">
<label for="first_name">City <span>*</span> </label>
<input type="text" class="control" name="city">
</div>
<div class="control-group">
<label for="first_name">Country <span>*</span> </label>
<input type="text" class="control" name="country">
</div>
<div class="control-group">
<label for="first_name">Provinces <span>*</span> </label>
<input type="text" class="control" name="provinces">
</div>
<div class="control-group">
<label for="first_name">Zip code <span>*</span> </label>
<input type="text" class="control" name="zip_code">
</div>
<div class="control-group">
<label for="first_name">Phone number <span>*</span> </label>
<input type="text" class="control" name="phone_number">
</div>
<div class="different-billing-addr">
<span>qwdevf</span>
<span>Usedifferent address for billing?</span>
</div>
<div class="horizontal-rule">
</div>
<div class="countinue-button">
<button class="btn btn-lg btn-primary" @click="count()">CONTINUE</button>
</div>
</div>

View File

@ -1,66 +0,0 @@
@extends('shop::layouts.master')
@section('content-wrapper')
<checkout customer="{{$customer_id}}"> </checkout>
@endsection
@push('scripts')
<script type="text/x-template" id="checkout-template">
<div>
@include('shop::customers.checkout.common.common')
<div v-if="customer">
@include('shop::customers.checkout.ship-method')
</div>
<div v-if="!customer">
@include('shop::customers.checkout.guest')
</div>
</div>
</script>
<script>
Vue.component('checkout', {
props: ['customer'],
data: () => ({
isGuest:true,
isShip:false,
disabled: 0,
isShipMethod:false
}),
template: '#checkout-template',
mounted () {
if(this.customer){
this.isShip=true;
}else{
this.isGuest=true;
this.disabled=1;
}
} ,
methods: {
count () {
this.isShipMethod=true;
}
}
})
</script>
@endpush

View File

@ -1,57 +0,0 @@
@extends('shop::layouts.master')
@section('content-wrapper')
@include('shop::customers.checkout.common.common')
<div class="payment-method">
<div class="payment-info">
<span class="payment-text">
Payment Method
</span>
</div>
<div class="payment-price">
<div class="payment-checkbox">
<img src="{{asset('themes/default/assets/images/unselected.svg')}}" />
<span> Cash on Delivery</span>
</div>
<div class="payment-checkbox-text">
<b>Fadex - </b>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.</span>
</div>
</div>
<div class="payment-price">
<div class="payment-checkbox">
<img src="{{asset('themes/default/assets/images/selected.svg')}}" />
<span> Net Banking</span>
</div>
<div class="payment-checkbox-text">
<b>Fadex - </b>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.</span>
</div>
</div>
<div class="payment-price">
<div class="payment-checkbox">
<img src="{{asset('themes/default/assets/images/unselected.svg')}}" />
<span> Debit / Credit Card</span>
</div>
<div class="payment-checkbox-text">
<b>Fadex - </b>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.</span>
</div>
</div>
<div class="horizontal-rule">
</div>
<div class="countinue-button">
<button>CONTINUE</button>
</div>
</div>
@endsection

View File

@ -1,52 +0,0 @@
<div class="ship-method">
<div class="ship-info">
<span class="ship-text">
Shipment Method
</span>
</div>
<div class="ship-price">
<div class="price-checkbox">
{{-- <img src="{{asset('themes/default/assets/images/selected.svg')}}" /> --}}
<input type="radio" name="gender" value="male" checked>
<span> $ 25.00 </span>
</div>
<div class="price-checkbox-text">
<b>Fadex - </b>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.</span>
</div>
</div>
<div class="ship-price">
<div class="price-checkbox">
<img src="{{asset('themes/default/assets/images/unselected.svg')}}" />
<span> $ 25.00 </span>
</div>
<div class="price-checkbox-text">
<b>Fadex - </b>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.</span>
</div>
</div>
<div class="ship-price">
<div class="price-checkbox">
<img src="{{asset('themes/default/assets/images/unselected.svg')}}" />
<span> $ 25.00 </span>
</div>
<div class="price-checkbox-text">
<b>Fadex - </b>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut.</span>
</div>
</div>
<div class="horizontal-rule">
</div>
<div class="countinue-button">
<button>CONTINUE</button>
</div>
</div>

View File

@ -1,40 +0,0 @@
@extends('shop::layouts.master')
@section('content-wrapper')
@include('shop::customers.checkout.common')
<div class="signin-form">
<div class="signin-guest">
<span class="signin-text">
Sign In
</span>
<button class="order-button">
ORDER AS GUEST
</button>
</div>
<div class="control-group">
<label for="first_name">Email </label>
<input type="text" class="control" name="email_address">
</div>
<div class="control-group">
<label for="first_name">Password </label>
<input type="text" class="control" name="first_name">
</div>
<div class="forgot-pass">
<span>Forgot Password</span>
</div>
<div class="horizontal-rule">
</div>
<div class="countinue-button">
<button>CONTINUE</button>
</div>
</div>
@endsection

View File

@ -4,7 +4,7 @@
<ul class="logo-container">
<li>
<a href="{{ route('store.home') }}">
<a href="{{ route('shop.home.index') }}">
<img class="logo" src="{{ asset('vendor/webkul/shop/assets/images/logo.svg') }}" />
</a>
</li>
@ -133,6 +133,8 @@
</div>
@push('scripts')
<script>
@ -141,39 +143,44 @@
var hamMenu = document.getElementById("hammenu");
var search = document.getElementById("search");
var content = document.getElementsByClassName("content-container")[0];
var searchSuggestion = document.getElementsByClassName('search-suggestion')[0];
var headerBottom = document.getElementsByClassName('header-bottom')[0];
console.log(searchSuggestion);
//hamMenu.addEventListener("click", header);
search.addEventListener("click", header);
hamMenu.addEventListener("click", header);
window.addEventListener('scroll', function() {
console.log(window.pageYOffset);
if(window.pageYOffset > 70){
headerBottom.style.visibility = "hidden";
}else{
headerBottom.style.visibility = "visible";
}
});
function header(){
alert('hello');
var className = document.getElementById(this.id).className;
if(className === 'icon search-icon' ){
search.classList.remove("search-icon");
search.classList.add("cross-icon");
searchSuggestion.style.display = 'block';
document.body.style.overflow = 'hidden';
}else if(className === 'icon sortable-icon'){
hamMenu.classList.remove("sortable-icon");
hamMenu.classList.add("cross-icon");
searchSuggestion.style.display = 'block';
document.body.style.overflow = 'hidden';
headerBottom.style.display = 'block';
document.body.style.overflow = 'hidden';
}else{
search.classList.remove("cross-icon");
search.classList.add("search-icon");
hamMenu.classList.remove("cross-icon");
hamMenu.classList.add("sortable-icon");
searchSuggestion.style.display = 'none';
document.body.style.overflow = "scroll";
}
}

View File

@ -35,26 +35,26 @@
</div>
<div class="search-suggestion">
<div class="control-group">
<span class="icon search-icon"></span>
<input type="text" class="control" placeholder="Saress India">
<span class="icon icon-menu-back right"></span>
</div>
<div class="suggestion">
<span>Designer sarees</span>
</div>
<div class="suggestion">
<span>India patter sarees</span>
</div>
<div class="suggestion">
<span>Border Sarees</span>
</div>
<div class="search-suggestion">
<div class="control-group">
<span class="icon search-icon"></span>
<input type="text" class="control" placeholder="Saress India">
<span class="icon icon-menu-back right"></span>
</div>
{{-- <div class="suggestion">
<span>Designer sarees</span>
</div>
<div class="suggestion">
<span>India patter sarees</span>
</div>
<div class="suggestion">
<span>Border Sarees</span>
</div> --}}
</div>
@include('shop::layouts.footer')
</div>

View File

@ -11,7 +11,7 @@
<span class="breadcrumb">Home</span> > <span class="breadcrumb">Men</span> > <span class="breadcrumb">Slit Open Jeans</span>
</div>
<div class="layouter">
<form method="POST" action="{{ route('cart.add', $product->id) }}">
<form method="POST" action="{{ route('cart.add', $product->id) }}" @submit.prevent="onSubmit">
@csrf()
<input type="hidden" name="product" value="{{ $product->id }}">

View File

@ -27,7 +27,7 @@
<div v-for='(attribute, index) in childAttributes' class="attribute control-group" :class="[errors.has('super_attribute[' + attribute.id + ']') ? 'has-error' : '']">
<label class="reqiured">@{{ attribute.label }}</label>
<select v-validate="'required'" class="control" :name="['super_attribute[' + attribute.id + ']']" :disabled="attribute.disabled" @change="configure(attribute, $event.target.value)" :id="['attribute_' + attribute.id]">
<select v-validate="'required'" class="control" :name="['super_attribute[' + attribute.id + ']']" :disabled="attribute.disabled" @change="configure(attribute, $event.target.value)" :id="['attribute_' + attribute.id]" required>
<option v-for='(option, index) in attribute.options' :value="option.id">@{{ option.label }}</option>
@ -49,6 +49,8 @@
template: '#product-options-template',
inject: ['$validator'],
data: () => ({
config: @json($config),

View File

@ -6,45 +6,10 @@
</div>
<div class="cart-content">
{{-- {{ dd($products) }} --}}
<div class="left-side">
{{-- <div class="item">
<img class="item-image" src="{{ bagisto_asset('images/jeans_big.jpg') }}" />
<div class="item-details">
<div class="item-title">
Rainbow Creation Embroided
</div>
<div class="price">
<span class="main-price">
$24.00
</span>
<span class="real-price">
$25.00
</span>
<span class="discount">
10% Off
</span>
</div>
<div class="summary">
Color : Gray, Size : S, Sleeve type : Puffed Sleeves, Occasion : Birthday, Marriage Anniversary
</div>
<div class="misc">
<div class="qty-text">Quantity</div>
<div class="box">1</div>
<span class="remove">Remove</span>
<span class="towishlist">Move to Wishlist</span>
</div>
</div>
</div> --}}
@foreach($products as $product)
<div class="item">
<div style="margin-right: 15px;">

View File

@ -1,3 +1,4 @@
{
"/js/app.js": "/js/app.js"
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css"
}

File diff suppressed because it is too large Load Diff

View File

@ -1460,10 +1460,10 @@ $(document).ready(function () {
var flashes = this.$refs.flashes;
flashMessages.forEach(function (flash) {
console.log(flash);
flashes.addFlash(flash);
}, this);
},
responsiveHeader: function responsiveHeader() {}
}
});