Skip to content

Commit

Permalink
fix qty
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Dec 17, 2024
1 parent c635ce2 commit 7fa9dcd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public function getConditionAttributes()
* example={{
* "value": "2",
* "operator": ">=",
* "attribute": "cart|items_qty",
* "attribute": "cart_item|quantity",
* "attribute_type": "integer",
* "price": "10.50"
* }},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,27 +303,28 @@ public function createProductQuantityRule($product_id, Request $request){
], 404);
}

$request->set('product_id', $product_id);
$request->set('name', $product->name);
$request->set('channels', ['all']);
$request->set('customer_groups', ['all']);
$request->set('coupon_type', 0);


// create a new cart rule for the product quantity
$request->validate([
'name' => 'required',
'channels' => 'required|array|min:1',
'customer_groups' => 'required|array|min:1',
'coupon_type' => 'required',
'use_auto_generation' => 'required_if:coupon_type,==,1',
'coupon_code' => 'required_if:use_auto_generation,==,0|unique:cart_rule_coupons,code',
'starts_from' => 'nullable|date',
'ends_till' => 'nullable|date|after_or_equal:starts_from',
'action_type' => 'required',
'discount_amount' => 'required|numeric',
'product_id' => 'required|integer',
'rules' => 'required|array|min:1',
]);

$cartRule = app(\Webkul\CartRule\Repositories\CartRuleRepository::class);

$cartRuleData = [
'name' => $product->name,
'description' => $product->description,
'channels' => [1],
'customer_groups' => [1],
'coupon_type' => 0,
'use_auto_generation' => 1,
'starts_from' => null,
'ends_till' => null,
'action_type' => 1,
'discount_amount' => 0,
];

Event::dispatch('promotions.cart_rule.create.before');

$cartRule = $this->getRepositoryInstance()->create($request->all());
Expand Down

0 comments on commit 7fa9dcd

Please sign in to comment.