diff --git a/packages/Webkul/Admin/src/Resources/lang/en/app.php b/packages/Webkul/Admin/src/Resources/lang/en/app.php index 13cd8d477..31da14d13 100755 --- a/packages/Webkul/Admin/src/Resources/lang/en/app.php +++ b/packages/Webkul/Admin/src/Resources/lang/en/app.php @@ -764,8 +764,10 @@ return [ 'add-cart-rule' => 'Add Cart Rule', 'create-catalog-rule' => 'Create Catalog Rule', 'create-cart-rule' => 'Create Cart Rule', - 'create' => 'Create', 'save-btn-title' => 'Create', + 'select-attr' => 'Select Attribute', + 'select-attr-fam' => 'Select Attribute Family', + 'select-cart-attr' => 'Select Cart Attribute', 'general-info' => [ 'name' => 'Rule Name', 'description' => 'Description', diff --git a/packages/Webkul/Admin/src/Resources/views/promotions/catalog-rule/create.blade.php b/packages/Webkul/Admin/src/Resources/views/promotions/catalog-rule/create.blade.php index 7be9ba138..9a656836c 100644 --- a/packages/Webkul/Admin/src/Resources/views/promotions/catalog-rule/create.blade.php +++ b/packages/Webkul/Admin/src/Resources/views/promotions/catalog-rule/create.blade.php @@ -97,33 +97,76 @@ @{{ errors.first('criteria') }} - Add Condition + Select Condition
- + @{{ errors.first('attribute') }}
+
+ + + @{{ errors.first('attribute_family') }} +
+
- + @{{ errors.first('cart_attribute') }}
+
+
+ + + + + + + @{{ errors.first('cart_attr') }} +
+ +
+ + + + + + + @{{ errors.first('attr') }} +
+ +
+ + + + + + + @{{ errors.first('attr_fam') }} +
+
@@ -133,36 +176,81 @@ inject: ['$validator'], - data() { + data () { return { - criteria: @json($criteria[0]), attributes: @json($criteria[1]), attribute: null, - attribute_families: null, - name: null, - description: null, + attribute_families: @json($criteria[2]), + attribute_family: null, + cart_attribute: null, channels: [], + criteria: @json($criteria[0]), + conditions: [], + cart_attr: { + cart_attribute : null, + condition_one: null, + value_one: null, + condition_two: null, + value_two: null + }, + attr_family: { + attribute_family : null, + condition_one: null, + value_one: null, + condition_two: null, + value_two: null + }, + attr: { + attribute : null, + condition_one: null, + value_one: null, + condition_two: null, + value_two: null + }, customer_groups: [], - criteria: null, - priority: 0, - starts_from: null, + description: null, ends_till: null, enableAttribute: false, - enableCartAttribute: false + enableCartAttribute: false, + enableAttributeFamily: false, + enableCartAttrLine: false, + enableAttrLine: false, + enableAttrFamLine: false, + name: null, + priority: 0, + starts_from: null } }, - mounted() { - console.log(this.attribute); + mounted () { + console.log(this.criteria.cart); + + for(index in this.criteria.cart) { + console.log(this.criteria.cart[index]); + } }, methods: { - addCondition() { - if (this.criteria == "attribute_family") { + addCondition () { + if (this.criteria == "attribute" || this.criteria == "attribute_family" || this.criteria == "cart_attribute") { + this.condition_on = this.criteria; + } else { + alert('please try again'); + } + + if (this.condition_on == "attribute") { + this.attr.push(); + this.enableAttribute = true; this.enableCartAttribute = false; - } else if (this.criteria == "cart_attribute") { + this.enableAttributeFamily = false; + } else if (this.condition_on == "attribute_family") { + this.enableAttributeFamily = true; + this.enableAttribute = false; + this.enableCartAttribute = false; + } else { this.enableCartAttribute = true; + this.enableAttributeFamily = false; this.enableAttribute = false; } } diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php index 3deb198de..fdc933d52 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeFamilyRepository.php @@ -153,6 +153,23 @@ class AttributeFamilyRepository extends Repository return $family; } + public function getNameAndId() + { + $attributeFamilies = $this->model->all(); + $trimmed = array(); + + foreach($attributeFamilies as $key => $attributeFamily) { + if ($attributeFamily->name != null || $attributeFamily->name != "") { + $trimmed[$key] = [ + 'id' => $attributeFamily->id, + 'name' => $attributeFamily->name + ]; + } + } + + return $trimmed; + } + /** * @param $id * @return void diff --git a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php index 7ac578dab..8ad18a1ed 100755 --- a/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php +++ b/packages/Webkul/Attribute/src/Repositories/AttributeRepository.php @@ -222,10 +222,12 @@ class AttributeRepository extends Repository $trimmed = array(); foreach($attributes as $key => $attribute) { - $trimmed[$key] = [ - 'id' => $attribute->id, - 'name' => $attribute->name - ]; + if ($attribute->name != null || $attribute->name != "") { + $trimmed[$key] = [ + 'id' => $attribute->id, + 'name' => $attribute->name + ]; + } } return $trimmed; diff --git a/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php b/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php index 64b7b583c..4155adf31 100644 --- a/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php +++ b/packages/Webkul/Discount/src/Http/Controllers/CatalogRuleController.php @@ -7,6 +7,7 @@ use Illuminate\Http\Response; use Illuminate\Routing\Controller; use Webkul\Attribute\Repositories\AttributeRepository as Attribute; +use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily; /** * Catalog Rule controller @@ -18,11 +19,13 @@ class CatalogRuleController extends Controller { protected $_config; protected $attribute; + protected $attributeFamily; - public function __construct(Attribute $attribute) + public function __construct(Attribute $attribute, AttributeFamily $attributeFamily) { $this->_config = request('_config'); $this->attribute = $attribute; + $this->attributeFamily = $attributeFamily; } public function index() @@ -39,14 +42,22 @@ class CatalogRuleController extends Controller 2 => 'grand_total' ], - 'product' => [ + 'attribute' => [ 0 => 'attribute', 1 => 'attribute_groups', 2 => 'attribute_familes' ] ]; - return view($this->_config['view'])->with('criteria', [$ruleCriterias, $this->attribute->getNameAndId()]); + $arr = array(); + + foreach($ruleCriterias as $key => $ruleCriteria) { + array_push($arr, $ruleCriteria); + } + + $arr; + + return view($this->_config['view'])->with('criteria', [$ruleCriterias, $this->attribute->getNameAndId(), $this->attributeFamily->getNameAndId()]); } public function store() diff --git a/packages/Webkul/Shipping/src/Config/carriers.php b/packages/Webkul/Shipping/src/Config/carriers.php index 8c4524da0..5562a3f53 100755 --- a/packages/Webkul/Shipping/src/Config/carriers.php +++ b/packages/Webkul/Shipping/src/Config/carriers.php @@ -16,6 +16,7 @@ return [ 'title' => 'Free Shipping', 'description' => 'This is a free shipping', 'active' => true, + 'default_rate' => '0', 'class' => 'Webkul\Shipping\Carriers\Free', ] ]; \ No newline at end of file