merge with master
This commit is contained in:
commit
5afef79ac2
|
|
@ -23,7 +23,7 @@ class CustomerDataGrid extends DataGrid
|
|||
{
|
||||
$queryBuilder = DB::table('customers')
|
||||
->leftJoin('customer_groups', 'customers.customer_group_id', '=', 'customer_groups.id')
|
||||
->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name')
|
||||
->addSelect('customers.id as customer_id', 'customers.email', 'customer_groups.name', 'status')
|
||||
->addSelect(DB::raw('CONCAT(customers.first_name, " ", customers.last_name) as full_name'));
|
||||
|
||||
$this->addFilter('customer_id', 'customers.id');
|
||||
|
|
@ -69,6 +69,22 @@ class CustomerDataGrid extends DataGrid
|
|||
'sortable' => true,
|
||||
'filterable' => true
|
||||
]);
|
||||
|
||||
$this->addColumn([
|
||||
'index' => 'status',
|
||||
'label' => trans('admin::app.datagrid.status'),
|
||||
'type' => 'boolean',
|
||||
'searchable' => false,
|
||||
'sortable' => true,
|
||||
'filterable' => true,
|
||||
'wrapper' => function ($row) {
|
||||
if ($row->status == 1) {
|
||||
return 'Activated';
|
||||
} else {
|
||||
return 'Blocked';
|
||||
}
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
public function prepareActions() {
|
||||
|
|
@ -96,4 +112,30 @@ class CustomerDataGrid extends DataGrid
|
|||
'title' => trans('admin::app.customers.note.help-title')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Customer Mass Action To Delete And Change Their
|
||||
*/
|
||||
public function prepareMassActions()
|
||||
{
|
||||
$this->addMassAction([
|
||||
'type' => 'delete',
|
||||
'label' => 'Delete',
|
||||
'action' => route('admin.customer.mass-delete'),
|
||||
'method' => 'PUT',
|
||||
]);
|
||||
|
||||
$this->addMassAction([
|
||||
'type' => 'update',
|
||||
'label' => 'Update Status',
|
||||
'action' => route('admin.customer.mass-update'),
|
||||
'method' => 'PUT',
|
||||
'options' => [
|
||||
'Active' => 1,
|
||||
'Inactive' => 0
|
||||
]
|
||||
]);
|
||||
|
||||
$this->enableMassAction = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -224,4 +224,43 @@ class CustomerController extends Controller
|
|||
|
||||
return redirect()->route($this->_config['redirect']);
|
||||
}
|
||||
|
||||
/**
|
||||
* To mass update the customer
|
||||
*/
|
||||
public function massUpdate()
|
||||
{
|
||||
$customerIds = explode(',', request()->input('indexes'));
|
||||
$updateOption = request()->input('update-options');
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$customer = $this->customer->find($customerId);
|
||||
|
||||
$customer->update([
|
||||
'status' => $updateOption
|
||||
]);
|
||||
}
|
||||
|
||||
session()->flash('info', trans('admin::app.customers.customers.mass-update-success'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* To mass delete the customer
|
||||
*/
|
||||
public function massDestroy()
|
||||
{
|
||||
$customerIds = explode(',', request()->input('indexes'));
|
||||
|
||||
foreach ($customerIds as $customerId) {
|
||||
$this->customer->deleteWhere([
|
||||
'id' => $customerId
|
||||
]);
|
||||
}
|
||||
|
||||
session()->flash('info', trans('admin::app.customers.customers.mass-destroy-success'));
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ Route::group(['middleware' => ['web']], function () {
|
|||
'view' => 'admin::dashboard.index'
|
||||
])->name('admin.dashboard.index');
|
||||
|
||||
//Customers Management Routes
|
||||
//Customer Management Routes
|
||||
Route::get('customers', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@index')->defaults('_config', [
|
||||
'view' => 'admin::customers.index'
|
||||
])->name('admin.customer.index');
|
||||
|
|
@ -74,6 +74,10 @@ Route::group(['middleware' => ['web']], function () {
|
|||
|
||||
Route::post('customers/delete/{id}', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@destroy')->name('admin.customer.delete');
|
||||
|
||||
Route::post('customers/masssdelete', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@massDestroy')->name('admin.customer.mass-delete');
|
||||
|
||||
Route::post('customers/masssupdate', 'Webkul\Admin\Http\Controllers\Customer\CustomerController@massUpdate')->name('admin.customer.mass-update');
|
||||
|
||||
Route::get('reviews', 'Webkul\Product\Http\Controllers\ReviewController@index')->defaults('_config',[
|
||||
'view' => 'admin::customers.reviews.index'
|
||||
])->name('admin.customer.review.index');
|
||||
|
|
|
|||
|
|
@ -768,7 +768,9 @@ return [
|
|||
'phone' => 'Phone',
|
||||
'group-default' => 'Cannot delete the default group.',
|
||||
'edit-help-title' => 'Edit Customer',
|
||||
'delete-help-title' => 'Delete Customer'
|
||||
'delete-help-title' => 'Delete Customer',
|
||||
'mass-destroy-success' => 'Customers deleted successfully',
|
||||
'mass-update-success' => 'Customers updated successfully'
|
||||
],
|
||||
|
||||
'reviews' => [
|
||||
|
|
@ -819,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',
|
||||
|
|
@ -842,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 -->
|
||||
|
|
@ -257,7 +266,7 @@
|
|||
<div class="control-group" :class="[errors.has('disc_amount') ? 'has-error' : '']">
|
||||
<label for="disc_amount" class="required">{{ __('admin::app.promotion.general-info.disc_amt') }}</label>
|
||||
|
||||
<input type="number" step="0.5000" class="control" name="disc_amount" v-model="disc_amount" v-validate="'required|decimal|min_value:0.0001'" value="{{ old('disc_amount') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_amt') }}"">
|
||||
<input type="number" step="0.5000" class="control" name="disc_amount" v-model="disc_amount" v-validate="'required|min_value:0.0001'" value="{{ old('disc_amount') }}" data-vv-as=""{{ __('admin::app.promotion.general-info.disc_amt') }}"">
|
||||
|
||||
<span class="control-error" v-if="errors.has('disc_amount')">@{{ errors.first('disc_amount') }}</span>
|
||||
</div>
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@
|
|||
<td>{{ core()->formatBasePrice($item->base_discount_amount) }}</td>
|
||||
@endif
|
||||
|
||||
<td>{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount) }}</td>
|
||||
<td>{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount - $item->base_total + $item->base_tax_amount) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@
|
|||
<td>{{ core()->formatBasePrice($item->base_discount_amount) }}</td>
|
||||
@endif
|
||||
|
||||
<td>{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount) }}</td>
|
||||
<td>{{ core()->formatBasePrice($item->base_total + $item->base_tax_amount - $item->base_discount_amount) }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -1167,6 +1167,9 @@ class Cart {
|
|||
'tax_percent' => $data['tax_percent'],
|
||||
'tax_amount' => $data['tax_amount'],
|
||||
'base_tax_amount' => $data['base_tax_amount'],
|
||||
'discount_percent' => $data['discount_percent'],
|
||||
'discount_amount' => $data['discount_amount'],
|
||||
'base_discount_amount' => $data['base_discount_amount'],
|
||||
'additional' => $data['additional'],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
@ -71,34 +45,47 @@ 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)
|
||||
public function __construct(
|
||||
CartRule $cartRule,
|
||||
CartRuleCoupons $cartRuleCoupon,
|
||||
CartRuleLabels $cartRuleLabel
|
||||
)
|
||||
{
|
||||
$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',
|
||||
|
|
@ -118,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;
|
||||
|
|
@ -136,6 +118,7 @@ class CartRuleController extends Controller
|
|||
unset($data['_token']);
|
||||
|
||||
$channels = $data['channels'];
|
||||
|
||||
unset($data['channels']);
|
||||
|
||||
// $customer_groups = $data['customer_groups'];
|
||||
|
|
@ -143,6 +126,7 @@ class CartRuleController extends Controller
|
|||
unset($data['criteria']);
|
||||
|
||||
$labels = $data['label'];
|
||||
|
||||
unset($data['label']);
|
||||
unset($data['cart_attributes']);
|
||||
unset($data['attributes']);
|
||||
|
|
@ -170,6 +154,7 @@ class CartRuleController extends Controller
|
|||
} else {
|
||||
$data['conditions'] = json_encode($data['all_conditions']);
|
||||
}
|
||||
|
||||
unset($data['all_conditions']);
|
||||
|
||||
if ($data['use_coupon']) {
|
||||
|
|
@ -177,6 +162,7 @@ class CartRuleController extends Controller
|
|||
$data['auto_generation'] = 0;
|
||||
|
||||
$coupons['code'] = $data['code'];
|
||||
|
||||
unset($data['code']);
|
||||
// } else {
|
||||
// $data['auto_generation'] = 1;
|
||||
|
|
@ -207,6 +193,7 @@ class CartRuleController extends Controller
|
|||
if (isset($labels['global'])) {
|
||||
foreach (core()->getAllChannels() as $channel) {
|
||||
$label1['channel_id'] = $channel->id;
|
||||
|
||||
foreach($channel->locales as $locale) {
|
||||
$label1['locale_id'] = $locale->id;
|
||||
$label1['label'] = $labels['global'];
|
||||
|
|
@ -218,10 +205,11 @@ class CartRuleController extends Controller
|
|||
} else {
|
||||
$label2['label'] = $labels['global'];
|
||||
$label2['cart_rule_id'] = $ruleCreated->id;
|
||||
|
||||
$ruleLabelCreated = $this->cartRuleLabel->create($label2);
|
||||
}
|
||||
|
||||
if(isset($coupons)) {
|
||||
if (isset($coupons)) {
|
||||
$coupons['cart_rule_id'] = $ruleCreated->id;
|
||||
$coupons['usage_per_customer'] = $data['per_customer']; //0 is for unlimited usage
|
||||
|
||||
|
|
@ -243,18 +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]);
|
||||
return view($this->_config['view'])->with('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',
|
||||
|
|
@ -274,18 +273,13 @@ 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
|
||||
];
|
||||
|
||||
$data = request()->all();
|
||||
|
||||
dd($data);
|
||||
if ($data['starts_from'] == "" || $data['ends_till'] == "") {
|
||||
$data['starts_from'] = null;
|
||||
$data['ends_till'] = null;
|
||||
|
|
@ -294,6 +288,7 @@ class CartRuleController extends Controller
|
|||
unset($data['_token']);
|
||||
|
||||
$channels = $data['channels'];
|
||||
|
||||
unset($data['channels']);
|
||||
|
||||
// $customer_groups = $data['customer_groups'];
|
||||
|
|
@ -302,6 +297,7 @@ class CartRuleController extends Controller
|
|||
|
||||
if (isset($data['label'])) {
|
||||
$labels = $data['label'];
|
||||
|
||||
unset($data['label']);
|
||||
}
|
||||
|
||||
|
|
@ -325,6 +321,7 @@ class CartRuleController extends Controller
|
|||
}
|
||||
|
||||
$data['actions'] = json_encode($data['actions']);
|
||||
|
||||
if (! isset($data['all_conditions']) || $data['all_conditions'] == "[]") {
|
||||
$data['conditions'] = null;
|
||||
} else {
|
||||
|
|
@ -338,6 +335,7 @@ class CartRuleController extends Controller
|
|||
$data['auto_generation'] = 0;
|
||||
|
||||
$coupons['code'] = $data['code'];
|
||||
|
||||
unset($data['code']);
|
||||
// } else {
|
||||
// $data['auto_generation'] = 1;
|
||||
|
|
@ -413,17 +411,4 @@ class CartRuleController extends Controller
|
|||
'states' => $states
|
||||
];
|
||||
}
|
||||
|
||||
public function fetchOptionableAttributes()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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