Add hook from mundosanjose

This commit is contained in:
Edward Yang 2023-03-24 17:01:02 +08:00
parent 3266cb4924
commit 76edc24c77
4 changed files with 34 additions and 16 deletions

View File

@ -35,20 +35,30 @@ class LoginController extends Controller
public function store(LoginRequest $request) public function store(LoginRequest $request)
{ {
$guestCartProduct = CartRepo::allCartProducts(0); $data = [
if (! auth(Customer::AUTH_GUARD)->attempt($request->only('email', 'password'))) { 'request_data' => $request->all(),
throw new NotAcceptableHttpException(trans('shop/login.email_or_password_error')); ];
try {
hook_action('shop.account.login.before', $data);
$guestCartProduct = CartRepo::allCartProducts(0);
if (! auth(Customer::AUTH_GUARD)->attempt($request->only('email', 'password'))) {
throw new NotAcceptableHttpException(trans('shop/login.email_or_password_error'));
}
$customer = current_customer();
if ($customer && $customer->status != 1) {
Auth::guard(Customer::AUTH_GUARD)->logout();
throw new NotFoundHttpException(trans('shop/login.customer_inactive'));
}
CartRepo::mergeGuestCart($customer, $guestCartProduct);
return json_success(trans('shop/login.login_successfully'));
} catch (\Exception $e) {
return json_fail($e->getMessage());
} }
$customer = current_customer();
if ($customer && $customer->status != 1) {
Auth::guard(Customer::AUTH_GUARD)->logout();
throw new NotFoundHttpException(trans('shop/login.customer_inactive'));
}
CartRepo::mergeGuestCart($customer, $guestCartProduct);
return json_success(trans('shop/login.login_successfully'));
} }
} }

View File

@ -26,7 +26,7 @@ class CartDetail extends JsonResource
$subTotal = $price * $this->quantity; $subTotal = $price * $this->quantity;
$image = $sku->image ?: $product->image; $image = $sku->image ?: $product->image;
return [ $result = [
'cart_id' => $this->id, 'cart_id' => $this->id,
'product_id' => $this->product_id, 'product_id' => $this->product_id,
'sku_id' => $this->product_sku_id, 'sku_id' => $this->product_sku_id,
@ -44,5 +44,7 @@ class CartDetail extends JsonResource
'subtotal_format' => currency_format($subTotal), 'subtotal_format' => currency_format($subTotal),
'variant_labels' => trim($sku->getVariantLabel()), 'variant_labels' => trim($sku->getVariantLabel()),
]; ];
return hook_filter('resource.cart.detail', $result);
} }
} }

View File

@ -17,7 +17,7 @@ class SkuDetail extends JsonResource
{ {
public function toArray($request): array public function toArray($request): array
{ {
return [ $result = [
'id' => $this->id, 'id' => $this->id,
'variants' => $this->variants ?: [], 'variants' => $this->variants ?: [],
'position' => $this->position, 'position' => $this->position,
@ -37,5 +37,7 @@ class SkuDetail extends JsonResource
'quantity' => $this->quantity, 'quantity' => $this->quantity,
'is_default' => $this->is_default, 'is_default' => $this->is_default,
]; ];
return hook_filter('resource.sku.detail', $result);
} }
} }

View File

@ -107,9 +107,11 @@
<div> <div>
<h5 class="border-bottom pb-3 mb-4">{{ __('admin/product.stocks') }}</h5> <h5 class="border-bottom pb-3 mb-4">{{ __('admin/product.stocks') }}</h5>
@hookwrapper('admin.product.edit.switch')
<x-admin::form.row :title="__('admin/product.enable_multi_spec')"> <x-admin::form.row :title="__('admin/product.enable_multi_spec')">
<el-switch v-model="editing.isVariable" @change="isVariableChange" class="mt-2"></el-switch> <el-switch v-model="editing.isVariable" @change="isVariableChange" class="mt-2"></el-switch>
</x-admin::form.row> </x-admin::form.row>
@endhookwrapper
<input type="hidden" name="variables" :value="JSON.stringify(form.variables)"> <input type="hidden" name="variables" :value="JSON.stringify(form.variables)">
@ -265,6 +267,7 @@
</div> </div>
</div> </div>
@hookwrapper('admin.product.edit.variable')
<template v-if="!editing.isVariable"> <template v-if="!editing.isVariable">
<input type="hidden" value="{{ old('skus.0.image', $product->skus[0]->image ?? '') }}" name="skus[0][image]"> <input type="hidden" value="{{ old('skus.0.image', $product->skus[0]->image ?? '') }}" name="skus[0][image]">
<x-admin-form-input name="skus[0][model]" :title="__('admin/product.model')" :value="old('skus.0.model', $product->skus[0]->model ?? '')" /> <x-admin-form-input name="skus[0][model]" :title="__('admin/product.model')" :value="old('skus.0.model', $product->skus[0]->model ?? '')" />
@ -277,6 +280,7 @@
<input type="hidden" name="skus[0][position]" placeholder="position" value="0"> <input type="hidden" name="skus[0][position]" placeholder="position" value="0">
<input type="hidden" name="skus[0][is_default]" placeholder="is_default" value="1"> <input type="hidden" name="skus[0][is_default]" placeholder="is_default" value="1">
</template> </template>
@endhookwrapper
</div> </div>
</div> </div>
<div class="tab-pane fade" id="tab-descriptions"> <div class="tab-pane fade" id="tab-descriptions">