Revert "Fixed issue with order summary rendering on cart page"

This commit is contained in:
Jitendra Singh 2019-06-15 15:09:59 +05:30 committed by GitHub
parent 4bf4f2686f
commit 7ac715e93d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 52 deletions

View File

@ -74,7 +74,7 @@
</div>
</datetime>
<div class="control-group" :class="[errors.has('customer_groups[]') ? 'has-error' : '']">
{{-- <div class="control-group" :class="[errors.has('customer_groups[]') ? 'has-error' : '']">
<label for="customer_groups" class="required">{{ __('admin::app.promotion.general-info.cust-groups') }}</label>
<select type="text" class="control" name="customer_groups[]" v-model="customer_groups" v-validate="'required'" value="{{ old('customer_groups[]') }}" data-vv-as="&quot;{{ __('admin::app.promotion.general-info.cust-groups') }}&quot;" multiple="multiple">
@ -85,7 +85,7 @@
</select>
<span class="control-error" v-if="errors.has('customer_groups')">@{{ errors.first('customer_groups') }}</span>
</div>
</div> --}}
<div class="control-group" :class="[errors.has('channels[]') ? 'has-error' : '']">
<label for="channels" class="required">{{ __('admin::app.promotion.general-info.channels') }}</label>

View File

@ -83,10 +83,12 @@ class CartRuleController extends Controller
*/
public function store()
{
$data = request()->all();
$validated = $this->validate($data, [
'name' => 'required|string',
'description' => 'string',
'customer_groups' => 'required|array',
// 'customer_groups' => 'required|array',
'channels' => 'required|array',
'status' => 'required|boolean',
'use_coupon' => 'boolean|required',
@ -103,45 +105,32 @@ class CartRuleController extends Controller
'label' => 'array|nullable'
]);
$data = request()->all();
$data = [
'usage_limit' => 0,
'per_customer' => 0
];
// unset token
unset($data['_token']);
// set usage limit
$data['usage_limit'] = 0;
// set per customer usage limit
$data['per_customer'] = 0;
// check starts from and ends till
if ($data['starts_from'] == "" || $data['ends_till'] == "") {
$data['starts_from'] = null;
$data['ends_till'] = null;
}
// customer groups
$customer_groups = $data['customer_groups'];
unset($data['_token']);
// unset customer groups
unset($data['customer_groups']);
// unset criteria
unset($data['criteria']);
// channels
$channels = $data['channels'];
// unset channels
unset($data['channels']);
// make labels
// $customer_groups = $data['customer_groups'];
// unset($data['customer_groups']);
unset($data['criteria']);
$labels = $data['label'];
// unset labels
unset($data['label']);
unset($data['cart_attributes']);
unset($data['attributes']);
// prepare json object from actions
if (isset($data['disc_amount']) && $data['action_type'] == config('pricerules.cart.validations.2')) {
$data['actions'] = [
'action_type' => $data['action_type'],
@ -158,37 +147,22 @@ class CartRuleController extends Controller
];
}
// prepare json object from conditions
$data['actions'] = json_encode($data['actions']);
// check if all
if (! isset($data['all_conditions']) || $data['all_conditions'] == "[]") {
$data['conditions'] = null;
} else {
$data['conditions'] = json_encode($data['all_conditions']);
}
// unset cart_attributes from conditions
unset($data['cart_attributes']);
// unset attributes from conditions
unset($data['attributes']);
// unset all_conditions from conditions
unset($data['all_conditions']);
// prepare coupons if coupons are used
if ($data['use_coupon']) {
// if (isset($data['auto_generation']) && $data['auto_generation']) {
// auto generation is off for now
$data['auto_generation'] = 0;
// save the coupon used in coupon section
$coupons['code'] = $data['code'];
// set coupon usage per customer same as per_customer limit which is disabled for now
$coupons['usage_per_customer'] = $data['per_customer']; //0 is for unlimited usage
// unset coupon code from coupon section
unset($data['code']);
// } else {
// $data['auto_generation'] = 1;
@ -207,21 +181,15 @@ class CartRuleController extends Controller
// $coupons['limit'] = 0;
}
// per coupon usage limit
// if(isset($data['usage_limit'])) {
// $coupons['limit'] = $data['usage_limit'];
// }
// create a cart rule
$ruleCreated = $this->cartRule->create($data);
// create customer groups for cart rule
$ruleGroupCreated = $this->cartRule->CustomerGroupSync($customer_groups, $ruleCreated);
// create customer groups for channels
// $ruleGroupCreated = $this->cartRule->CustomerGroupSync($customer_groups, $ruleCreated);
$ruleChannelCreated = $this->cartRule->ChannelSync($channels, $ruleCreated);
// prepare labels
if (isset($labels['global'])) {
foreach (core()->getAllChannels() as $channel) {
$label1['channel_id'] = $channel->id;
@ -241,13 +209,14 @@ class CartRuleController extends Controller
$ruleLabelCreated = $this->cartRuleLabel->create($label2);
}
// create coupon if present
if (isset($coupons)) {
$coupons['cart_rule_id'] = $ruleCreated->id;
$coupons['usage_per_customer'] = $data['per_customer']; //0 is for unlimited usage
$couponCreated = $this->cartRuleCoupon->create($coupons);
}
if ($ruleCreated && $ruleChannelCreated && $ruleGroupCreated) {
if ($ruleCreated && $ruleChannelCreated) {
if (isset($couponCreated) && $couponCreated) {
session()->flash('success', trans('admin::app.promotion.status.success-coupon'));
}

View File

@ -44,7 +44,7 @@
</label>
</div>
<div @if (! request()->is('checkout/cart')) v-if="hide_discount" @endif>
<div v-if="hide_discount">
@if (! request()->is('checkout/cart'))
<div class="discount">
<div class="discount-group" v-if="! coupon_used">