sarga/packages/Webkul/Shop/src/Http/Controllers/CartController.php

317 lines
8.2 KiB
PHP
Raw Normal View History

2018-09-06 06:20:30 +00:00
<?php
2018-09-28 13:28:54 +00:00
namespace Webkul\Shop\Http\Controllers;
2018-09-06 06:20:30 +00:00
use Illuminate\Http\Request;
use Illuminate\Http\Response;
2018-09-28 13:28:54 +00:00
use Webkul\Checkout\Repositories\CartRepository;
use Webkul\Checkout\Repositories\CartItemRepository;
2018-09-20 10:00:52 +00:00
use Webkul\Product\Repositories\ProductRepository;
2018-09-10 09:31:34 +00:00
use Webkul\Customer\Repositories\CustomerRepository;
2019-04-02 07:54:11 +00:00
use Webkul\Customer\Repositories\WishlistRepository;
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
use Webkul\Discount\Repositories\CartRuleCartRepository as CartRuleCart;
2019-01-07 10:30:28 +00:00
use Illuminate\Support\Facades\Event;
use Cart;
2018-09-06 06:20:30 +00:00
/**
2018-10-10 10:26:27 +00:00
* Cart controller for the customer and guest users for adding and
* removing the products in the cart.
2018-09-06 06:20:30 +00:00
*
2018-10-26 07:28:38 +00:00
* @author Prashant Singh <prashant.singh852@webkul.com> @prashant-webkul
2018-09-06 06:20:30 +00:00
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
class CartController extends Controller
{
/**
2018-10-10 10:26:27 +00:00
* Protected Variables that holds instances of the repository classes.
2018-09-06 06:20:30 +00:00
*
* @param Array $_config
* @param $cart
* @param $cartItem
* @param $customer
* @param $product
* @param $productView
2018-09-06 06:20:30 +00:00
*/
protected $_config;
protected $cart;
protected $cartItem;
2018-09-10 09:31:34 +00:00
protected $customer;
2018-09-20 10:00:52 +00:00
protected $product;
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
protected $cartRuleCart;
2019-03-28 10:06:48 +00:00
protected $suppressFlash = false;
2019-04-02 07:54:11 +00:00
/**
* WishlistRepository Repository object
*
* @var array
*/
protected $wishlist;
public function __construct(
CartRepository $cart,
CartItemRepository $cartItem,
CustomerRepository $customer,
ProductRepository $product,
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
WishlistRepository $wishlist,
CartRuleCart $cartRuleCart
)
{
2018-10-30 11:22:36 +00:00
$this->middleware('customer')->only(['moveToWishlist']);
2018-09-10 09:31:34 +00:00
$this->customer = $customer;
2018-09-06 06:20:30 +00:00
$this->cart = $cart;
2018-09-10 09:31:34 +00:00
$this->cartItem = $cartItem;
2018-09-20 10:00:52 +00:00
$this->product = $product;
2019-04-02 07:54:11 +00:00
$this->wishlist = $wishlist;
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
$this->cartRuleCart = $cartRuleCart;
$this->_config = request('_config');
2018-09-10 09:31:34 +00:00
}
2018-09-26 04:21:14 +00:00
/**
2018-10-04 06:43:49 +00:00
* Method to populate the cart page which will be populated before the checkout process.
2018-09-26 04:21:14 +00:00
*
* @return Mixed
*/
2019-01-07 10:30:28 +00:00
public function index()
{
2018-09-26 04:21:14 +00:00
return view($this->_config['view'])->with('cart', Cart::getCart());
}
2018-09-11 11:19:40 +00:00
/**
2018-10-10 10:26:27 +00:00
* Function for guests user to add the product in the cart.
2018-09-11 11:19:40 +00:00
*
* @return Mixed
*/
2019-01-07 10:30:28 +00:00
public function add($id)
{
2019-01-18 11:10:40 +00:00
try {
Event::fire('checkout.cart.add.before', $id);
2019-01-07 10:30:28 +00:00
2019-01-18 11:10:40 +00:00
$result = Cart::add($id, request()->except('_token'));
2018-10-26 07:05:19 +00:00
2019-01-18 11:10:40 +00:00
Event::fire('checkout.cart.add.after', $result);
2019-01-07 10:30:28 +00:00
Cart::collectTotals();
2019-01-18 11:10:40 +00:00
if ($result) {
session()->flash('success', trans('shop::app.checkout.cart.item.success'));
2019-04-02 07:54:11 +00:00
if (auth()->guard('customer')->user()) {
$customer = auth()->guard('customer')->user();
if (count($customer->wishlist_items)) {
foreach ($customer->wishlist_items as $wishlist) {
if ($wishlist->product_id == $id) {
$this->wishlist->delete($wishlist->id);
}
}
}
}
2019-03-28 08:59:45 +00:00
return redirect()->back();
2019-01-18 11:10:40 +00:00
} else {
session()->flash('warning', trans('shop::app.checkout.cart.item.error-add'));
2018-09-14 13:15:49 +00:00
return redirect()->back();
}
2018-10-18 09:31:19 +00:00
2019-01-18 11:10:40 +00:00
return redirect()->route($this->_config['redirect']);
} catch(\Exception $e) {
session()->flash('error', trans($e->getMessage()));
2019-01-29 10:35:30 +00:00
2019-01-18 11:10:40 +00:00
return redirect()->back();
}
2018-09-06 06:20:30 +00:00
}
2018-09-28 12:55:48 +00:00
/**
2018-10-10 10:26:27 +00:00
* Removes the item from the cart if it exists
2018-09-28 12:55:48 +00:00
*
* @param integer $itemId
*/
2019-01-07 10:30:28 +00:00
public function remove($itemId)
{
Event::fire('checkout.cart.delete.before', $itemId);
2018-09-28 12:55:48 +00:00
Cart::removeItem($itemId);
2019-01-07 10:30:28 +00:00
Event::fire('checkout.cart.delete.after', $itemId);
2018-10-18 09:31:19 +00:00
Cart::collectTotals();
2018-09-28 12:55:48 +00:00
return redirect()->back();
}
/**
2018-10-10 10:26:27 +00:00
* Updates the quantity of the items present in the cart.
2018-09-28 12:55:48 +00:00
*
* @return response
*/
2019-01-07 10:30:28 +00:00
public function updateBeforeCheckout()
{
2019-06-07 11:06:50 +00:00
try {
$request = request()->except('_token');
2018-09-28 12:55:48 +00:00
2019-06-07 11:06:50 +00:00
foreach ($request['qty'] as $id => $quantity) {
if ($quantity <= 0) {
session()->flash('warning', trans('shop::app.checkout.cart.quantity.illegal'));
2018-10-04 06:43:49 +00:00
2019-06-07 11:06:50 +00:00
return redirect()->back();
}
2018-10-04 06:43:49 +00:00
}
2019-06-07 11:06:50 +00:00
foreach ($request['qty'] as $key => $value) {
$item = $this->cartItem->findOneByField('id', $key);
2019-06-07 11:06:50 +00:00
$data['quantity'] = $value;
2019-06-07 11:06:50 +00:00
Event::fire('checkout.cart.update.before', $item);
2019-01-07 10:30:28 +00:00
2019-06-07 11:06:50 +00:00
$result = Cart::updateItem($item->product_id, $data, $key);
2019-03-28 10:06:48 +00:00
2019-06-07 11:06:50 +00:00
if ($result == false) {
$this->suppressFlash = true;
}
2019-06-07 11:06:50 +00:00
Event::fire('checkout.cart.update.after', $item);
2019-01-07 10:30:28 +00:00
2019-06-07 11:06:50 +00:00
unset($item);
unset($data);
}
2018-09-14 13:15:49 +00:00
2019-06-07 11:06:50 +00:00
Cart::collectTotals();
2018-10-18 09:31:19 +00:00
2019-06-07 11:06:50 +00:00
if ($this->suppressFlash) {
session()->forget('success');
session()->forget('warning');
session()->flash('info', trans('shop::app.checkout.cart.partial-cart-update'));
}
} catch(\Exception $e) {
session()->flash('error', trans($e->getMessage()));
2019-03-28 10:06:48 +00:00
}
2018-09-14 13:15:49 +00:00
return redirect()->back();
2018-09-11 11:19:40 +00:00
}
2018-10-12 11:15:55 +00:00
/**
* Add the configurable product
* to the cart.
*
* @return response
*/
2019-01-07 10:30:28 +00:00
public function addConfigurable($slug)
{
2018-10-12 11:15:55 +00:00
session()->flash('warning', trans('shop::app.checkout.cart.add-config-warning'));
return redirect()->route('shop.products.index', $slug);
}
public function buyNow($id, $quantity = 1)
2019-01-07 10:30:28 +00:00
{
2019-01-18 11:10:40 +00:00
Event::fire('checkout.cart.add.before', $id);
2019-06-03 10:59:00 +00:00
$result = Cart::proceedToBuyNow($id, $quantity);
2018-10-26 07:05:19 +00:00
2019-01-18 11:10:40 +00:00
Event::fire('checkout.cart.add.after', $result);
2018-10-30 11:22:36 +00:00
Cart::collectTotals();
2019-01-15 11:54:41 +00:00
if (! $result) {
2018-10-26 07:05:19 +00:00
return redirect()->back();
2018-10-30 11:22:36 +00:00
} else {
return redirect()->route('shop.checkout.onepage.index');
2018-10-26 07:05:19 +00:00
}
2018-09-27 10:07:54 +00:00
}
2018-10-30 04:31:01 +00:00
/**
* Function to move a already added product to wishlist
* will run only on customer authentication.
*
* @param instance cartItem $id
*/
2019-01-07 10:30:28 +00:00
public function moveToWishlist($id)
{
2018-10-30 04:31:01 +00:00
$result = Cart::moveToWishlist($id);
2019-01-15 11:54:41 +00:00
if (! $result) {
2018-10-30 11:22:36 +00:00
Cart::collectTotals();
session()->flash('success', trans('shop::app.wishlist.moved'));
2018-10-30 11:22:36 +00:00
return redirect()->back();
} else {
session()->flash('warning', trans('shop::app.wishlist.move-error'));
2018-10-30 11:22:36 +00:00
return redirect()->back();
}
2018-10-30 04:31:01 +00:00
}
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
/**
* To apply coupon rules
*/
public function applyCoupon()
{
$this->validate(request(), [
'code' => 'string|required'
]);
$code = request()->input('code');
$result = Cart::applyCoupon($code);
if ($result != null) {
return response()->json([
'success' => true,
'message' => trans('shop::app.checkout.onepage.total.coupon-applied'),
'result' => $result
]);
} else {
return response()->json([
'success' => false,
'message' => trans('shop::app.checkout.onepage.total.cannot-apply-coupon'),
'result' => null
]);
}
Cart rule inside promotions, various improvements and fixes. (#964) * Some syntax issue fixes * Adding discount things inside promotions in admin * routes updated for creating discount rules * fixed customer profile redirect parameter issue * added cart and catalog rule routes to admin section * migrations for discount almost to be finished, final revision left * migrations for discounts complete * catalog rule form underway * catalog rule * Made some dynamic form fields in catalog rule create form * made some changes for custom validations used in ProductForm request class * working on prepopulating the values fields in conditions * need another revisit on discount rules tables and then prepare for actions * removed discounts table * catalog rule form changed to muliti attribute set for single condition * new icons added for promotion and customer note. new action for customer added to take notes on the customers * catalog and cart rule designs stable, now moving towards validations on client side and backend * catalog rules migrations added * catalog rule models added with contracts and proxies * fixed customer group bug in customer registration controller * fixed customer registration bug due to last fix * fixed product card image not found issue * catalog rule translations added * Added migrations for cart rules and catalog rule products their contracts and remaining necessary files related to them. * making cart attributes for cart rules * Added more fields for cart rules * working on conditions for cart rule form * minor changes in migrations related to price rules * currency and locale switcher now only available for a channel on storefront when more than on locale and currency are assigned to that channel * part of conditions on the cart rule form added * daily sync * cart rate migrations updated * Added select and multi select attributes options fetching with ajax on catalog rule form * changed some migrations and data being populated at runtime inside catalog rule form * catalog rule create complete, migrations changes, translations added * catalog rule edit form complete * catalog rule form complete, now moving towards catalog rule products * added delete functionality for catalog rules * added cart rule preferences for coupon codes * cart rule submission problem due to repository issue * Cart rule form and migrations complete * Models and Repositories updated for cart rule usage * base sync with master * designing process to get suitable discount rules * cart rule form completed * added helpers in cart and discount to apply rules on cart at checkout or not * cart rule coupon implementation in progress for discount coupon in shop checkout pages * cart rules working * added coupon box on checkout screen * removed the conditions empty bug * Nearing to completion of coupon based rules * made some changes in cart rule coupon application on checkout related to new designs * some bug fixes * calculation for automatic cart rules complete * non couponable cart rules implemented, now moving on to binding them on frontend * some conditions improvements in couponable cart rules * some bug fixes * removed some bugs from summary blade for cart rule * added the table for cart rule cart for managing rules with cart and removed various bug fixes * some bug fixes * Removed bugs and added coupon based cart rule removal functionality * some bug fixes * cart rule labels refactoring in midway * Cart rule labels bug fixed * removed margin classes from shop to UI * Refactoring cart rule on front end * added checks * Discount rule implemented. * cart rule bug fixes * provision to remove the couponable and non couponable rule had been added * Cart rule frontend work done * altered some frontend variables on onepage checkout * Altered cart rules to some extent
2019-06-10 07:49:05 +00:00
return $result;
}
/**
* Fetch the non couponable rule
*/
public function getNonCouponAbleRule()
{
$cart = Cart::getCart();
$nonCouponAbleRules = Cart::applyNonCoupon();
return $nonCouponAbleRules;
}
/**
* To remove the currently active
* couponable rule
*/
public function removeCoupon()
{
$result = Cart::removeCoupon();
if ($result) {
return response()->json([
'success' => true,
'message' => trans('admin::app.promotion.status.coupon-removed')
]);
} else {
return response()->json([
'success' => false,
'message' => trans('admin::app.promotion.status.coupon-remove-failed')
]);
}
}
2018-09-06 06:20:30 +00:00
}