Cart Packages files
This commit is contained in:
parent
888dfc6b0f
commit
29d83d7b5f
|
|
@ -56,7 +56,8 @@
|
||||||
"Webkul\\Customer\\": "packages/Webkul/Customer/src",
|
"Webkul\\Customer\\": "packages/Webkul/Customer/src",
|
||||||
"Webkul\\Inventory\\": "packages/Webkul/Inventory/src",
|
"Webkul\\Inventory\\": "packages/Webkul/Inventory/src",
|
||||||
"Webkul\\Product\\": "packages/Webkul/Product/src",
|
"Webkul\\Product\\": "packages/Webkul/Product/src",
|
||||||
"Webkul\\Theme\\": "packages/Webkul/Theme/src"
|
"Webkul\\Theme\\": "packages/Webkul/Theme/src",
|
||||||
|
"Webkul\\Cart\\": "packages/Webkul/Cart/src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,8 @@ return [
|
||||||
|
|
||||||
//Laravel Intervention
|
//Laravel Intervention
|
||||||
Intervention\Image\ImageServiceProvider::class,
|
Intervention\Image\ImageServiceProvider::class,
|
||||||
|
|
||||||
|
//Repository
|
||||||
Prettus\Repository\Providers\RepositoryServiceProvider::class,
|
Prettus\Repository\Providers\RepositoryServiceProvider::class,
|
||||||
|
|
||||||
//Webkul packages
|
//Webkul packages
|
||||||
|
|
@ -187,7 +189,8 @@ return [
|
||||||
Webkul\Product\Providers\ProductServiceProvider::class,
|
Webkul\Product\Providers\ProductServiceProvider::class,
|
||||||
Webkul\Shop\Providers\ShopServiceProvider::class,
|
Webkul\Shop\Providers\ShopServiceProvider::class,
|
||||||
Webkul\Customer\Providers\CustomerServiceProvider::class,
|
Webkul\Customer\Providers\CustomerServiceProvider::class,
|
||||||
Webkul\Theme\Providers\ThemeServiceProvider::class
|
Webkul\Theme\Providers\ThemeServiceProvider::class,
|
||||||
|
Webkul\Cart\Providers\CartServiceProvider::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ class ProductDataGrid
|
||||||
'primaryKey' => 'prods.attribute_family_id',
|
'primaryKey' => 'prods.attribute_family_id',
|
||||||
'condition' => '=',
|
'condition' => '=',
|
||||||
'secondaryKey' => 'attfam.id',
|
'secondaryKey' => 'attfam.id',
|
||||||
'withAttributes' => false
|
|
||||||
],
|
],
|
||||||
|
|
||||||
//for getting the attribute values.
|
//for getting the attribute values.
|
||||||
|
|
@ -76,7 +75,12 @@ class ProductDataGrid
|
||||||
'primaryKey' => 'prods.id',
|
'primaryKey' => 'prods.id',
|
||||||
'condition' => '=',
|
'condition' => '=',
|
||||||
'secondaryKey' => 'pav.product_id',
|
'secondaryKey' => 'pav.product_id',
|
||||||
'withAttributes' => true //use this boolean to select records as columns
|
'withAttributes' => [
|
||||||
|
'condition' => [
|
||||||
|
'attribute_id' => 2,
|
||||||
|
'select' => 'name',
|
||||||
|
]
|
||||||
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
// for getting the inventory quantity of a product
|
// for getting the inventory quantity of a product
|
||||||
|
|
@ -86,7 +90,6 @@ class ProductDataGrid
|
||||||
'primaryKey' => 'prods.id',
|
'primaryKey' => 'prods.id',
|
||||||
'condition' => '=',
|
'condition' => '=',
|
||||||
'secondaryKey' => 'pi.product_id',
|
'secondaryKey' => 'pi.product_id',
|
||||||
'withAttributes' => false
|
|
||||||
],
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
@ -120,17 +123,9 @@ class ProductDataGrid
|
||||||
'name' => 'pi.qty',
|
'name' => 'pi.qty',
|
||||||
'alias' => 'ProductQuantity',
|
'alias' => 'ProductQuantity',
|
||||||
'type' => 'string',
|
'type' => 'string',
|
||||||
'label' => 'Product Quatity',
|
'label' => 'Product Quantity',
|
||||||
'sortable' => false,
|
'sortable' => false,
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'name' => 'pav.attribute_id',
|
|
||||||
'alias' => 'AttributeID',
|
|
||||||
'type' => 'string',
|
|
||||||
'label' => 'Attribute ID',
|
|
||||||
'sortable' => false,
|
|
||||||
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'filterable' => [
|
'filterable' => [
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"name": "webkul/laravel-cart",
|
||||||
|
"description": "Cart Package for customer.",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "prashant-webkul",
|
||||||
|
"email": "prashant.singh852@webkul.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Webkul\\Cart\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Webkul\\Cart\\Providers\\CartServiceProvider"
|
||||||
|
],
|
||||||
|
"aliases": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minimum-stability": "dev"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateCartTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('cart', function (Blueprint $table) {
|
||||||
|
$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('coupon_code')->nullable();
|
||||||
|
$table->boolean('is_gift')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cart');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateCartItemsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('cart_items', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->integer('product_id')->unsigned();
|
||||||
|
$table->foreign('product_id')->references('id')->on('products');
|
||||||
|
$table->integer('quantity')->unsigned()->default(1);
|
||||||
|
$table->integer('cart_id')->unsigned();
|
||||||
|
$table->foreign('cart_id')->references('id')->on('cart');
|
||||||
|
$table->integer('tax_category_id')->unsigned()->nullable();
|
||||||
|
$table->foreign('tax_category_id')->references('id')->on('tax_categories');
|
||||||
|
$table->string('coupon_code')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('cart_items');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Cart\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Webkul\Cart\Repositories\CartRepository;
|
||||||
|
use Webkul\Cart\Repositories\CartItemsRepository;
|
||||||
|
use Session;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cart controller for the customer
|
||||||
|
* and guest users for adding and
|
||||||
|
* removing the products in the
|
||||||
|
* cart.
|
||||||
|
*
|
||||||
|
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||||
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||||
|
*/
|
||||||
|
class CartController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
protected $_config;
|
||||||
|
|
||||||
|
protected $cart;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(CartRepository $cart)
|
||||||
|
{
|
||||||
|
$this->middleware(['customer', 'guest']);
|
||||||
|
|
||||||
|
$this->_config = request('_config');
|
||||||
|
|
||||||
|
$this->cart = $cart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add() {
|
||||||
|
return "Adding Items to Cart";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Cart\Models;
|
||||||
|
|
||||||
|
class Cart
|
||||||
|
{
|
||||||
|
protected $table = 'cart';
|
||||||
|
|
||||||
|
protected $fillable = ['customer_id','session_id','channel_id','coupon_code','is_gift'];
|
||||||
|
|
||||||
|
protected $hidden = ['coupon_code'];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Cart\Models;
|
||||||
|
|
||||||
|
class CartItems
|
||||||
|
{
|
||||||
|
protected $table = 'cart_items';
|
||||||
|
|
||||||
|
protected $fillable = ['product_id','quantity','cart_id','tax_category_id','coupon_code'];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Cart\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Routing\Router;
|
||||||
|
use Webkul\Customer\Http\Middleware\RedirectIfNotCustomer;
|
||||||
|
|
||||||
|
class CartServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
public function boot(Router $router)
|
||||||
|
{
|
||||||
|
|
||||||
|
$router->aliasMiddleware('customer', RedirectIfNotCustomer::class);
|
||||||
|
|
||||||
|
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
// $this->app->bind('datagrid', 'Webkul\Ui\DataGrid\DataGrid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Cart\Repositories;
|
||||||
|
|
||||||
|
use Webkul\Core\Eloquent\Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cart Items Reposotory
|
||||||
|
*
|
||||||
|
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||||
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CartItemsRepository extends Repository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Specify Model class name
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
function model()
|
||||||
|
{
|
||||||
|
return 'Webkul\Cart\Models\CartItems';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function create(array $data)
|
||||||
|
{
|
||||||
|
$cartitems = $this->model->create($data);
|
||||||
|
|
||||||
|
return $cartitems;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param $id
|
||||||
|
* @param string $attribute
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function update(array $data, $id, $attribute = "id")
|
||||||
|
{
|
||||||
|
$cartitems = $this->find($id);
|
||||||
|
|
||||||
|
$cartitems->update($data);
|
||||||
|
|
||||||
|
return $cartitems;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Cart\Repositories;
|
||||||
|
|
||||||
|
use Webkul\Core\Eloquent\Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cart Reposotory
|
||||||
|
*
|
||||||
|
* @author Prashant Singh <prashant.singh852@webkul.com>
|
||||||
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CartRepository extends Repository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Specify Model class name
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
function model()
|
||||||
|
{
|
||||||
|
return 'Webkul\Cart\Models\Cart';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function create(array $data)
|
||||||
|
{
|
||||||
|
$cart = $this->model->create($data);
|
||||||
|
|
||||||
|
return $cart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param $id
|
||||||
|
* @param string $attribute
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function update(array $data, $id, $attribute = "id")
|
||||||
|
{
|
||||||
|
$cart = $this->find($id);
|
||||||
|
|
||||||
|
$cart->update($data);
|
||||||
|
|
||||||
|
return $cart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -160,22 +160,6 @@ class TaxCategoryController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To perform the rollback
|
|
||||||
* if in anycase the taxMap
|
|
||||||
* records creates any problem.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function performRollback($taxRuleId) {
|
|
||||||
|
|
||||||
if($this->taxRule->delete($taxRuleId)) {
|
|
||||||
session()->flash('error', 'Cannot Create Tax Rule');
|
|
||||||
|
|
||||||
return redirect()->route('admin.taxrule.index');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy a tax rule
|
* Destroy a tax rule
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<section class="featured-products">
|
<section class="featured-products">
|
||||||
<div class="featured-heading">
|
<div class="featured-heading">
|
||||||
|
{{ $session_id = session()->getId() }}<br/>
|
||||||
New Products<br/>
|
New Products<br/>
|
||||||
<span class="featured-seperator" style="color:lightgrey;">_____</span>
|
<span class="featured-seperator" style="color:lightgrey;">_____</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,10 @@ class ProductGrid
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
|
if(array_key_exists('withAttributes', $join)) {
|
||||||
|
$this->query->{$join['join']}($join['table'], $join['primaryKey'], $join['condition'], $join['secondaryKey'])->where('attribute_id','=',2)->addSelect('name as product_name');
|
||||||
|
}
|
||||||
|
else
|
||||||
$this->query->{$join['join']}($join['table'], $join['primaryKey'], $join['condition'], $join['secondaryKey']);
|
$this->query->{$join['join']}($join['table'], $join['primaryKey'], $join['condition'], $join['secondaryKey']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -949,7 +953,7 @@ class ProductGrid
|
||||||
|
|
||||||
$this->allAttributes = $this->getAttributes();
|
$this->allAttributes = $this->getAttributes();
|
||||||
$this->getDbQueryResults();
|
$this->getDbQueryResults();
|
||||||
// dd($this->results);
|
dd($this->results);
|
||||||
return view('ui::datagrid.index', [
|
return view('ui::datagrid.index', [
|
||||||
'css' => $this->css,
|
'css' => $this->css,
|
||||||
'results' => $this->results,
|
'results' => $this->results,
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@
|
||||||
<th class="grid_head" data-column-name="{{ $column->alias }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
|
<th class="grid_head" data-column-name="{{ $column->alias }}" data-column-label="{{ $column->label }}">{!! $column->sorting() !!}</th>
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
|
<td>Name</td>
|
||||||
{{-- @if(isset($attribute_columns))
|
{{-- @if(isset($attribute_columns))
|
||||||
@foreach($attribute_columns as $key => $value)
|
@foreach($attribute_columns as $key => $value)
|
||||||
<th class="grid_head"
|
<th class="grid_head"
|
||||||
|
|
@ -140,6 +141,7 @@
|
||||||
<td>{{ $result->{$atc} }}</td>
|
<td>{{ $result->{$atc} }}</td>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif --}}
|
@endif --}}
|
||||||
|
<td></td>
|
||||||
|
|
||||||
<td class="action">
|
<td class="action">
|
||||||
@foreach($actions as $action)
|
@foreach($actions as $action)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue