Fixed conflicts
This commit is contained in:
commit
6e8c0da054
|
|
@ -821,7 +821,7 @@ return [
|
|||
'cust-groups' => 'Customer Groups',
|
||||
'priority' => 'Priority',
|
||||
'add-condition' => 'Add Conditions',
|
||||
'disc_amt' => 'Discount Amount',
|
||||
'disc_amt' => 'Discount Amount(B)',
|
||||
'disc_percent' => 'Discount Percentage',
|
||||
'is-coupon' => 'Use Coupon',
|
||||
'is-coupon-yes' => 'Yes',
|
||||
|
|
@ -844,6 +844,7 @@ return [
|
|||
'free-shipping' => 'Free Shipping',
|
||||
'is-guest' => 'For Guests',
|
||||
'disc_qty' => 'Max. Quantity Allowed To Be Discounted',
|
||||
'test-mode' => 'Choose how to test conditions'
|
||||
],
|
||||
|
||||
'status' => [
|
||||
|
|
|
|||
|
|
@ -179,13 +179,22 @@
|
|||
<div class="control-group">
|
||||
<label for="criteria" class="required">{{ __('admin::app.promotion.general-info.add-condition') }}</label>
|
||||
|
||||
<select type="text" class="control" name="criteria" v-model="criteria">
|
||||
<select type="text" class="control" v-model="criteria">
|
||||
<option value="cart">Cart Properties</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 mb-10"><b>Any of the condition is true</b></div>
|
||||
<div class="control-group">
|
||||
{{ __('admin::app.promotion.general-info.test-mode') }}
|
||||
<select class="control" v-model="match_criteria" style="margin-right: 15px;">
|
||||
{{ $i = 0 }}
|
||||
@foreach(config('pricerules.test_mode') as $key => $value)
|
||||
<option value="{{ $key }}">{{ $value }}</option>
|
||||
{{ $i++ }}
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="condition-set">
|
||||
<!-- Cart Attributes -->
|
||||
|
|
@ -418,6 +427,7 @@
|
|||
free_shipping: null,
|
||||
|
||||
all_conditions: [],
|
||||
match_criteria: 'all_are_true',
|
||||
|
||||
code: null,
|
||||
suffix: null,
|
||||
|
|
@ -441,7 +451,6 @@
|
|||
actions: @json($cart_rule[0]).actions,
|
||||
conditions_list:[],
|
||||
cart_object: {
|
||||
criteria: null,
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: []
|
||||
|
|
@ -516,13 +525,17 @@
|
|||
},
|
||||
|
||||
onSubmit: function (e) {
|
||||
if (this.conditions_list.length != 0) {
|
||||
this.conditions_list.test_mode = this.match_criteria;
|
||||
}
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
|
||||
this.$validator.validateAll().then(result => {
|
||||
if (result) {
|
||||
e.target.submit();
|
||||
}
|
||||
});
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
},
|
||||
|
||||
addFlashMessages() {
|
||||
|
|
|
|||
|
|
@ -179,13 +179,22 @@
|
|||
<div class="control-group">
|
||||
<label for="criteria" class="required">{{ __('admin::app.promotion.general-info.add-condition') }}</label>
|
||||
|
||||
<select type="text" class="control" name="criteria" v-model="criteria">
|
||||
<select type="text" class="control" v-model="criteria">
|
||||
<option value="cart">Cart Properties</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 mb-10"><b>Any of the condition is true</b></div>
|
||||
<div class="control-group">
|
||||
{{ __('admin::app.promotion.general-info.test-mode') }}
|
||||
<select class="control" v-model="match_criteria" style="margin-right: 15px;">
|
||||
{{ $i = 0 }}
|
||||
@foreach(config('pricerules.test_mode') as $key => $value)
|
||||
<option value="{{ $key }}">{{ $value }}</option>
|
||||
{{ $i++ }}
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="condition-set">
|
||||
<!-- Cart Attributes -->
|
||||
|
|
@ -405,6 +414,7 @@
|
|||
free_shipping: null,
|
||||
|
||||
all_conditions: null,
|
||||
match_criteria: 'all_are_true',
|
||||
|
||||
code: null,
|
||||
suffix: null,
|
||||
|
|
@ -427,7 +437,6 @@
|
|||
actions: @json($cart_rule[0]).actions,
|
||||
conditions_list:[],
|
||||
cart_object: {
|
||||
criteria: null,
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: []
|
||||
|
|
@ -511,7 +520,6 @@
|
|||
this.conditions_list.push(this.cart_object);
|
||||
|
||||
this.cart_object = {
|
||||
criteria: null,
|
||||
attribute: null,
|
||||
condition: null,
|
||||
value: []
|
||||
|
|
@ -559,13 +567,20 @@
|
|||
},
|
||||
|
||||
onSubmit: function (e) {
|
||||
|
||||
// if (this.conditions_list.length != 0) {
|
||||
// this.conditions_list.push(this.match_criteria);
|
||||
// }
|
||||
|
||||
console.log(JSON.stringify(this.conditions_list));
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
|
||||
this.$validator.validateAll().then(result => {
|
||||
if (result) {
|
||||
e.target.submit();
|
||||
}
|
||||
});
|
||||
|
||||
this.all_conditions = JSON.stringify(this.conditions_list);
|
||||
},
|
||||
|
||||
addFlashMessages() {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ return [
|
|||
0 => 'admin::app.promotion.catalog.apply-percent',
|
||||
1 => 'admin::app.promotion.catalog.apply-fixed',
|
||||
2 => 'admin::app.promotion.catalog.adjust-to-percent',
|
||||
3 => 'admin::app.promotion.catalog.adjust-to-value'
|
||||
// 3 => 'admin::app.promotion.catalog.adjust-to-value'
|
||||
],
|
||||
|
||||
'attributes' => [
|
||||
|
|
@ -85,10 +85,6 @@ return [
|
|||
'<=' => 'Lesser or equals',
|
||||
'>' => 'Greater than',
|
||||
'<' => 'Lesser than',
|
||||
'{}' => 'Contains'
|
||||
// '!{}' => 'Does not contains',
|
||||
// '()' => 'Is one of',
|
||||
// '!()' => 'Not is one of'
|
||||
],
|
||||
|
||||
'text' => [
|
||||
|
|
@ -99,8 +95,6 @@ return [
|
|||
'<' => 'Lesser than',
|
||||
'{}' => 'Contains',
|
||||
'!{}' => 'Does not contains'
|
||||
// '()' => 'Is one of',
|
||||
// '!()' => 'Not is one of'
|
||||
],
|
||||
|
||||
'string' => [
|
||||
|
|
@ -111,8 +105,6 @@ return [
|
|||
'<' => 'Lesser than',
|
||||
'{}' => 'Contains',
|
||||
'!{}' => 'Does not contains'
|
||||
// '()' => 'Is one of',
|
||||
// '!()' => 'Not is one of'
|
||||
],
|
||||
|
||||
'boolean' => [
|
||||
|
|
@ -171,9 +163,9 @@ return [
|
|||
],
|
||||
|
||||
'test_mode' => [
|
||||
0 => 'all_are_true',
|
||||
1 => 'all_are_false',
|
||||
2 => 'any_of_true',
|
||||
3 => 'all_of_false'
|
||||
'all_are_true' => 'All conditions are true',
|
||||
'all_are_false' => 'All conditions are false',
|
||||
'any_is_true' => 'Any condition is true',
|
||||
'any_is_false' => 'Any condition is false'
|
||||
]
|
||||
];
|
||||
|
|
@ -114,6 +114,18 @@ class Discount
|
|||
|
||||
if ($canBeApplied->count()) {
|
||||
$this->save(array_first($canBeApplied)['rule']);
|
||||
$itemId = array_first($canBeApplied);
|
||||
|
||||
foreach (\Cart::getCart()->items as $item) {
|
||||
if ($item->id == $itemId['item_id']) {
|
||||
$item->update([
|
||||
'discount_amount' => array_first($canBeApplied)['discount'],
|
||||
'base_discount_amount' => array_first($canBeApplied)['discount']
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return array_first($canBeApplied);
|
||||
} else {
|
||||
|
|
@ -307,6 +319,7 @@ class Discount
|
|||
}
|
||||
}
|
||||
|
||||
$report['item_id'] = $leastWorthItem['id'];
|
||||
$report['discount'] = $amountDiscounted;
|
||||
$report['formatted_discount'] = core()->formatPrice($amountDiscounted, $cart->cart_currency_code);
|
||||
$report['new_grand_total'] = $cart->grand_total - $amountDiscounted;
|
||||
|
|
|
|||
|
|
@ -2,16 +2,10 @@
|
|||
|
||||
namespace Webkul\Discount\Http\Controllers;
|
||||
|
||||
use Webkul\Attribute\Repositories\AttributeRepository as Attribute;
|
||||
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\CatalogRuleRepository as CatalogRule;
|
||||
use Webkul\Discount\Repositories\CartRuleRepository as CartRule;
|
||||
use Webkul\Checkout\Repositories\CartRepository as Cart;
|
||||
use Webkul\Discount\Repositories\CartRuleLabelsRepository as CartRuleLabels;
|
||||
use Webkul\Discount\Repositories\CartRuleCouponsRepository as CartRuleCoupons;
|
||||
use Validator;
|
||||
|
||||
/**
|
||||
* Cart Rule controller
|
||||
|
|
@ -26,26 +20,6 @@ class CartRuleController extends Controller
|
|||
*/
|
||||
protected $_config;
|
||||
|
||||
/**
|
||||
* Attribute $attribute
|
||||
*/
|
||||
protected $attribute;
|
||||
|
||||
/**
|
||||
* AttributeFamily $attributeFamily
|
||||
*/
|
||||
protected $attributeFamily;
|
||||
|
||||
/**
|
||||
* Category $category
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* Product $product
|
||||
*/
|
||||
protected $product;
|
||||
|
||||
/**
|
||||
* Property for Cart rule application
|
||||
*/
|
||||
|
|
@ -72,11 +46,6 @@ class CartRuleController extends Controller
|
|||
protected $cart;
|
||||
|
||||
public function __construct(
|
||||
Attribute $attribute,
|
||||
AttributeFamily $attributeFamily,
|
||||
Category $category,
|
||||
Product $product,
|
||||
CatalogRule $catalogRule,
|
||||
CartRule $cartRule,
|
||||
CartRuleCoupons $cartRuleCoupon,
|
||||
CartRuleLabels $cartRuleLabel
|
||||
|
|
@ -84,42 +53,39 @@ class CartRuleController extends Controller
|
|||
{
|
||||
$this->_config = request('_config');
|
||||
|
||||
$this->attribute = $attribute;
|
||||
|
||||
$this->attributeFamily = $attributeFamily;
|
||||
|
||||
$this->category = $category;
|
||||
|
||||
$this->product = $product;
|
||||
|
||||
$this->cartRule = $cartRule;
|
||||
|
||||
$this->cartRuleCoupon = $cartRuleCoupon;
|
||||
|
||||
|
||||
$this->cartRuleLabel = $cartRuleLabel;
|
||||
|
||||
$this->appliedConfig = config('pricerules.cart');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view($this->_config['view']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return view($this->_config['view'])->with('cart_rule', [
|
||||
$this->appliedConfig,
|
||||
$this->fetchOptionableAttributes(),
|
||||
$this->getStatesAndCountries()
|
||||
]);
|
||||
return view($this->_config['view'])->with('cart_rule', [$this->appliedConfig, [], $this->getStatesAndCountries()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Redirect
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
$data = request()->all();
|
||||
|
||||
$validated = Validator::make($data, [
|
||||
$validated = $this->validate($data, [
|
||||
'name' => 'required|string',
|
||||
'description' => 'string',
|
||||
// 'customer_groups' => 'required|array',
|
||||
|
|
@ -139,15 +105,10 @@ class CartRuleController extends Controller
|
|||
'label' => 'array|nullable'
|
||||
]);
|
||||
|
||||
$data['usage_limit'] = 0;
|
||||
$data['per_customer'] = 0;
|
||||
|
||||
if ($validated->fails()) {
|
||||
session()->flash('error', 'Validation failed');
|
||||
return redirect()->route('admin.cart-rule.create')
|
||||
->withErrors($validated)
|
||||
->withInput();
|
||||
}
|
||||
$data = [
|
||||
'usage_limit' => 0,
|
||||
'per_customer' => 0
|
||||
];
|
||||
|
||||
if ($data['starts_from'] == "" || $data['ends_till'] == "") {
|
||||
$data['starts_from'] = null;
|
||||
|
|
@ -157,6 +118,7 @@ class CartRuleController extends Controller
|
|||
unset($data['_token']);
|
||||
|
||||
$channels = $data['channels'];
|
||||
|
||||
unset($data['channels']);
|
||||
|
||||
// $customer_groups = $data['customer_groups'];
|
||||
|
|
@ -164,6 +126,7 @@ class CartRuleController extends Controller
|
|||
unset($data['criteria']);
|
||||
|
||||
$labels = $data['label'];
|
||||
|
||||
unset($data['label']);
|
||||
unset($data['cart_attributes']);
|
||||
unset($data['attributes']);
|
||||
|
|
@ -199,6 +162,7 @@ class CartRuleController extends Controller
|
|||
$data['auto_generation'] = 0;
|
||||
|
||||
$coupons['code'] = $data['code'];
|
||||
|
||||
unset($data['code']);
|
||||
// } else {
|
||||
// $data['auto_generation'] = 1;
|
||||
|
|
@ -230,7 +194,7 @@ class CartRuleController extends Controller
|
|||
foreach (core()->getAllChannels() as $channel) {
|
||||
$label1['channel_id'] = $channel->id;
|
||||
|
||||
foreach ($channel->locales as $locale) {
|
||||
foreach($channel->locales as $locale) {
|
||||
$label1['locale_id'] = $locale->id;
|
||||
$label1['label'] = $labels['global'];
|
||||
$label1['cart_rule_id'] = $ruleCreated->id;
|
||||
|
|
@ -241,6 +205,7 @@ class CartRuleController extends Controller
|
|||
} else {
|
||||
$label2['label'] = $labels['global'];
|
||||
$label2['cart_rule_id'] = $ruleCreated->id;
|
||||
|
||||
$ruleLabelCreated = $this->cartRuleLabel->create($label2);
|
||||
}
|
||||
|
||||
|
|
@ -266,23 +231,29 @@ class CartRuleController extends Controller
|
|||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return view
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$cart_rule = $this->cartRule->find($id);
|
||||
|
||||
return view($this->_config['view'])->with('cart_rule', [
|
||||
$this->appliedConfig,
|
||||
$this->fetchOptionableAttributes(),
|
||||
$this->getStatesAndCountries(),
|
||||
$cart_rule
|
||||
]);
|
||||
$this->appliedConfig,
|
||||
[],
|
||||
$this->getStatesAndCountries(),
|
||||
$cart_rule
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return redirect
|
||||
*/
|
||||
public function update($id)
|
||||
{
|
||||
$types = config('price_rules.cart.validations');
|
||||
|
||||
$validated = Validator::make(request()->all(), [
|
||||
$this->validate(request(), [
|
||||
'name' => 'required|string',
|
||||
'description' => 'string',
|
||||
// 'customer_groups' => 'required|array',
|
||||
|
|
@ -304,18 +275,11 @@ class CartRuleController extends Controller
|
|||
|
||||
$data = [
|
||||
'usage_limit' => 0,
|
||||
'per_customer' => 0,
|
||||
'per_customer' => 0
|
||||
];
|
||||
|
||||
if ($validated->fails()) {
|
||||
session()->flash('error', 'Validation failed');
|
||||
return redirect()->route('admin.cart-rule.create')
|
||||
->withErrors($validated)
|
||||
->withInput();
|
||||
}
|
||||
|
||||
$data = request()->all();
|
||||
|
||||
dd($data);
|
||||
if ($data['starts_from'] == "" || $data['ends_till'] == "") {
|
||||
$data['starts_from'] = null;
|
||||
$data['ends_till'] = null;
|
||||
|
|
@ -371,6 +335,7 @@ class CartRuleController extends Controller
|
|||
$data['auto_generation'] = 0;
|
||||
|
||||
$coupons['code'] = $data['code'];
|
||||
|
||||
unset($data['code']);
|
||||
// } else {
|
||||
// $data['auto_generation'] = 1;
|
||||
|
|
@ -446,17 +411,4 @@ class CartRuleController extends Controller
|
|||
'states' => $states
|
||||
];
|
||||
}
|
||||
|
||||
public function fetchOptionableAttributes()
|
||||
{
|
||||
return $attributesWithOptions = [];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -90,6 +90,8 @@ class OnepageController extends Controller
|
|||
if (Cart::hasError() || !Cart::saveCustomerAddress($data) || ! $rates = Shipping::collectRates())
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
$rule = Cart::applyNonCoupon();
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
return response()->json($rates);
|
||||
|
|
@ -107,6 +109,8 @@ class OnepageController extends Controller
|
|||
if (Cart::hasError() || !$shippingMethod || !Cart::saveShippingMethod($shippingMethod))
|
||||
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
|
||||
|
||||
$rule = Cart::applyNonCoupon();
|
||||
|
||||
Cart::collectTotals();
|
||||
|
||||
return response()->json(Payment::getSupportedPaymentMethods());
|
||||
|
|
|
|||
Loading…
Reference in New Issue