diff --git a/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/create.blade.php b/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/create.blade.php index 3f3bee901..5a1a68b4f 100644 --- a/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/promotions/cart-rule/create.blade.php @@ -162,7 +162,7 @@
@@ -256,11 +256,13 @@ apply_prct: false, apply_to_shipping: null, buy_atleast: null, + attribute_options: @json($criteria[1]), cart_attributes: @json($criteria[0]).cart, cart_attr: { attribute: null, condition: null, - value: null + value: null, + type: null }, cart_attrs: [], cart_attrs_count: 0, @@ -334,8 +336,6 @@ this.cart_attrs[pushedIndex].type = this.cart_attributes[i].type; } } - - }, removeCartAttr(index) { diff --git a/packages/Webkul/Discount/src/Config/cart-attributes.php b/packages/Webkul/Discount/src/Config/cart-attributes.php index e4db3b307..f007ea7b7 100644 --- a/packages/Webkul/Discount/src/Config/cart-attributes.php +++ b/packages/Webkul/Discount/src/Config/cart-attributes.php @@ -41,15 +41,16 @@ return [ 'conditions' => [ 'numeric' => [ - 0 => 'Greater than', - 1 => 'Lesser than', - 2 => 'Equals' + 0 => 'Equals', + 1 => 'Equals or greater', + 2 => 'Equals or lesser', + 3 => 'Greater than', + 4 => 'Lesser than', ], 'text' => [ 0 => 'is', - 1 => 'is any of', - 2 => 'contains' + 1 => 'is not' ], ] ]; \ No newline at end of file diff --git a/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php b/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php index 525dfd5d1..128e43c76 100644 --- a/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php +++ b/packages/Webkul/Discount/src/Http/Controllers/CartRuleController.php @@ -11,6 +11,7 @@ use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; use Webkul\Category\Repositories\CategoryRepository as Category; use Webkul\Product\Repositories\ProductFlatRepository as Product; use Webkul\Discount\Repositories\CartRuleRepository as CartRule; +use Webkul\Checkout\Repositories\CartRepository as Cart; /** * Cart Rule controller @@ -53,22 +54,22 @@ class CartRuleController extends Controller /** * To hold the Cart repository instance */ - protected $CartRule; + protected $cartRule; - public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product, CartRule $CartRule) + /** + * To hold the cart repository instance + */ + protected $cart; + + public function __construct(Attribute $attribute, AttributeFamily $attributeFamily, Category $category, Product $product, CartRule $cartRule, Cart $cart) { $this->_config = request('_config'); - $this->attribute = $attribute; - $this->attributeFamily = $attributeFamily; - $this->category = $category; - $this->product = $product; - - $this->CartRule = $CartRule; - + $this->CartRule = $cartRule; + $this->cart = $cart; $this->appliedConfig = [ 0 => trans('admin::app.promotion.Cart.apply-percent'), 1 => trans('admin::app.promotion.Cart.apply-fixed'), @@ -84,9 +85,11 @@ class CartRuleController extends Controller public function create() { - // dd(config('pricerules')); + $countries = core()->getAllCountries(); - return view($this->_config['view'])->with('criteria', [config('pricerules')]); + $attributesWithOptions = $this->fetchOptionableAttributes(); + + return view($this->_config['view'])->with('criteria', [config('pricerules'), $attributesWithOptions]); } public function store() @@ -101,11 +104,19 @@ class CartRuleController extends Controller 'apply' => 'numeric|min:1|max:4' ]); - $CartRule = $this->CartRule->create(request()->all()); + $cartRule = $this->cartRule->create(request()->all()); } - public function fetchAttribute() + public function fetchOptionableAttributes() { - return request()->all(); + $attributesWithOptions = array(); + + foreach($this->attribute->all() as $attribute) { + if (($attribute->type == 'select' || $attribute->type == 'multiselect') && $attribute->code != 'tax_category_id') { + $attributesWithOptions[$attribute->admin_name] = $attribute->options->toArray(); + } + } + + return $attributesWithOptions; } } diff --git a/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php b/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php index 3923c1034..e7d46f422 100644 --- a/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php +++ b/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php @@ -4,7 +4,6 @@ namespace Webkul\Discount\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Http\Response; -use Illuminate\Routing\Controller; use Webkul\Attribute\Repositories\AttributeRepository as Attribute; use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; @@ -84,9 +83,13 @@ class CatalogRuleController extends Controller 'channels' => 'required|array', 'starts_from' => 'required|date_format:Y-m-d H:i:s', 'ends_till' => 'required|date_format:Y-m-d H:i:s', - 'apply' => 'numeric|min:1|max:4' + 'priority' => 'required|numeric', + 'criteria' => 'required', + 'apply' => 'required|numeric|min:1|max:4' ]); + dd(request()->all()); + $catalogRule = $this->catalogRule->create(request()->all()); }