cart's implementation now moving towards normalized forms and improved the database structure for cart and cartitems table.
|
|
@ -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',
|
||||
]
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::customers.orders.index'
|
||||
])->name('admin.customer.orders.index');
|
||||
|
||||
Route::get('customer/reviews', 'Webkul\Shop\Http\Controllers\ReviewController@index')->defaults('_config',[
|
||||
Route::get('customer/reviews', 'Webkul\Product\Http\Controllers\ReviewController@index')->defaults('_config',[
|
||||
'view' => 'admin::customers.review.index'
|
||||
])->name('admin.customer.review.index');
|
||||
|
||||
|
|
@ -61,11 +61,11 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'redirect' => 'admin.customer.index'
|
||||
])->name('admin.customer.store');
|
||||
|
||||
Route::get('customer/reviews/edit/{id}', 'Webkul\Shop\Http\Controllers\ReviewController@edit')->defaults('_config',[
|
||||
Route::get('customer/reviews/edit/{id}', 'Webkul\Product\Http\Controllers\ReviewController@edit')->defaults('_config',[
|
||||
'view' => 'admin::customers.review.edit'
|
||||
])->name('admin.customer.review.edit');
|
||||
|
||||
Route::put('customer/reviews/edit/{id}', 'Webkul\Shop\Http\Controllers\ReviewController@update')->defaults('_config', [
|
||||
Route::put('customer/reviews/edit/{id}', 'Webkul\Product\Http\Controllers\ReviewController@update')->defaults('_config', [
|
||||
'redirect' => 'admin.customer.review.index'
|
||||
])->name('admin.customer.review.update');
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::customers.edit'
|
||||
])->name('admin.customer.edit');
|
||||
|
||||
Route::put('customer/reviews/edit/{id}', 'Webkul\Core\Http\Controllers\CustomerController@update')->defaults('_config', [
|
||||
Route::put('customer/edit/{id}', 'Webkul\Core\Http\Controllers\CustomerController@update')->defaults('_config', [
|
||||
'redirect' => 'admin.customer.index'
|
||||
])->name('admin.customer.update');
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class EventServiceProvider extends ServiceProvider
|
|||
$acl->add('catalog.products', 'Products', 'admin.catalog.products.index', 1);
|
||||
|
||||
$acl->add('catalog.categories', 'Categories', 'admin.catalog.categories.index', 1);
|
||||
|
||||
|
||||
$acl->add('configuration', 'Configure', 'admin.account.edit', 5);
|
||||
|
||||
$acl->add('settings', 'Settings', 'admin.users.index', 6);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
@section('content')
|
||||
<div class="content">
|
||||
<?php $locale = request()->get('locale') ?: app()->getLocale(); ?>
|
||||
|
||||
|
||||
<form method="POST" action="" @submit.prevent="onSubmit">
|
||||
|
||||
<div class="page-header">
|
||||
|
|
@ -121,7 +121,7 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -63,8 +63,13 @@
|
|||
|
||||
<div class="control-group">
|
||||
<label for="name" >{{ __('admin::app.customers.customers.customer_group') }}</label>
|
||||
<?php $selectedOption = $customer->customerGroup->id ?>
|
||||
|
||||
@if(!is_null($customer->customer_group_id))
|
||||
<?php $selectedOption = $customer->customerGroup->id ?>
|
||||
@endif
|
||||
|
||||
<select class="control" name="customer_group_id">
|
||||
|
||||
@foreach($customerGroup as $group)
|
||||
<option value="{{ $group->id }}" {{ $selectedOption == $group->id ? 'selected' : '' }}>
|
||||
{{ $group->group_name}}
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@
|
|||
<div class="control-group">
|
||||
<label for="name" >{{ __('admin::app.customers.reviews.status') }}</label>
|
||||
<select class="control" name="status">
|
||||
<option value="1">
|
||||
1
|
||||
<option value="pending" {{ $review->status == "pending" ? 'selected' : ''}}>
|
||||
pending
|
||||
</option>
|
||||
<option value="2">
|
||||
2
|
||||
<option value="approved" {{ $review->status == "approved" ? 'selected' : '' }}>
|
||||
approved
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
@extends('admin::layouts.content')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('admin::app.catalog.categories.edit-title') }}
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@stop
|
||||
|
|
@ -3,104 +3,305 @@
|
|||
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 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($id, $data) {
|
||||
unset($data['_token']);
|
||||
|
||||
if(!isset($data['is_configurable']) || !isset($data['product']) ||!isset($data['quantity'])) {
|
||||
session()->flash('error', 'Cart System Integrity Violation, Some Required Fields Missing.');
|
||||
|
||||
dd('discrepancy 1');
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
if($data['is_configurable'] == "true") {
|
||||
if(!isset($data['super_attribute'])) {
|
||||
session()->flash('error', 'Cart System Integrity Violation, Configurable Options Not Found In Request.');
|
||||
|
||||
dd('discrepancy 2');
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['sku'] = $this->product->findOneByField('id', $data['product'])->sku;
|
||||
|
||||
if(isset($data['is_configurable']) && $data['is_configurable'] == "true") {
|
||||
$parentData['sku'] = $data['sku'];
|
||||
|
||||
$parentData['product_id'] = $id;
|
||||
|
||||
$parentData['quantity'] = $data['quantity'];
|
||||
|
||||
$parentData['type'] = 'configurable';
|
||||
|
||||
$parentData['name'] = $this->product->findOneByField('id', $id)->name;
|
||||
|
||||
$parentData['price'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->price;
|
||||
|
||||
$parentData['base_price'] = $parentData['price'];
|
||||
|
||||
$parentData['item_total'] = $parentData['price'] * $data['quantity'];
|
||||
|
||||
$parentData['base_item_total'] = $parentData['price'] * $data['quantity'];
|
||||
|
||||
$parentData['weight'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->weight;
|
||||
|
||||
$parentData['item_weight'] = $parentData['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'] = $id;
|
||||
unset($data['product']);
|
||||
|
||||
$data['type'] = 'simple';
|
||||
|
||||
$data['name'] = $this->product->findOneByField('id', $id)->name;
|
||||
|
||||
$data['price'] = $this->product->findOneByField('id', $id)->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', $id)->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)
|
||||
{
|
||||
$itemData = $this->prepareItemData($id, $data);
|
||||
|
||||
if(session()->has('cart')) {
|
||||
$cart = session()->get('cart');
|
||||
|
|
@ -109,34 +310,51 @@ class Cart {
|
|||
|
||||
if(isset($cartItems)) {
|
||||
foreach($cartItems as $cartItem) {
|
||||
if($cartItem->product_id == $id) {
|
||||
$prevQty = $cartItem->quantity;
|
||||
if($data['is_configurable'] == "false") {
|
||||
if($cartItem->product_id == $id) {
|
||||
$prevQty = $cartItem->quantity;
|
||||
|
||||
$newQty = $data['quantity'];
|
||||
$newQty = $data['quantity'];
|
||||
|
||||
$cartItem->update(['quantity' => $prevQty + $newQty]);
|
||||
$cartItem->update(['quantity' => $prevQty + $newQty]);
|
||||
|
||||
session()->flash('success', "Product Quantity Successfully Updated");
|
||||
session()->flash('success', "Product Quantity Successfully Updated");
|
||||
|
||||
return redirect()->back();
|
||||
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);
|
||||
|
|
@ -150,26 +368,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');
|
||||
|
||||
|
|
@ -182,20 +398,45 @@ class Cart {
|
|||
|
||||
if(isset($customerCart)) {
|
||||
foreach($customerCartItems as $customerCartItem) {
|
||||
if($customerCartItem->type == "simple" && isset($customerCartItem->parent_id)) {
|
||||
//write the merge case whem the items exists with the customer cart also.
|
||||
$child = $customerCartItem;
|
||||
|
||||
foreach($cartItems as $key => $cartItem) {
|
||||
$parentId = $child->parent_id;
|
||||
|
||||
if($cartItem->product_id == $customerCartItem->product_id) {
|
||||
$parent = $this->cartItem->findOneByField('id', $parentId);
|
||||
|
||||
$customerItemQuantity = $customerCartItem->quantity;
|
||||
$parentPrice = $parent->price;
|
||||
|
||||
$cartItemQuantity = $cartItem->quantity;
|
||||
$prevQty = $parent->quantity;
|
||||
|
||||
$customerCartItem->update(['cart_id' => $customerCart->id, 'quantity' => $cartItemQuantity + $customerItemQuantity]);
|
||||
foreach ($cartItems as $key => $cartItem) {
|
||||
if ($cartItem->type == "simple" && isset($cartItem->parent_id)) {
|
||||
$newQty = $data['quantity'];
|
||||
|
||||
$this->cartItem->delete($cartItem->id);
|
||||
$parent->update(['quantity' => $prevQty + $newQty, 'item_total' => $parentPrice * ($prevQty + $newQty)]);
|
||||
} else if($cartItem->type == "simple" && is_null($cartItem->parent_id)){
|
||||
|
||||
$cartItems->forget($key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} elseif($customerCartItem->type == "simple" && is_null($customerCartItem->parent_id)) {
|
||||
foreach($cartItems as $key => $cartItem) {
|
||||
|
||||
if($cartItem->product_id == $customerCartItem->product_id) {
|
||||
|
||||
$customerItemQuantity = $customerCartItem->quantity;
|
||||
|
||||
$cartItemQuantity = $cartItem->quantity;
|
||||
|
||||
$customerCartItem->update(['cart_id' => $customerCart->id, 'quantity' => $cartItemQuantity + $customerItemQuantity]);
|
||||
|
||||
$this->cartItem->delete($cartItem->id);
|
||||
|
||||
$cartItems->forget($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -219,4 +460,80 @@ class Cart {
|
|||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cart
|
||||
*
|
||||
* @return Mixed
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
if(!$cart = session()->get('cart'))
|
||||
return false;
|
||||
|
||||
return $cart;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
foreach($cart->shipping_rates as $rate) {
|
||||
if($rate->method != $shippingMethodCode) {
|
||||
$rate->delete();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,18 +17,13 @@ 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('sku')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
$table->integer('parent_id')->nullable();
|
||||
$table->foreign('parent_id')->references('id')->on('cart');
|
||||
$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();
|
||||
|
|
@ -41,6 +36,7 @@ class CreateCartTable extends Migration
|
|||
$table->decimal('base_sub_total_with_discount', 12, 4)->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();
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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,7 +13,7 @@ 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');
|
||||
|
|
@ -21,8 +21,6 @@ class CreateCartShipping extends Migration
|
|||
$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->integer('cart_address_id')->nullable()->unsigned();
|
||||
$table->foreign('cart_address_id')->references('id')->on('cart_address');
|
||||
$table->timestamps();
|
||||
|
|
@ -36,6 +34,6 @@ class CreateCartShipping extends Migration
|
|||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cart_shipping');
|
||||
Schema::dropIfExists('cart_shipping_rates');
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,6 @@ use Webkul\Product\Repositories\ProductRepository;
|
|||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Product\Product\ProductImage;
|
||||
use Webkul\Product\Product\View as ProductView;
|
||||
use Webkul\Attribute\Repositories\AttributeOptionRepository;
|
||||
|
||||
use Cart;
|
||||
|
||||
/**
|
||||
|
|
@ -51,28 +49,16 @@ class CartController extends Controller
|
|||
|
||||
protected $productView;
|
||||
|
||||
/**
|
||||
* Initializing various
|
||||
* required repositories
|
||||
* and classes.
|
||||
*
|
||||
* @param Mixed $cart
|
||||
* @param Mixed $cartItem
|
||||
* @param Mixed $customer
|
||||
* @param Mixed $product
|
||||
* @param Mixed $productImage
|
||||
* @param Mixed $productView
|
||||
*/
|
||||
public function __construct(
|
||||
CartRepository $cart,
|
||||
CartItemRepository $cartItem,
|
||||
CustomerRepository $customer,
|
||||
ProductRepository $product,
|
||||
ProductImage $productImage,
|
||||
ProductView $productView)
|
||||
{
|
||||
ProductView $productView
|
||||
) {
|
||||
|
||||
$this->middleware('customer')->except(['add', 'remove', 'test']);
|
||||
// $this->middleware('customer')->except(['add', 'remove', 'test']);
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
|
|
@ -89,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
|
||||
|
|
@ -98,36 +97,12 @@ class CartController extends Controller
|
|||
*/
|
||||
|
||||
public function add($id) {
|
||||
// session()->forget('cart');
|
||||
|
||||
session()->forget('cart');
|
||||
return redirect()->back();
|
||||
// return redirect()->back();
|
||||
|
||||
$data = request()->input();
|
||||
|
||||
if(!isset($data['is_configurable']) || !isset($data['product']) ||!isset($data['quantity'])) {
|
||||
session()->flash('error', 'Cart System Integrity Violation');
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
//handle the accidental case
|
||||
//when some one deleted
|
||||
//form fields from the DOM
|
||||
if($data['is_configurable']) {
|
||||
if(!isset($data['super_attributes'])) {
|
||||
session()->flash('error', 'Cart System Integrity Violation');
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['is_configurable']) && $data['is_configurable']) {
|
||||
$data['price'] = $this->product->findOneByField('id', $data['selected_configurable_option'])->price;
|
||||
|
||||
} else {
|
||||
$data['price'] = $this->product->findOneByField('id', $data['product'])->price;
|
||||
}
|
||||
|
||||
Cart::add($id, $data);
|
||||
|
||||
return redirect()->back();
|
||||
|
|
@ -144,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);
|
||||
|
||||
|
|
@ -274,9 +137,7 @@ class CartController extends Controller
|
|||
else {
|
||||
$products[$cartItem->product->id] = [$cartItem->product->name, $cartItem->price, 'null', $cartItem->quantity];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dd($products);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ 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);
|
||||
|
||||
|
|
@ -68,9 +70,7 @@ class CartComposer
|
|||
$view->with('cart', $products);
|
||||
}
|
||||
} else {
|
||||
if(session()->has('cart')) {
|
||||
$cart = session()->get('cart');
|
||||
|
||||
if($cart = session()->get('cart')) {
|
||||
if(isset($cart)) {
|
||||
$cartItems = $this->cart->items($cart['id']);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ namespace Webkul\Cart\Models;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Product\Models\Product;
|
||||
use Webkul\Cart\Models\CartAddress;
|
||||
use Webkul\Cart\Models\CartShipping;
|
||||
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'];
|
||||
|
||||
|
|
@ -28,10 +28,42 @@ class Cart extends Model
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the shipping for the cart.
|
||||
* Get the biling address for the cart.
|
||||
*/
|
||||
public function shipping()
|
||||
public function biling_address()
|
||||
{
|
||||
return $this->hasMany(CartShipping::class);
|
||||
return $this->addresses()->where('address_type', 'billing');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the attributes for the attribute groups.
|
||||
*/
|
||||
public function getBilingAddressAttribute()
|
||||
{
|
||||
return $this->biling_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');
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,19 @@
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ 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');
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Cart\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CartShipping extends Model
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ namespace Webkul\Customer\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Webkul\Customer\Repositories\CustomerRepository;
|
||||
use Webkul\Product\Repositories\ProductReviewRepository as ProductReview;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Auth;
|
||||
|
||||
|
|
@ -27,14 +28,29 @@ class CustomerController extends Controller
|
|||
protected $_config;
|
||||
protected $customer;
|
||||
|
||||
/**
|
||||
* ProductReviewRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $productReview;
|
||||
|
||||
public function __construct(CustomerRepository $customer)
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Product\Repositories\ProductReviewRepository $productReview
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct(CustomerRepository $customer , ProductReview $productReview)
|
||||
{
|
||||
$this->middleware('customer');
|
||||
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$this->productReview = $productReview;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -141,7 +157,12 @@ class CustomerController extends Controller
|
|||
}
|
||||
|
||||
public function reviews() {
|
||||
return view($this->_config['view']);
|
||||
|
||||
$id = auth()->guard('customer')->user()->id;
|
||||
|
||||
$reviews = $this->productReview->getCustomerReview($id);
|
||||
|
||||
return view($this->_config['view'],compact('reviews'));
|
||||
}
|
||||
|
||||
public function address() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Webkul\Core\Http\Controllers;
|
||||
namespace Webkul\Product\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
|
@ -53,29 +53,43 @@ class ReviewController extends Controller
|
|||
$this->_config = request('_config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request , $id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'comment' => 'required',
|
||||
]);
|
||||
public function edit($id)
|
||||
{
|
||||
$review = $this->productReview->find($id);
|
||||
|
||||
$input=$request->all();
|
||||
return view($this->_config['view'],compact('review'));
|
||||
}
|
||||
|
||||
$input['product_id']=$id;
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$input['customer_id']=1;
|
||||
$this->productReview->update(request()->all(), $id);
|
||||
|
||||
$this->productReview->create($input);
|
||||
|
||||
session()->flash('success', 'Review submitted successfully.');
|
||||
session()->flash('success', 'Review updated successfully.');
|
||||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ namespace Webkul\Product\Models;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Webkul\Customer\Models\Customer;
|
||||
use Webkul\Product\Models\Product;
|
||||
|
||||
class ProductReview extends Model
|
||||
{
|
||||
|
|
@ -16,4 +17,12 @@ class ProductReview extends Model
|
|||
{
|
||||
return $this->belongsTo(Customer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product.
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class Review extends AbstractProduct
|
|||
*/
|
||||
public function getTotalRating($product)
|
||||
{
|
||||
return $product->reviews()->where('status',1)->sum('rating');
|
||||
return $product->reviews()->where('status','approved')->sum('rating');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -101,7 +101,7 @@ class Review extends AbstractProduct
|
|||
$link = $_SERVER['PHP_SELF'];
|
||||
$link_array = explode('/',$link);
|
||||
$last=end($link_array);
|
||||
$itemPerPage = $last*5;
|
||||
$itemPerPage = 1*5;
|
||||
return $product->reviews()->where('status',1)->paginate($itemPerPage);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
namespace Webkul\Product\Repositories;
|
||||
|
||||
|
||||
use Illuminate\Container\Container as App;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Webkul\Product\Repositories\ProductRepository;
|
||||
|
||||
/**
|
||||
* Product Review Reposotory
|
||||
|
|
@ -11,7 +13,29 @@ use Webkul\Core\Eloquent\Repository;
|
|||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||
*/
|
||||
class ProductReviewRepository extends Repository
|
||||
{
|
||||
{
|
||||
/**
|
||||
* ProductImageRepository object
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
ProductRepository $product,
|
||||
App $app)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify Model class name
|
||||
*
|
||||
|
|
@ -21,4 +45,16 @@ class ProductReviewRepository extends Repository
|
|||
{
|
||||
return 'Webkul\Product\Models\ProductReview';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve review for customerId
|
||||
*
|
||||
* @param int $customerId
|
||||
*/
|
||||
function getCustomerReview($customerId)
|
||||
{
|
||||
$reviews = $this->model->where('customer_id',$customerId)->with('product')->get();
|
||||
|
||||
return $reviews;
|
||||
}
|
||||
}
|
||||
|
|
@ -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,12 +19,17 @@ 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');
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
<?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;
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
|
@ -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 = [];
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ class ProductController extends Controller
|
|||
{
|
||||
$product = $this->product->findBySlugOrFail($slug);
|
||||
|
||||
return view($this->_config['view'], compact('product'));
|
||||
$customer = auth()->guard('customer')->user();
|
||||
|
||||
return view($this->_config['view'], compact('product','customer'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class ReviewController extends Controller
|
|||
|
||||
$customer_id = auth()->guard('customer')->user()->id;
|
||||
|
||||
$data['status']=0;
|
||||
$data['status']='pending';
|
||||
$data['product_id']=$id;
|
||||
$data['customer_id']=$customer_id;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,16 +10,16 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'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::post('/checkout/save-address', 'Webkul\Cart\Http\Controllers\CheckoutController@saveAddress')->name('shop.checkout.save-address');
|
||||
|
||||
Route::post('/checkout/save-shipping', 'Webkul\Cart\Http\Controllers\CheckoutController@saveShipping')->name('shop.checkout.save-shipping');
|
||||
|
|
@ -51,12 +51,12 @@ Route::group(['middleware' => ['web']], function () {
|
|||
])->name('shop.reviews.create');
|
||||
|
||||
Route::post('/product/{slug}/review', 'Webkul\Shop\Http\Controllers\ReviewController@store')->defaults('_config', [
|
||||
'redirect' => 'shop.reviews.index'
|
||||
'redirect' => 'customer.reviews.index'
|
||||
])->name('shop.reviews.store');
|
||||
|
||||
Route::post('/reviews/create/{slug}', 'Webkul\Shop\Http\Controllers\ReviewController@store')->defaults('_config', [
|
||||
'redirect' => 'admin.reviews.index'
|
||||
])->name('admin.reviews.store');
|
||||
// Route::post('/reviews/create/{slug}', 'Webkul\Shop\Http\Controllers\ReviewController@store')->defaults('_config', [
|
||||
// 'redirect' => 'admin.reviews.index'
|
||||
// ])->name('admin.reviews.store');
|
||||
|
||||
|
||||
//customer routes starts here
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>icon-filter</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="icon-filter" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M7.49822126,6.5 L7.49822126,9.98513267 L15.5,16.270847 L15.5,23.4152305 L16.5,22.8438019 L16.5,16.2644683 L24.5100795,10.0607155 L24.5100795,6.5 L7.49822126,6.5 Z" id="Path-2" stroke="#242424" stroke-width="3"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 690 B |
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>icon-sort</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="icon-sort" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group" transform="translate(5.000000, 6.000000)" fill="#242424">
|
||||
<polygon id="Path-8" points="13 0 16 0 16 13 19.689148 9.24692068 21.3605633 11.9273017 13 20.3403711"></polygon>
|
||||
<polygon id="Path-8-Copy" points="9 20 6 20 6 7.34037112 2.67141528 11.0934504 0.660888672 9.02355957 9 0"></polygon>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 800 B |
|
|
@ -29,4 +29,28 @@
|
|||
background-image:URL('../images/icon-list-view.svg');
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.sort-icon {
|
||||
background-image:URL('../images/icon-sort.svg');
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.filter-icon {
|
||||
background-image:URL('../images/icon-filter.svg');
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.whishlist-icon {
|
||||
background-image:URL('../images/wishlist.svg');
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.share-icon {
|
||||
background-image:URL('../images/icon-share.svg');
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
|
@ -60,7 +60,8 @@ return [
|
|||
|
||||
'checkout' => [
|
||||
'cart' => [
|
||||
|
||||
'title' => 'Shopping Cart',
|
||||
'empty' => 'Shopping Cart Is Empty',
|
||||
],
|
||||
|
||||
'onepage' => [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,141 @@
|
|||
@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">
|
||||
|
||||
@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">
|
||||
<span class="main-price">
|
||||
{{ $item->price }}
|
||||
</span>
|
||||
<span class="real-price">
|
||||
$25.00
|
||||
</span>
|
||||
<span class="discount">
|
||||
10% Off
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="summary" >
|
||||
Color : Gray, Size : S
|
||||
</div>
|
||||
|
||||
<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 class="misc-controls">
|
||||
<span>Continue Shopping</span>
|
||||
<button class="btn btn-lg btn-primary">PROCEED TO CHECKOUT</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right-side">
|
||||
<div class="price-section">
|
||||
<div class="title">
|
||||
Price Detail
|
||||
</div>
|
||||
<div class="all-item-details">
|
||||
@foreach($cart->items as $item)
|
||||
<div class="item-details">
|
||||
<span class="name">{{ $item->product->name }}</span>
|
||||
<span class="price">$ {{ $item->price }}</span>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="horizontal-rule"></div>
|
||||
|
||||
<div class="total-details">
|
||||
<span class="name">Amount Payable</span>
|
||||
<span class="amount">$75.00</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="coupon-section">
|
||||
|
||||
<span class="title">Apply Coupon</span>
|
||||
|
||||
<div class="control-group">
|
||||
<input type="text" class="control coupon-input" placeholder="Coupon Code" />
|
||||
</div>
|
||||
|
||||
<button class="btn btn-md btn-primary">Apply</button>
|
||||
|
||||
<div class="coupon-details">
|
||||
<div class="title">Coupon Used</div>
|
||||
<div class="coupon">
|
||||
<span class="name">Coupon 1</span>
|
||||
<span class="discount">$15</span>
|
||||
</div>
|
||||
<div class="coupon">
|
||||
<span class="name">Coupon 2</span>
|
||||
<span class="discount">$5</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="horizontal-rule"></div>
|
||||
|
||||
<div class="after-coupon-amount">
|
||||
<span class="name">Amount Payable</span>
|
||||
<span class="amount">$75.00</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@else
|
||||
|
||||
<div class="title">
|
||||
{{ __('shop::app.checkout.cart.empty') }}
|
||||
</div>
|
||||
|
||||
@endif
|
||||
</section>
|
||||
|
||||
@endsection
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<input v-validate="'required'" type="radio" id="{{ $rate->method }}" name="shipping_method" value="{{ $rate->method }}" v-model="selected_shipping_method">
|
||||
<label class="radio-view" for="{{ $rate->method }}"></label>
|
||||
{{ $rate->method_title }}
|
||||
<b>{{ $rate->price }}</b>
|
||||
<b>{{ core()->currency($rate->price) }}</b>
|
||||
</span>
|
||||
@endforeach
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1,44 @@
|
|||
<h1>Customer Reviews page</h1>
|
||||
@inject ('productImageHelper', 'Webkul\Product\Product\ProductImage')
|
||||
|
||||
@extends('shop::layouts.master')
|
||||
@section('content-wrapper')
|
||||
<div class="account-content">
|
||||
@include('shop::customers.account.partials.sidemenu')
|
||||
|
||||
<div class="cusomer-section">
|
||||
|
||||
<h1> Reviews</h1>
|
||||
|
||||
@foreach($reviews as $review)
|
||||
<div class="customer-section-info">
|
||||
|
||||
<?php $images = $productImageHelper->getGalleryImages($review->product); ?>
|
||||
|
||||
<div class="pro-img">
|
||||
<img src="{{ $images[0]['small_image_url'] }}" />
|
||||
</div>
|
||||
|
||||
<div class="pro-discription">
|
||||
|
||||
<div class="title">
|
||||
{{ $review->product->name }}
|
||||
</div>
|
||||
|
||||
<div class="rating">
|
||||
@for($i=0 ; $i < $review->rating ; $i++)
|
||||
<span class="icon star-icon"></span>
|
||||
@endfor
|
||||
</div>
|
||||
|
||||
<div class="discription">
|
||||
{{ $review->comment }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -147,14 +147,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header-bottom">
|
||||
<div class="header-bottom" id="header-bottom">
|
||||
@include('shop::layouts.header.nav-menu.navmenu')
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -1 +1 @@
|
|||
<button class="btn btn-lg btn-primary addtocart">Add to Cart</button>
|
||||
<button class="btn btn-lg btn-primary addtocart">ADD TO CART</button>
|
||||
|
|
@ -0,0 +1 @@
|
|||
<button class="btn btn-lg btn-primary buynow">BUY NOW!</button>
|
||||
|
|
@ -44,4 +44,90 @@
|
|||
|
||||
</div>
|
||||
|
||||
@stop
|
||||
@stop
|
||||
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script>
|
||||
|
||||
window.onload = function() {
|
||||
|
||||
var sort = document.getElementById("sort");
|
||||
var filter = document.getElementById("filter");
|
||||
|
||||
sort.addEventListener("click", myFunction);
|
||||
filter.addEventListener("click", myFunction);
|
||||
|
||||
function myFunction(){
|
||||
|
||||
let className = document.getElementById(this.id).className;
|
||||
var productGrid = document.getElementsByClassName('product-grid max-3-col');
|
||||
var filterLayered = document.getElementsByClassName('layered-filter-wrapper');
|
||||
var sortLimiter = document.getElementsByClassName('reponsive-sorter-limiter');
|
||||
|
||||
if(className === 'icon filter-icon'){
|
||||
|
||||
for(let i=0 ; i < filterLayered.length ; i++){
|
||||
filterLayered[i].style.display="block";
|
||||
filterLayered[i].style.padding="20px";
|
||||
filterLayered[i].style.width="100%";
|
||||
filterLayered[i].style.marginTop = "-100px";
|
||||
}
|
||||
for(let i=0 ; i < productGrid.length ; i++){
|
||||
productGrid[i].style.display = "none";
|
||||
}
|
||||
for(let i=0 ; i < sortLimiter.length ; i++){
|
||||
sortLimiter[i].style.display = "none";
|
||||
}
|
||||
|
||||
filter.classList.remove('icon', 'filter-icon');
|
||||
filter.classList.add('icon', 'cross-icon');
|
||||
sort.classList.remove('icon', 'cross-icon');
|
||||
sort.classList.remove('icon', 'sort-icon');
|
||||
sort.classList.add('icon', 'sort-icon');
|
||||
|
||||
}else if(className === 'icon sort-icon'){
|
||||
|
||||
for(let i=0 ; i < filterLayered.length ; i++){
|
||||
filterLayered[i].style.display="none";
|
||||
}
|
||||
for(let i=0 ; i < productGrid.length ; i++){
|
||||
productGrid[i].style.display = "none";
|
||||
}
|
||||
for(let i=0 ; i < sortLimiter.length ; i++){
|
||||
sortLimiter[i].style.display = "flex";
|
||||
sortLimiter[i].style.justifyContent = "space-between";
|
||||
}
|
||||
|
||||
sort.classList.remove('icon', 'sort-icon');
|
||||
sort.classList.add('icon', 'cross-icon');
|
||||
filter.classList.remove('icon', 'cross-icon');
|
||||
filter.classList.remove('icon', 'filter-icon');
|
||||
filter.classList.add('icon', 'filter-icon');
|
||||
|
||||
}else {
|
||||
|
||||
for(let i=0 ; i < productGrid.length ; i++){
|
||||
productGrid[i].style.display = "grid";
|
||||
}
|
||||
for(let i=0 ; i < filterLayered.length ; i++){
|
||||
filterLayered[i].style.display="none";
|
||||
}
|
||||
for(let i=0 ; i < sortLimiter.length ; i++){
|
||||
sortLimiter[i].style.display = "none";
|
||||
}
|
||||
|
||||
sort.classList.remove('icon', 'cross-icon');
|
||||
filter.classList.remove('icon', 'cross-icon');
|
||||
sort.classList.remove('icon', 'sort-icon');
|
||||
filter.classList.remove('icon', 'filter-icon');
|
||||
sort.classList.add('icon', 'sort-icon');
|
||||
filter.classList.add('icon', 'filter-icon');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
|
@ -11,9 +11,9 @@
|
|||
</div>
|
||||
|
||||
<div class="product-information">
|
||||
|
||||
|
||||
<div class="product-name">
|
||||
|
||||
|
||||
{{ $product->id }}
|
||||
|
||||
<a href="" title="{{ $product->name }}">
|
||||
|
|
@ -24,13 +24,13 @@
|
|||
<div class="product-description">
|
||||
{{ $product->short_description }}
|
||||
</div>
|
||||
|
||||
|
||||
@include ('shop::products.price', ['product' => $product])
|
||||
|
||||
@include ('shop::products.review', ['product' => $product])
|
||||
|
||||
@include ('shop::products.add-to', ['product' => $product])
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -3,13 +3,13 @@
|
|||
<div class="layered-filter-wrapper">
|
||||
|
||||
<layered-navigation></layered-navigation>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/x-template" id="layered-navigation-template">
|
||||
<div>
|
||||
|
||||
|
||||
<div class="filter-title">
|
||||
{{ __('shop::app.products.layered-nav-title') }}
|
||||
</div>
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
<div class="filter-content">
|
||||
|
||||
<div class="filter-attributes">
|
||||
|
||||
|
||||
<filter-attribute-item v-for='(attribute, index) in attributes' :attribute="attribute" :key="index" :index="index" @onFilterAdded="addFilters(attribute.code, $event)" :appliedFilterValues="appliedFilters[attribute.code]">
|
||||
</filter-attribute-item>
|
||||
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
</ol>
|
||||
|
||||
<div class="price-range-wrapper" v-if="attribute.type == 'price'">
|
||||
<vue-slider
|
||||
<vue-slider
|
||||
ref="slider"
|
||||
v-model="sliderConfig.value"
|
||||
:process-style="sliderConfig.processStyle"
|
||||
|
|
@ -86,9 +86,9 @@
|
|||
|
||||
created () {
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
|
||||
var entries = urlParams.entries();
|
||||
|
||||
|
||||
for(pair of entries) {
|
||||
this.appliedFilters[pair[0]] = pair[1].split(',');
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@
|
|||
if(filters.length) {
|
||||
this.appliedFilters[attributeCode] = filters;
|
||||
} else {
|
||||
delete this.appliedFilters[attributeCode];
|
||||
delete this.appliedFilters[attributeCode];
|
||||
}
|
||||
|
||||
this.applyFilter()
|
||||
|
|
@ -107,7 +107,7 @@
|
|||
|
||||
applyFilter () {
|
||||
var params = [];
|
||||
|
||||
|
||||
for(key in this.appliedFilters) {
|
||||
params.push(key + '=' + this.appliedFilters[key].join(','))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,15 @@
|
|||
<div class="top-toolbar">
|
||||
|
||||
<div class="page-info">
|
||||
{{ __('shop::app.products.pager-info', ['showing' => $products->firstItem() . '-' . $products->lastItem(), 'total' => $products->total()]) }}
|
||||
<span>
|
||||
{{ __('shop::app.products.pager-info', ['showing' => $products->firstItem() . '-' . $products->lastItem(), 'total' => $products->total()]) }}
|
||||
</span>
|
||||
|
||||
<span>Men</span>
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
|
||||
|
||||
<div class="view-mode">
|
||||
@if ($toolbarHelper->isModeActive('grid'))
|
||||
<span class="grid-view">
|
||||
|
|
@ -28,6 +32,15 @@
|
|||
<i class="icon list-view-icon"></i>
|
||||
</a>
|
||||
@endif
|
||||
|
||||
<div class="sort-filter">
|
||||
|
||||
<i class="icon sort-icon" id="sort" ></i>
|
||||
|
||||
<i class="icon filter-icon" id="filter"></i>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="sorter">
|
||||
|
|
@ -61,7 +74,44 @@
|
|||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="reponsive-sorter-limiter">
|
||||
|
||||
<div class="sorter">
|
||||
<label>{{ __('shop::app.products.sort-by') }}</label>
|
||||
|
||||
<select onchange="window.location.href = this.value">
|
||||
|
||||
@foreach ($toolbarHelper->getAvailableOrders() as $key => $order)
|
||||
|
||||
<option value="{{ $toolbarHelper->getOrderUrl($key) }}" {{ $toolbarHelper->isOrderCurrent($key) ? 'selected' : '' }}>
|
||||
{{ __('shop::app.products.' . $order) }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="limiter">
|
||||
<label>{{ __('shop::app.products.show') }}</label>
|
||||
|
||||
<select onchange="window.location.href = this.value">
|
||||
|
||||
@foreach ($toolbarHelper->getAvailableLimits() as $limit)
|
||||
|
||||
<option value="{{ $toolbarHelper->getLimitUrl($limit) }}" {{ $toolbarHelper->isLimitCurrent($limit) ? 'selected' : '' }}>
|
||||
{{ $limit }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -3,10 +3,10 @@
|
|||
@inject ('priceHelper', 'Webkul\Product\Product\Price')
|
||||
|
||||
@if ($product->type == 'configurable')
|
||||
|
||||
|
||||
<span class="price-label">{{ __('shop::app.products.price-label') }}</span>
|
||||
|
||||
<span class="final-price">{{ core()->currency($priceHelper->getMinimalPrice($product)) }}</span>
|
||||
<span class="final-price">{{ core()->currency($priceHelper->getMinimalPrice($product)) }}</span>
|
||||
|
||||
@else
|
||||
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
@else
|
||||
|
||||
<span>{{ core()->currency($product->price) }}</span>
|
||||
<span>{{ core()->currency($product->price) }}</span>
|
||||
|
||||
@endif
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<div class="cart-fav-seg">
|
||||
|
||||
@include ('shop::products.add-to-cart', ['product' => $product])
|
||||
|
||||
@include ('shop::products.buy-now')
|
||||
|
||||
</div>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
<div class="icon share-icon">
|
||||
<a href="#"></a>
|
||||
</div>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
<span>{{ $product->name }}</span>
|
||||
</div>
|
||||
|
||||
@include ('shop::products.review', ['product' => $product])
|
||||
{{-- @include ('shop::products.review', ['product' => $product]) --}}
|
||||
|
||||
@include ('shop::products.price', ['product' => $product])
|
||||
|
||||
|
|
@ -76,3 +76,44 @@
|
|||
</section>
|
||||
|
||||
@endsection
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
top: 16px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@push('scripts')
|
||||
|
||||
<script>
|
||||
|
||||
window.onscroll = function() {scrollFunction()};
|
||||
|
||||
function scrollFunction() {
|
||||
|
||||
var scrollTop = window.pageYOffset
|
||||
|
||||
var elems = document.getElementById("header-bottom");
|
||||
|
||||
if(scrollTop > 200){
|
||||
|
||||
elems.style.display = "none";
|
||||
|
||||
}else {
|
||||
elems.style.display = "block";
|
||||
}
|
||||
|
||||
console.log(scrollTop);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@endpush
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
<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>
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
<span class="control-error" v-if="errors.has('super_attribute[' + attribute.id + ']')">
|
||||
|
|
@ -41,17 +41,17 @@
|
|||
</div>
|
||||
</script>
|
||||
|
||||
<?php $config = $configurableOptionHelper->getConfigurationConfig($product) ?>
|
||||
{{-- <?php $config = $configurableOptionHelper->getConfigurationConfig($product) ?> --}}
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
Vue.component('product-options', {
|
||||
|
||||
template: '#product-options-template',
|
||||
|
||||
data: () => ({
|
||||
config: @json($config),
|
||||
|
||||
|
||||
childAttributes: [],
|
||||
|
||||
selectedProductId: '',
|
||||
|
|
@ -207,7 +207,7 @@
|
|||
element.selectedIndex = "0";
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getAttributeOptions (attributeId) {
|
||||
var this_this = this,
|
||||
options;
|
||||
|
|
@ -215,7 +215,7 @@
|
|||
this.config.attributes.forEach(function(attribute, index) {
|
||||
if (attribute.id == attributeId) {
|
||||
options = attribute.options;
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return options;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<div class="product-image-group">
|
||||
|
||||
<product-gallery></product-gallery>
|
||||
@include ('shop::products.add-to')
|
||||
@include ('shop::products.product-add')
|
||||
</div>
|
||||
@push('scripts')
|
||||
|
||||
|
|
@ -32,8 +32,13 @@
|
|||
|
||||
<img :src="currentLargeImageUrl" />
|
||||
|
||||
<div class="icon whishlist-icon"> </div>
|
||||
|
||||
@include ('shop::products.sharelinks')
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
@inject ('reviewHelper', 'Webkul\Product\Product\Review')
|
||||
|
||||
@if ($total = $reviewHelper->getTotalReviews($product))
|
||||
<div class="rating-reviews">
|
||||
<div class="rating-header">
|
||||
|
|
@ -17,7 +16,7 @@
|
|||
@for ($i = 1; $i <= round($reviewHelper->getAverageRating($product)); $i++)
|
||||
|
||||
<span class="icon star-icon"></span>
|
||||
|
||||
|
||||
@endfor
|
||||
</span>
|
||||
|
||||
|
|
@ -27,15 +26,17 @@
|
|||
|
||||
</div>
|
||||
|
||||
@if(!is_null($customer))
|
||||
<a href="{{ route('shop.reviews.create', $product->url_key) }}" class="btn btn-lg btn-primary">
|
||||
{{ __('shop::app.products.write-review-btn') }}
|
||||
</a>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<div class="reviews">
|
||||
|
||||
@foreach ($reviewHelper->getReviews($product)->paginate(5) as $review)
|
||||
@foreach ($reviewHelper->getReviews($product)->paginate(10) as $review)
|
||||
<div class="review">
|
||||
<div class="title">
|
||||
{{ $review->title }}
|
||||
|
|
@ -45,7 +46,7 @@
|
|||
@for ($i = 1; $i <= $review->rating; $i++)
|
||||
|
||||
<span class="icon star-icon"></span>
|
||||
|
||||
|
||||
@endfor
|
||||
</span>
|
||||
|
||||
|
|
@ -55,7 +56,7 @@
|
|||
|
||||
<div class="reviewer-details">
|
||||
<span class="by">
|
||||
{{ __('shop::app.products.by', ['name' => $review->customer->name]) }},
|
||||
{{ __('shop::app.products.by', ['name' => $review->customer->name]) }},
|
||||
</span>
|
||||
|
||||
<span class="when">
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 4.4 KiB |
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>icon-filter</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="icon-filter" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<path d="M7.49822126,6.5 L7.49822126,9.98513267 L15.5,16.270847 L15.5,23.4152305 L16.5,22.8438019 L16.5,16.2644683 L24.5100795,10.0607155 L24.5100795,6.5 L7.49822126,6.5 Z" id="Path-2" stroke="#242424" stroke-width="3"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 690 B |
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 50 (54983) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>icon-sort</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="icon-sort" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="Group" transform="translate(5.000000, 6.000000)" fill="#242424">
|
||||
<polygon id="Path-8" points="13 0 16 0 16 13 19.689148 9.24692068 21.3605633 11.9273017 13 20.3403711"></polygon>
|
||||
<polygon id="Path-8-Copy" points="9 20 6 20 6 7.34037112 2.67141528 11.0934504 0.660888672 9.02355957 9 0"></polygon>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 800 B |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 83 KiB |