Merged w/ master
This commit is contained in:
commit
60c930c401
|
|
@ -57,11 +57,11 @@ class Cart {
|
|||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param Webkul\Checkout\Repositories\CartRepository $cart
|
||||
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItem
|
||||
* @param Webkul\Checkout\Repositories\CartRepository $cart
|
||||
* @param Webkul\Checkout\Repositories\CartItemRepository $cartItem
|
||||
* @param Webkul\Checkout\Repositories\CartAddressRepository $cartAddress
|
||||
* @param Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @param Webkul\Customer\Repositories\CustomerRepository $customer
|
||||
* @param Webkul\Product\Repositories\ProductRepository $product
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
|
|
@ -97,7 +97,7 @@ class Cart {
|
|||
unset($data['_token']);
|
||||
|
||||
//Check if the product is saleable
|
||||
if(!isset($data['product']) ||!isset($data['quantity'])) {
|
||||
if(!isset($data['product']) || !isset($data['quantity'])) {
|
||||
session()->flash('error', trans('shop::app.checkout.cart.integrity.missing_fields'));
|
||||
|
||||
return redirect()->back();
|
||||
|
|
@ -117,22 +117,23 @@ class Cart {
|
|||
//child row data
|
||||
$childData = [
|
||||
'product_id' => $data['selected_configurable_option'],
|
||||
'quantity' => 1,
|
||||
'sku' => $child->sku,
|
||||
'type' => $child->type,
|
||||
'name' => $child->name
|
||||
'name' => $child->name,
|
||||
'type' => 'simple'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
$price = ($product->type == 'configurable' ? $child->price : $product->price);
|
||||
$parentData = [
|
||||
'sku' => $product->sku,
|
||||
'product_id' => $productId,
|
||||
'quantity' => $data['quantity'],
|
||||
'type' => $product->type,
|
||||
'name' => $product->name,
|
||||
'price' => $price = ($product->type == 'configurable' ? $child->price : $product->price),
|
||||
'price' => core()->convertPrice($price),
|
||||
'base_price' => $price,
|
||||
'total' => $price * $data['quantity'],
|
||||
'total' => core()->convertPrice($price * $data['quantity']),
|
||||
'base_total' => $price * $data['quantity'],
|
||||
'weight' => $weight = ($product->type == 'configurable' ? $child->weight : $product->weight),
|
||||
'total_weight' => $weight * $data['quantity'],
|
||||
|
|
@ -142,6 +143,114 @@ class Cart {
|
|||
return ['parent' => $parentData, 'child' => $childData];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Items in a cart with some cart and item details.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param array $data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($id, $data)
|
||||
{
|
||||
$itemData = $this->prepareItemData($id, $data);
|
||||
|
||||
if($cart = $this->getCart()) {
|
||||
$product = $this->product->find($id);
|
||||
|
||||
$cartItems = $cart->items;
|
||||
|
||||
if($cartItems->count()) {
|
||||
foreach($cartItems as $cartItem) {
|
||||
if($product->type == "simple") {
|
||||
|
||||
if($cartItem->product_id == $id) {
|
||||
$prevQty = $cartItem->quantity;
|
||||
$newQty = $data['quantity'];
|
||||
|
||||
$canBe = $this->canAddOrUpdate($cartItem->id, $prevQty + $newQty);
|
||||
|
||||
if($canBe == false) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItem->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => core()->convertPrice($cartItem->price * ($prevQty + $newQty)),
|
||||
'base_total' => $cartItem->price * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.quantity.success'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
} else if($product->type == "configurable") {
|
||||
if($cartItem->type == "configurable") {
|
||||
$temp = $this->cartItem->findOneByField('parent_id', $cartItem->id);
|
||||
if($temp->product_id == $data['selected_configurable_option']) {
|
||||
$child = $temp->child;
|
||||
|
||||
$parent = $cartItem;
|
||||
$parentPrice = $parent->price;
|
||||
|
||||
$prevQty = $parent->quantity;
|
||||
$newQty = $data['quantity'];
|
||||
|
||||
$canBe = $this->canAddOrUpdate($cartItem->child->id, $prevQty + $newQty);
|
||||
|
||||
if($canBe == false) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$parent->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => core()->convertPrice($parentPrice * ($prevQty + $newQty)),
|
||||
'base_total' => $parentPrice * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.quantity.success'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($product->type == "configurable") {
|
||||
$parent = $cart->items()->create($itemData['parent']);
|
||||
|
||||
$itemData['child']['parent_id'] = $parent->id;
|
||||
|
||||
$cart->items()->create($itemData['child']);
|
||||
} else if($product->type != "configurable"){
|
||||
$parent = $cart->items()->create($itemData['parent']);
|
||||
}
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.item.success'));
|
||||
|
||||
return $cart;
|
||||
} else {
|
||||
if(isset($cart)) {
|
||||
$this->cart->delete($cart->id);
|
||||
} else {
|
||||
return $this->createNewCart($id, $data);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $this->createNewCart($id, $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new cart instance with the current item success.
|
||||
*
|
||||
|
|
@ -212,185 +321,121 @@ class Cart {
|
|||
}
|
||||
|
||||
/**
|
||||
* Save cart
|
||||
* This function handles when guest has some of cart products and then logs in.
|
||||
*
|
||||
* @return mixed
|
||||
* @return Response
|
||||
*/
|
||||
public function putCart($cart)
|
||||
public function mergeCart()
|
||||
{
|
||||
if(!auth()->guard('customer')->check()) {
|
||||
session()->put('cart', $cart);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cart
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
$cart = null;
|
||||
|
||||
if(auth()->guard('customer')->check()) {
|
||||
if(session()->has('cart')) {
|
||||
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
|
||||
} elseif(session()->has('cart')) {
|
||||
$cart = $this->cart->find(session()->get('cart')->id);
|
||||
}
|
||||
|
||||
return $cart && $cart->is_active ? $cart : null;
|
||||
}
|
||||
$guestCart = session()->get('cart');
|
||||
|
||||
/**
|
||||
* Returns cart details in array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$cart = $this->getCart();
|
||||
if(!isset($cart)) {
|
||||
$guestCart->update(['customer_id' => auth()->guard('customer')->user()->id, 'is_guest' => 0]);
|
||||
|
||||
$data = $cart->toArray();
|
||||
session()->forget('cart');
|
||||
|
||||
$data['shipping_address'] = current($data['shipping_address']);
|
||||
session()->put('cart', $guestCart);
|
||||
|
||||
$data['billing_address'] = current($data['billing_address']);
|
||||
|
||||
$data['selected_shipping_rate'] = $cart->selected_shipping_rate->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if the product is available and its required quantity
|
||||
* is available or not in the inventory sources.
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function canAddOrUpdate($itemId, $quantity)
|
||||
{
|
||||
if ($quantity < 1) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.warning'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$item = $this->cartItem->findOneByField('id', $itemId);
|
||||
|
||||
if($item->product->haveSufficientQuantity($quantity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Items in a cart with some cart and item details.
|
||||
*
|
||||
* @param integer $id
|
||||
* @param array $data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($id, $data)
|
||||
{
|
||||
$itemData = $this->prepareItemData($id, $data);
|
||||
|
||||
if($cart = $this->getCart()) {
|
||||
$product = $this->product->find($id);
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItems = $cart->items;
|
||||
|
||||
if($cartItems->count()) {
|
||||
foreach($cartItems as $cartItem) {
|
||||
if($product->type == "simple") {
|
||||
$guestCartId = $guestCart->id;
|
||||
|
||||
if($cartItem->product_id == $id) {
|
||||
$guestCartItems = $this->cart->findOneByField('id', $guestCartId)->items;
|
||||
|
||||
foreach($guestCartItems as $key => $guestCartItem) {
|
||||
foreach($cartItems as $cartItem) {
|
||||
|
||||
if($guestCartItem->type == "simple") {
|
||||
if($cartItem->product_id == $guestCartItem->product_id) {
|
||||
$prevQty = $cartItem->quantity;
|
||||
$newQty = $data['quantity'];
|
||||
|
||||
$newQty = $guestCartItem->quantity;
|
||||
|
||||
$canBe = $this->canAddOrUpdate($cartItem->id, $prevQty + $newQty);
|
||||
|
||||
if($canBe == false) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
session()->flash('warning', 'The requested quantity is not available, please try back later.');
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItem->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'base_total' => $cartItem->price * ($prevQty + $newQty)
|
||||
'total' => core()->convertPrice($cartItem->price * ($prevQty + $newQty)),
|
||||
'base_total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'total_weight' => $cartItem->weight * ($prevQty + $newQty),
|
||||
'base_total_weight' => $cartItem->weight * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.quantity.success'));
|
||||
|
||||
return redirect()->back();
|
||||
$guestCartItems->forget($key);
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
}
|
||||
} else if($product->type == "configurable") {
|
||||
if($cartItem->type == "configurable") {
|
||||
$temp = $this->cartItem->findOneByField('parent_id', $cartItem->id);
|
||||
if($temp->product_id == $data['selected_configurable_option']) {
|
||||
$child = $temp->child;
|
||||
} else if($guestCartItem->type == "configurable" && $cartItem->type == "configurable") {
|
||||
$guestCartItemChild = $guestCartItem->child;
|
||||
|
||||
$parent = $cartItem;
|
||||
$parentPrice = $parent->price;
|
||||
$cartItemChild = $cartItem->child;
|
||||
|
||||
$prevQty = $parent->quantity;
|
||||
$newQty = $data['quantity'];
|
||||
if($guestCartItemChild->product_id == $cartItemChild->product_id) {
|
||||
$prevQty = $guestCartItem->quantity;
|
||||
$newQty = $cartItem->quantity;
|
||||
|
||||
$canBe = $this->canAddOrUpdate($cartItem->child->id, $prevQty + $newQty);
|
||||
$canBe = $this->canAddOrUpdate($cartItem->child->id, $prevQty + $newQty);
|
||||
|
||||
if($canBe == false) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.inventory_warning'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$parent->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => $parentPrice * ($prevQty + $newQty),
|
||||
'base_total' => $parentPrice * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.quantity.success'));
|
||||
if($canBe == false) {
|
||||
session()->flash('warning', 'The requested quantity is not available, please try back later.');
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItem->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => core()->convertPrice($cartItem->price * ($prevQty + $newQty)),
|
||||
'base_total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'total_weight' => $cartItem->weight * ($prevQty + $newQty),
|
||||
'base_total_weight' => $cartItem->weight * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
|
||||
//child will be deleted first
|
||||
$this->cartItem->delete($guestCartItemChild->id);
|
||||
|
||||
//then parent will get deleted
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($product->type == "configurable") {
|
||||
$parent = $cart->items()->create($itemData['parent']);
|
||||
//now handle the products that are not deleted.
|
||||
foreach($guestCartItems as $guestCartItem) {
|
||||
|
||||
$itemData['child']['parent_id'] = $parent->id;
|
||||
if($guestCartItem->type == "configurable") {
|
||||
$guestCartItem->update(['cart_id' => $cart->id]);
|
||||
|
||||
$cart->items()->create($itemData['child']);
|
||||
} else if($product->type != "configurable"){
|
||||
$parent = $cart->items()->create($itemData['parent']);
|
||||
}
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
session()->flash('success', trans('shop::app.checkout.cart.item.success'));
|
||||
|
||||
return $cart;
|
||||
} else {
|
||||
if(isset($cart)) {
|
||||
$this->cart->delete($cart->id);
|
||||
} else {
|
||||
return $this->createNewCart($id, $data);
|
||||
$guestCartItem->child->update(['cart_id' => $cart->id]);
|
||||
} else{
|
||||
$guestCartItem->update(['cart_id' => $cart->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//delete the guest cart instance.
|
||||
$this->cart->delete($guestCartId);
|
||||
|
||||
//forget the guest cart instance
|
||||
session()->forget('cart');
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
return $this->createNewCart($id, $data);
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -452,6 +497,81 @@ class Cart {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check if the product is available and its required quantity
|
||||
* is available or not in the inventory sources.
|
||||
*
|
||||
* @param integer $id
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function canAddOrUpdate($itemId, $quantity)
|
||||
{
|
||||
if ($quantity < 1) {
|
||||
session()->flash('warning', trans('shop::app.checkout.cart.quantity.warning'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$item = $this->cartItem->findOneByField('id', $itemId);
|
||||
|
||||
if($item->product->haveSufficientQuantity($quantity)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save cart
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function putCart($cart)
|
||||
{
|
||||
if(!auth()->guard('customer')->check()) {
|
||||
session()->put('cart', $cart);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cart
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCart()
|
||||
{
|
||||
$cart = null;
|
||||
|
||||
if(auth()->guard('customer')->check()) {
|
||||
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
|
||||
} elseif(session()->has('cart')) {
|
||||
$cart = $this->cart->find(session()->get('cart')->id);
|
||||
}
|
||||
|
||||
return $cart && $cart->is_active ? $cart : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cart details in array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$cart = $this->getCart();
|
||||
|
||||
$data = $cart->toArray();
|
||||
|
||||
$data['shipping_address'] = current($data['shipping_address']);
|
||||
|
||||
$data['billing_address'] = current($data['billing_address']);
|
||||
|
||||
$data['selected_shipping_rate'] = $cart->selected_shipping_rate->toArray();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns cart
|
||||
*
|
||||
|
|
@ -615,123 +735,6 @@ class Cart {
|
|||
$cart->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* This function handles when guest has some of cart products and then logs in.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function mergeCart()
|
||||
{
|
||||
if(session()->has('cart')) {
|
||||
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id);
|
||||
|
||||
$guestCart = session()->get('cart');
|
||||
|
||||
if(!isset($cart)) {
|
||||
$guestCart->update(['customer_id' => auth()->guard('customer')->user()->id, 'is_guest' => 0]);
|
||||
|
||||
session()->forget('cart');
|
||||
|
||||
session()->put('cart', $guestCart);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItems = $cart->items;
|
||||
|
||||
$guestCartId = $guestCart->id;
|
||||
|
||||
$guestCartItems = $this->cart->findOneByField('id', $guestCartId)->items;
|
||||
|
||||
foreach($guestCartItems as $key => $guestCartItem) {
|
||||
foreach($cartItems as $cartItem) {
|
||||
|
||||
if($guestCartItem->type == "simple") {
|
||||
if($cartItem->product_id == $guestCartItem->product_id) {
|
||||
$prevQty = $cartItem->quantity;
|
||||
|
||||
$newQty = $guestCartItem->quantity;
|
||||
|
||||
$canBe = $this->canAddOrUpdate($cartItem->id, $prevQty + $newQty);
|
||||
|
||||
if($canBe == false) {
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItem->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'base_total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'total_weight' => $cartItem->weight * ($prevQty + $newQty),
|
||||
'base_total_weight' => $cartItem->weight * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
}
|
||||
} else if($guestCartItem->type == "configurable" && $cartItem->type == "configurable") {
|
||||
$guestCartItemChild = $guestCartItem->child;
|
||||
|
||||
$cartItemChild = $cartItem->child;
|
||||
|
||||
if($guestCartItemChild->product_id == $cartItemChild->product_id) {
|
||||
$prevQty = $guestCartItem->quantity;
|
||||
$newQty = $cartItem->quantity;
|
||||
|
||||
$canBe = $this->canAddOrUpdate($cartItem->child->id, $prevQty + $newQty);
|
||||
|
||||
if($canBe == false) {
|
||||
session()->flash('warning', 'The requested quantity is not available, please try back later.');
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
$cartItem->update([
|
||||
'quantity' => $prevQty + $newQty,
|
||||
'total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'base_total' => $cartItem->price * ($prevQty + $newQty),
|
||||
'total_weight' => $cartItem->weight * ($prevQty + $newQty),
|
||||
'base_total_weight' => $cartItem->weight * ($prevQty + $newQty)
|
||||
]);
|
||||
|
||||
$guestCartItems->forget($key);
|
||||
|
||||
//child will be deleted first
|
||||
$this->cartItem->delete($guestCartItemChild->id);
|
||||
|
||||
//then parent will get deleted
|
||||
$this->cartItem->delete($guestCartItem->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//now handle the products that are not deleted.
|
||||
foreach($guestCartItems as $guestCartItem) {
|
||||
|
||||
if($guestCartItem->type == "configurable") {
|
||||
$guestCartItem->update(['cart_id' => $cart->id]);
|
||||
|
||||
$guestCartItem->child->update(['cart_id' => $cart->id]);
|
||||
} else{
|
||||
$guestCartItem->update(['cart_id' => $cart->id]);
|
||||
}
|
||||
}
|
||||
|
||||
//delete the guest cart instance.
|
||||
$this->cart->delete($guestCartId);
|
||||
|
||||
//forget the guest cart instance
|
||||
session()->forget('cart');
|
||||
|
||||
$this->collectTotals();
|
||||
|
||||
return redirect()->back();
|
||||
} else {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if cart has any error
|
||||
*
|
||||
|
|
@ -778,7 +781,6 @@ class Cart {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deactivates current cart
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class CreateCartItemsTable extends Migration
|
|||
{
|
||||
Schema::create('cart_items', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('quantity')->unsigned()->default(1);
|
||||
$table->integer('quantity')->unsigned()->default(0);
|
||||
$table->string('sku')->nullable();
|
||||
$table->string('type')->nullable();
|
||||
$table->string('name')->nullable();
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class CartController extends Controller
|
|||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
Cart::update($data);
|
||||
|
||||
return redirect()->back();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ return [
|
|||
],
|
||||
|
||||
'signup-form' => [
|
||||
'page-title' => 'Customer - Registration Form',
|
||||
'title' => 'Sign Up',
|
||||
'firstname' => 'First Name',
|
||||
'lastname' => 'Last Name',
|
||||
|
|
@ -31,11 +32,63 @@ return [
|
|||
],
|
||||
|
||||
'login-form' => [
|
||||
'title' => 'Sign Up',
|
||||
'page-title' => 'Customer - Login',
|
||||
'title' => 'Sign In',
|
||||
'email' => 'E-Mail',
|
||||
'password' => 'Password',
|
||||
'forgot_pass' => 'Forgot Password?',
|
||||
'button_title' => 'Sign In'
|
||||
'button_title' => 'Sign In',
|
||||
'remember' => 'Remember Me',
|
||||
'footer' => '© Copyright 2018 Webkul Software, All rights reserved.'
|
||||
],
|
||||
|
||||
'forgot-password' => [
|
||||
'title' => 'Recover Password',
|
||||
'email' => 'E-Mail',
|
||||
'submit' => 'Submit',
|
||||
'page_title' => 'Customer - Forgot Password Form'
|
||||
],
|
||||
|
||||
'account' => [
|
||||
'dashboard' => 'Customer - Edit Profile',
|
||||
|
||||
'profile' => [
|
||||
'index' => [
|
||||
'page-title' => 'Customer - Profile',
|
||||
'title' => 'Profile',
|
||||
'edit' => 'Edit',
|
||||
],
|
||||
|
||||
'fname' => 'First Name',
|
||||
'lname' => 'Last Name',
|
||||
'gender' => 'Gender',
|
||||
'dob' => 'Date Of Birth',
|
||||
'phone' => 'Phone',
|
||||
'email' => 'E-Mail',
|
||||
'opassword' => 'Old Password',
|
||||
'password' => 'Password',
|
||||
'cpassword' => 'Confirm Password',
|
||||
'submit' => 'Update Profile',
|
||||
|
||||
'edit-profile' => [
|
||||
'title' => 'Edit Profile',
|
||||
'page-title' => 'Customer - Edit Profile Form'
|
||||
]
|
||||
],
|
||||
|
||||
'address' => [
|
||||
'index' => [
|
||||
'page-title' => 'Customer - Address',
|
||||
'title' => 'Address',
|
||||
'edit' => 'Edit',
|
||||
'empty' => 'You don\'t have any saved addresses here, please create a new one by clicking the link below.',
|
||||
'create' => 'Create Address',
|
||||
],
|
||||
|
||||
'edit' => [
|
||||
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
Customer - Address
|
||||
{{ __('shop::app.customer.account.address.index.page-title') }}
|
||||
@endsection
|
||||
|
||||
@section('content-wrapper')
|
||||
|
|
@ -13,14 +13,19 @@ Customer - Address
|
|||
<div class="profile">
|
||||
|
||||
<div class="section-head">
|
||||
<span class="profile-heading">Address</span>
|
||||
<span class="profile-edit"><a href="{{ route('customer.address.edit') }}">Edit</a></span>
|
||||
<span class="profile-heading">{{ __('shop::app.customer.account.address.index.title') }}</span>
|
||||
|
||||
<span class="profile-edit">
|
||||
<a href="{{ route('customer.address.edit') }}">
|
||||
{{ __('shop::app.customer.account.address.index.edit') }}
|
||||
</a>
|
||||
</span>
|
||||
<div class="horizontal-rule"></div>
|
||||
</div>
|
||||
|
||||
<div class="profile-content">
|
||||
@if($address->isEmpty())
|
||||
<div>You don't have any saved addresses here, please create a new one by clicking the link below.</div>
|
||||
<div>{{ __('shop::app.customer.account.address.index.empty') }}</div>
|
||||
<br/>
|
||||
<a href="{{ route('customer.address.create') }}">Create Address</a>
|
||||
@else
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ Customer - Create Address
|
|||
<div class="account-content">
|
||||
@include('shop::customers.account.partials.sidemenu')
|
||||
|
||||
<div class="address-form-content">
|
||||
<div class="title">Add Address</div>
|
||||
|
||||
<div class="edit-form-content">
|
||||
<div class="section-head">
|
||||
<div class="section-head">Add Address</div>
|
||||
</div>
|
||||
<form method="post" action="{{ route('customer.address.create') }}">
|
||||
|
||||
<div class="edit-form">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
Customer - Edit Profile
|
||||
{{ __('shop::app.customer.account.profile.edit-profile.page-title') }}
|
||||
@endsection
|
||||
|
||||
@section('content-wrapper')
|
||||
|
|
@ -12,7 +12,7 @@ Customer - Edit Profile
|
|||
<div class="edit-form-content">
|
||||
|
||||
<div class="section-head mb-10">
|
||||
<div class="profile-heading">Edit Profile</div>
|
||||
<div class="profile-heading">{{ __('shop::app.customer.account.profile.edit-profile.title') }}</div>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ route('customer.profile.edit') }}">
|
||||
|
|
@ -21,19 +21,19 @@ Customer - Edit Profile
|
|||
@csrf
|
||||
|
||||
<div class="control-group" :class="[errors.has('first_name') ? 'has-error' : '']">
|
||||
<label for="first_name">First Name</label>
|
||||
<label for="first_name">{{ __('shop::app.customer.account.profile.fname') }}</label>
|
||||
<input type="text" class="control" name="first_name" value="{{ $customer['first_name'] }}" v-validate="'required'">
|
||||
<span class="control-error" v-if="errors.has('first_name')">@{{ errors.first('first_name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('last_name') ? 'has-error' : '']">
|
||||
<label for="last_name">Last Name</label>
|
||||
<label for="last_name">{{ __('shop::app.customer.account.profile.lname') }}</label>
|
||||
<input type="text" class="control" name="last_name" value="{{ $customer['last_name'] }}" v-validate="'required'">
|
||||
<span class="control-error" v-if="errors.has('last_name')">@{{ errors.first('last_name') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('gender') ? 'has-error' : '']">
|
||||
<label for="email">Gender</label>
|
||||
<label for="email">{{ __('shop::app.customer.account.profile.gender') }}</label>
|
||||
<select name="gender" class="control" v-validate="'required'">
|
||||
<option value="Male" @if($customer['gender']=="Male") selected @endif>Male</option>
|
||||
<option value="Female" @if($customer['gender']=="Female") selected @endif>Female</option>
|
||||
|
|
@ -42,43 +42,43 @@ Customer - Edit Profile
|
|||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('date_of_birth') ? 'has-error' : '']">
|
||||
<label for="date_of_birth">Date of Birth</label>
|
||||
<label for="date_of_birth">{{ __('shop::app.customer.account.profile.dob') }}</label>
|
||||
<input type="date" class="control" name="date_of_birth" value="{{ $customer['date_of_birth'] }}" v-validate="'required'">
|
||||
<span class="control-error" v-if="errors.has('date_of_birth')">@{{ errors.first('date_of_birth') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('phone') ? 'has-error' : '']">
|
||||
<label for="phone">Phone</label>
|
||||
<label for="phone">{{ __('shop::app.customer.account.profile.phone') }}</label>
|
||||
<input type="text" class="control" name="phone" value="{{ $customer['phone'] }}" v-validate="'required|digits:10'">
|
||||
<span class="control-error" v-if="errors.has('phone')">@{{ errors.first('phone') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
|
||||
<label for="email">Email</label>
|
||||
<label for="email">{{ __('shop::app.customer.account.profile.email') }}</label>
|
||||
<input type="email" class="control" name="email" value="{{ $customer['email'] }}" v-validate="'required'">
|
||||
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('old_password') ? 'has-error' : '']">
|
||||
<label for="password">Old Password</label>
|
||||
<label for="password">{{ __('shop::app.customer.account.profile.opassword') }}</label>
|
||||
<input type="oldpassword" class="control" name="oldpassword">
|
||||
<span class="control-error" v-if="errors.has('oldpassword')">@{{ errors.first('oldpassword') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('password') ? 'has-error' : '']">
|
||||
<label for="password">Password</label>
|
||||
<label for="password">{{ __('shop::app.customer.account.profile.password') }}</label>
|
||||
<input type="password" class="control" name="password">
|
||||
<span class="control-error" v-if="errors.has('password')">@{{ errors.first('password') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label for="password">Confirm Password</label>
|
||||
<label for="password">{{ __('shop::app.customer.account.profile.cpassword') }}</label>
|
||||
<input type="password" class="control" name="password_confirmation">
|
||||
<span>@{{ errors.first('password') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="button-group">
|
||||
<input class="btn btn-primary btn-lg" type="submit" value="Update Profile">
|
||||
<input class="btn btn-primary btn-lg" type="submit" value="{{ __('shop::app.customer.account.profile.submit') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('shop::app.customer.account.profile.index.page-title') }}
|
||||
@endsection
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="account-content">
|
||||
|
|
@ -9,8 +11,8 @@
|
|||
<div class="account-lauyout = profile">
|
||||
|
||||
<div class="section-head">
|
||||
<span class="profile-heading"> profile</span>
|
||||
<span class="profile-edit"><a href="{{ route('customer.profile.edit') }}">Edit</a></span>
|
||||
<span class="profile-heading">{{ __('shop::app.customer.account.profile.index.title') }}</span>
|
||||
<span class="profile-edit"><a href="{{ route('customer.profile.edit') }}">{{ __('shop::app.customer.account.profile.index.edit') }}</a></span>
|
||||
<div class="horizontal-rule"></div>
|
||||
</div>
|
||||
|
||||
|
|
@ -18,32 +20,32 @@
|
|||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>First Name</td>
|
||||
<td>{{ __('shop::app.customer.account.profile.fname') }}</td>
|
||||
<td>{{ $customer['first_name'] }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Last Name</td>
|
||||
<td>{{ __('shop::app.customer.account.profile.lname') }}</td>
|
||||
<td>{{ $customer['last_name'] }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Gender Name</td>
|
||||
<td>{{ __('shop::app.customer.account.profile.gender') }}</td>
|
||||
<td>{{ $customer['gender'] }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Date of Birth</td>
|
||||
<td>{{ __('shop::app.customer.account.profile.dob') }}</td>
|
||||
<td>{{ $customer['date_of_birth'] }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Email Address</td>
|
||||
<td>{{ __('shop::app.customer.account.profile.email') }}</td>
|
||||
<td>{{ $customer['email'] }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Mobile</td>
|
||||
<td>{{ __('shop::app.customer.account.profile.phone') }}</td>
|
||||
<td>{{ $customer['phone'] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
@extends('shop::layouts.master')
|
||||
@section('page_title')
|
||||
{{ __('shop::app.customer.login-form.page-title') }}
|
||||
@endsection
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="content">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('shop::app.customer.forgot-password.page_title') }}
|
||||
@endsection
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="content">
|
||||
|
|
@ -10,15 +12,15 @@
|
|||
|
||||
<div class="login-form">
|
||||
|
||||
<div class="login-text">{{ __('shop::app.customer.forgot-password-form.title') }}</div>
|
||||
<div class="login-text">{{ __('shop::app.customer.forgot-password.title') }}</div>
|
||||
|
||||
<div class="control-group" :class="[errors.has('email') ? 'has-error' : '']">
|
||||
<label for="email">{{ __('shop::app.customer.forgot-password-form.email') }}</label>
|
||||
<label for="email">{{ __('shop::app.customer.forgot-password.email') }}</label>
|
||||
<input type="email" class="control" name="email" v-validate="'required|email'">
|
||||
<span class="control-error" v-if="errors.has('email')">@{{ errors.first('email') }}</span>
|
||||
</div>
|
||||
|
||||
<input class="btn btn-primary btn-lg" type="submit" value="{{ __('shop::app.customer.forgot-password-form.button_title') }}">
|
||||
<input class="btn btn-primary btn-lg" type="submit" value="{{ __('shop::app.customer.forgot-password.submit') }}">
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
@extends('shop::layouts.master')
|
||||
|
||||
@section('page_title')
|
||||
{{ __('shop::app.customer.signup-form.page-title') }}
|
||||
@endsection
|
||||
@section('content-wrapper')
|
||||
|
||||
<div class="content">
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@
|
|||
</div>
|
||||
|
||||
<div class="right-content">
|
||||
@guest('customer')
|
||||
<ul class="register-link" style="border-right: 2px solid #E8E8E8; ">
|
||||
<span class="icon account-icon"></span>
|
||||
<li><a href="{{ route('customer.register.index') }}">Sign Up</a></li>
|
||||
</ul>
|
||||
@endguest
|
||||
<ul class="account-dropdown-container">
|
||||
<li class="account-dropdown">
|
||||
|
||||
|
|
@ -30,7 +36,7 @@
|
|||
<div style="display: inline-block; cursor: pointer;">
|
||||
|
||||
@guest('customer')
|
||||
<span class="name">Login & Register</span>
|
||||
<span class="name">Sign In</span>
|
||||
@endguest
|
||||
|
||||
@auth('customer')
|
||||
|
|
@ -47,8 +53,6 @@
|
|||
<label>Account</label>
|
||||
<ul>
|
||||
<li><a href="{{ route('customer.session.index') }}">Sign In</a></li>
|
||||
|
||||
<li><a href="{{ route('customer.register.index') }}">Sign Up</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
|
@ -275,15 +279,12 @@
|
|||
@else
|
||||
<div class="dropdown-toggle">
|
||||
<div style="display: inline-block; cursor: pointer;">
|
||||
{{-- <span class="name"><span class="count"> 0
|
||||
</span>Products</span> --}}
|
||||
<span class="icon cart-icon"></span>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</li>
|
||||
</ul>
|
||||
{{-- <li class="cart-box"><span class="icon cart-icon"></span></li> --}}
|
||||
<li class="menu-box" ><span class="icon sortable-icon" id="hammenu"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue