Merge branch 'bagisto:master' into downloadable-customer-panel-ui-issue

This commit is contained in:
Deepak Singh Gusain 2022-02-02 17:01:25 +05:30 committed by GitHub
commit 811dfebec7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 378 additions and 214 deletions

View File

@ -37,8 +37,18 @@ 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 as group', 'customers.phone', 'customers.gender', 'status')
->addSelect(DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name'));
->addSelect(
'customers.id as customer_id',
'customers.email',
'customers.phone',
'customers.gender',
'customers.status',
'customers.is_suspended',
'customer_groups.name as group',
)
->addSelect(
DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name) as full_name')
);
$this->addFilter('customer_id', 'customers.id');
$this->addFilter('full_name', DB::raw('CONCAT(' . DB::getTablePrefix() . 'customers.first_name, " ", ' . DB::getTablePrefix() . 'customers.last_name)'));
@ -101,7 +111,7 @@ class CustomerDataGrid extends DataGrid
'sortable' => true,
'filterable' => false,
'closure' => function ($row) {
if (!$row->phone) {
if (! $row->phone) {
return '-';
} else {
return $row->phone;
@ -117,7 +127,7 @@ class CustomerDataGrid extends DataGrid
'sortable' => true,
'filterable' => false,
'closure' => function ($row) {
if (!$row->gender) {
if (! $row->gender) {
return '-';
} else {
return $row->gender;
@ -133,11 +143,19 @@ class CustomerDataGrid extends DataGrid
'sortable' => true,
'filterable' => true,
'closure' => function ($row) {
$html = '';
if ($row->status == 1) {
return '<span class="badge badge-md badge-success">' . trans('admin::app.customers.customers.active') . '</span>';
$html .= '<span class="badge badge-md badge-success">' . trans('admin::app.customers.customers.active') . '</span>';
} else {
return '<span class="badge badge-md badge-danger">' . trans('admin::app.customers.customers.inactive') . '</span>';
$html .= '<span class="badge badge-md badge-danger">' . trans('admin::app.customers.customers.inactive') . '</span>';
}
if ($row->is_suspended == 1) {
$html .= '<span class="badge badge-md badge-danger">' . trans('admin::app.customers.customers.suspended') . '</span>';
}
return $html;
},
]);
}

View File

@ -175,6 +175,8 @@ class CustomerController extends Controller
$data['status'] = ! isset($data['status']) ? 0 : 1;
$data['is_suspended'] = ! isset($data['is_suspended']) ? 0 : 1;
$this->customerRepository->update($data, $id);
session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Customer']));

View File

@ -1027,6 +1027,9 @@ return [
'status' => 'الحالة',
'active' => 'نشيط',
'inactive' => 'غير نشط',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1027,6 +1027,9 @@ return [
'status' => 'Status',
'active' => 'Aktiv',
'inactive' => 'Inaktiv',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' =>
[

View File

@ -1045,6 +1045,9 @@ return [
'status' => 'Status',
'active' => 'Active',
'inactive' => 'Inactive',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1036,6 +1036,9 @@ return [
'status' => 'Estado',
'active' => 'Activo',
'inactive' => 'Inactivo',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1022,6 +1022,9 @@ return [
'status' => 'وضعیت',
'active' => 'فعال',
'inactive' => 'غیرفعال',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1042,6 +1042,9 @@ return [
'status' => 'Statut',
'active' => 'actif',
'inactive' => 'Inactif',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1030,6 +1030,9 @@ return [
'active' => 'Attivo',
'inactive' => 'Non attivo',
'in-active' => 'Non attivo',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1024,6 +1024,9 @@ return [
'status' => 'Status',
'active' => 'Actief',
'inactive' => 'Niet geactiveerd',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1027,6 +1027,9 @@ return [
'status' => 'Status',
'active' => 'Aktywny',
'inactive' => 'Nieaktywny',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1026,6 +1026,9 @@ return [
'status' => 'Status',
'active' => 'Ativo (a)',
'inactive' => 'Inativo (a)',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -1015,6 +1015,9 @@ return [
'status' => 'Durum',
'active' => 'Aktif',
'inactive' => 'Pasif',
'is-suspended' => 'Is Suspended',
'suspend' => 'Suspend',
'suspended' => 'Suspended',
],
'reviews' => [

View File

@ -105,6 +105,24 @@
{!! view_render_event('bagisto.admin.customer.edit.status.after', ['customer' => $customer]) !!}
<div class="control-group">
<label for="isSuspended" class="required">{{ __('admin::app.customers.customers.suspend') }}</label>
<label class="switch">
<input
id="isSuspended"
type="checkbox"
name="is_suspended"
value="{{ $customer->is_suspended }}" {{ $customer->is_suspended ? 'checked' : '' }}>
<span class="slider round"></span>
</label>
<span class="control-error" v-if="errors.has('is_suspended')">@{{ errors.first('is_suspended') }}</span>
</div>
{!! view_render_event('bagisto.admin.customer.edit.is_suspended.after', ['customer' => $customer]) !!}
<div class="control-group date" :class="[errors.has('date_of_birth') ? 'has-error' : '']">
<label for="dob">{{ __('admin::app.customers.customers.date_of_birth') }}</label>

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIsSuspendedColumnToCustomersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('customers', function (Blueprint $table) {
$table->tinyInteger('is_suspended')->unsigned()->default(0)->after('is_verified');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('customers', function (Blueprint $table) {
$table->dropColumn('is_suspended');
});
}
}

View File

@ -42,12 +42,13 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject
'phone',
'password',
'api_token',
'token',
'customer_group_id',
'subscribed_to_news_letter',
'is_verified',
'token',
'notes',
'status',
'is_verified',
'is_suspended',
'notes',
];
/**
@ -68,7 +69,7 @@ class Customer extends Authenticatable implements CustomerContract, JWTSubject
*/
protected static function newFactory()
{
return CustomerFactory::new();
return CustomerFactory::new ();
}
/**

View File

@ -3,25 +3,25 @@
namespace Webkul\Shop\Http\Controllers;
use Illuminate\Support\Facades\Event;
use Webkul\Shop\Http\Controllers\Controller;
use Webkul\Checkout\Facades\Cart;
use Webkul\Shipping\Facades\Shipping;
use Webkul\Payment\Facades\Payment;
use Webkul\Checkout\Http\Requests\CustomerAddressForm;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Customer\Repositories\CustomerRepository;
use Webkul\Payment\Facades\Payment;
use Webkul\Sales\Repositories\OrderRepository;
use Webkul\Shipping\Facades\Shipping;
use Webkul\Shop\Http\Controllers\Controller;
class OnepageController extends Controller
{
/**
* OrderRepository object
* Order repository instance.
*
* @var \Webkul\Sales\Repositories\OrderRepository
*/
protected $orderRepository;
/**
* customerRepository instance object
* Customer repository instance.
*
* @var \Webkul\Customer\Repositories\CustomerRepository
*/
@ -37,8 +37,7 @@ class OnepageController extends Controller
public function __construct(
OrderRepository $orderRepository,
CustomerRepository $customerRepository
)
{
) {
$this->orderRepository = $orderRepository;
$this->customerRepository = $customerRepository;
@ -55,22 +54,26 @@ class OnepageController extends Controller
{
Event::dispatch('checkout.load.index');
if (! auth()->guard('customer')->check()
&& ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) {
if (! auth()->guard('customer')->check() && ! core()->getConfigData('catalog.products.guest-checkout.allow-guest-checkout')) {
return redirect()->route('customer.session.index');
}
if (auth()->guard('customer')->check() && auth()->guard('customer')->user()->is_suspended) {
session()->flash('warning', trans('shop::app.checkout.cart.suspended-account-message'));
return redirect()->route('shop.checkout.cart.index');
}
if (Cart::hasError()) {
return redirect()->route('shop.checkout.cart.index');
}
$cart = Cart::getCart();
if (! auth()->guard('customer')->check() && $cart->hasDownloadableItems()) {
return redirect()->route('customer.session.index');
}
if (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems()) {
if (
(! auth()->guard('customer')->check() && $cart->hasDownloadableItems())
|| (! auth()->guard('customer')->check() && ! $cart->hasGuestCheckoutItems())
) {
return redirect()->route('customer.session.index');
}
@ -88,7 +91,7 @@ class OnepageController extends Controller
}
/**
* Return order short summary
* Return order short summary.
*
* @return \Illuminate\Http\Response
*/
@ -120,7 +123,8 @@ class OnepageController extends Controller
if (Cart::hasError() || ! Cart::saveCustomerAddress($data)) {
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
} else {
}
$cart = Cart::getCart();
Cart::collectTotals();
@ -128,14 +132,13 @@ class OnepageController extends Controller
if ($cart->haveStockableItems()) {
if (! $rates = Shipping::collectRates()) {
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
} else {
}
return response()->json($rates);
}
} else {
return response()->json(Payment::getSupportedPaymentMethods());
}
}
}
/**
* Saves shipping method.
@ -146,7 +149,7 @@ class OnepageController extends Controller
{
$shippingMethod = request()->get('shipping_method');
if (Cart::hasError() || !$shippingMethod || !Cart::saveShippingMethod($shippingMethod)) {
if (Cart::hasError() || ! $shippingMethod || ! Cart::saveShippingMethod($shippingMethod)) {
return response()->json(['redirect_url' => route('shop.checkout.cart.index')], 403);
}
@ -216,7 +219,7 @@ class OnepageController extends Controller
}
/**
* Order success page
* Order success page.
*
* @return \Illuminate\Http\Response
*/
@ -230,7 +233,7 @@ class OnepageController extends Controller
}
/**
* Validate order before creation
* Validate order before creation.
*
* @return void|\Exception
*/
@ -240,29 +243,33 @@ class OnepageController extends Controller
$minimumOrderAmount = core()->getConfigData('sales.orderSettings.minimum-order.minimum_order_amount') ?? 0;
if (auth()->guard('customer')->check() && auth()->guard('customer')->user()->is_suspended) {
throw new \Exception(trans('shop::app.checkout.cart.suspended-account-message'));
}
if (! $cart->checkMinimumOrder()) {
throw new \Exception(trans('shop::app.checkout.cart.minimum-order-message', ['amount' => core()->currency($minimumOrderAmount)]));
}
if ($cart->haveStockableItems() && ! $cart->shipping_address) {
throw new \Exception(trans('Please check shipping address.'));
throw new \Exception(trans('shop::app.checkout.cart.check-shipping-address'));
}
if (! $cart->billing_address) {
throw new \Exception(trans('Please check billing address.'));
throw new \Exception(trans('shop::app.checkout.cart.check-billing-address'));
}
if ($cart->haveStockableItems() && ! $cart->selected_shipping_rate) {
throw new \Exception(trans('Please specify shipping method.'));
throw new \Exception(trans('shop::app.checkout.cart.specify-shipping-method'));
}
if (! $cart->payment) {
throw new \Exception(trans('Please specify payment method.'));
throw new \Exception(trans('shop::app.checkout.cart.specify-payment-method'));
}
}
/**
* Check Customer is exist or not
* Check Customer is exist or not.
*
* @return \Illuminate\Http\Response
*/
@ -280,14 +287,14 @@ class OnepageController extends Controller
}
/**
* Login for checkout
* Login for checkout.
*
* @return \Illuminate\Http\Response
*/
public function loginForCheckout()
{
$this->validate(request(), [
'email' => 'required|email'
'email' => 'required|email',
]);
if (! auth()->guard('customer')->attempt(request(['email', 'password']))) {
@ -300,7 +307,7 @@ class OnepageController extends Controller
}
/**
* To apply couponable rule requested
* To apply couponable rule requested.
*
* @return \Illuminate\Http\Response
*/
@ -322,7 +329,8 @@ class OnepageController extends Controller
'message' => trans('shop::app.checkout.total.coupon-applied'),
'result' => $result,
], 200);
} else {
}
return response()->json([
'success' => false,
'message' => trans('shop::app.checkout.total.cannot-apply-coupon'),
@ -330,11 +338,8 @@ class OnepageController extends Controller
], 422);
}
return $result;
}
/**
* Initiates the removal of couponable cart rule
* Initiates the removal of couponable cart rule.
*
* @return array
*/
@ -352,14 +357,14 @@ class OnepageController extends Controller
'grand_total' => core()->currency(Cart::getCart()->grand_total),
],
], 200);
} else {
}
return response()->json([
'success' => false,
'message' => trans('admin::app.promotion.status.coupon-remove-failed'),
'data' => null,
], 422);
}
}
/**
* Check for minimum order.

View File

@ -531,6 +531,11 @@ return [
'expired' => 'This event has been expired.',
],
'minimum-order-message' => 'الحد الأدنى لمبلغ الطلب هو :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -525,6 +525,11 @@ return [
'partial-cart-update' => 'Nur einige der Produkte wurden aktualisiert',
'link-missing' => '',
'minimum-order-message' => 'Mindestbestellmenge ist :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -479,10 +479,6 @@ return [
'tax-inclusive' => 'Inclusive of all taxes',
],
// 'reviews' => [
// 'empty' => 'You Have Not Reviewed Any Of Product Yet'
// ]
'buynow' => [
'no-options' => 'Please select options before buying this product.',
],
@ -516,7 +512,6 @@ return [
'inventory_warning' => 'The requested quantity is not available, please try again later.',
'error' => 'Cannot update the item(s) at the moment, please try again later.',
],
'item' => [
'error_remove' => 'No items to remove from the cart.',
'success' => 'Item is successfully added to cart.',
@ -534,6 +529,11 @@ return [
'expired' => 'This event has been expired.',
],
'minimum-order-message' => 'Minimum order amount is :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -530,6 +530,11 @@ return [
'expired' => 'This event has been expired.',
],
'minimum-order-message' => 'La cantidad mínima de pedido es :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -528,6 +528,11 @@ return [
'expired' => 'This event has been expired.',
],
'minimum-order-message' => 'حداقل مقدار سفارش است :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -531,6 +531,11 @@ return [
],
'minimum-order-message' => 'Le montant minimum de commande est de :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -529,6 +529,11 @@ return [
'expired' => 'Questo evento è terminato.',
],
'minimum-order-message' => 'L\'importo minimo dell\'ordine è :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -490,6 +490,11 @@ return [
'partial-cart-update' => 'Only some of the product(s) were updated',
'link-missing' => '',
'minimum-order-message' => '最小注文額は :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -536,6 +536,11 @@ return [
'expired' => 'This event has been expired.',
],
'minimum-order-message' => 'Minimum orderbedrag is :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -528,6 +528,11 @@ return [
'expired' => 'To wydarzenie wygasło.',
],
'minimum-order-message' => 'Minimalna kwota zamówienia to :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -520,6 +520,11 @@ return [
'expired' => 'This event has been expired.',
],
'minimum-order-message' => 'O valor mínimo do pedido é :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [

View File

@ -529,6 +529,11 @@ return [
'expired' => 'Bu eylemin geçerliliği sona erdi.',
],
'minimum-order-message' => 'Minimum order amount is :amount',
'suspended-account-message' => 'Your account has been suspended.',
'check-shipping-address' => 'Please check shipping address.',
'check-billing-address' => 'Please check billing address.',
'specify-shipping-method' => 'Please specify shipping method.',
'specify-payment-method' => 'Please specify payment method.',
],
'onepage' => [