修复购物车和结账页多语言

This commit is contained in:
Edward Yang 2022-08-22 20:51:49 +08:00
parent 8659720060
commit 700390790f
4 changed files with 22 additions and 10 deletions

View File

@ -40,12 +40,12 @@ class CheckoutService
$this->customer = current_customer();
}
if (empty($this->customer) || !($this->customer instanceof Customer)) {
throw new \Exception("购物车客户无效");
throw new \Exception(trans('shop/carts.invalid_customer'));
}
$this->cart = CartRepo::createCart($this->customer);
$this->selectedProducts = CartRepo::selectedCartProducts($this->customer->id);
if ($this->selectedProducts->count() == 0) {
throw new \Exception("购物车商品为空");
throw new \Exception(trans('shop/carts.empty_selected_products'));
}
}
@ -113,22 +113,22 @@ class CheckoutService
$shippingAddressId = $current['shipping_address_id'];
if (empty(Address::query()->find($shippingAddressId))) {
throw new \Exception('配送地址无效');
throw new \Exception(trans('shop/carts.invalid_shipping_address'));
}
$paymentAddressId = $current['payment_address_id'];
if (empty(Address::query()->find($paymentAddressId))) {
throw new \Exception('账单地址无效');
throw new \Exception(trans('shop/carts.invalid_payment_address'));
}
$shippingMethodCode = $current['shipping_method_code'];
if (!PluginRepo::shippingEnabled($shippingMethodCode)) {
throw new \Exception('配送方式不可用');
throw new \Exception(trans('shop/carts.invalid_shipping_method'));
}
$paymentMethodCode = $current['payment_method_code'];
if (!PluginRepo::paymentEnabled($paymentMethodCode)) {
throw new \Exception('支付方式不可用');
throw new \Exception(trans('shop/carts.invalid_payment_method'));
}
}

View File

@ -29,5 +29,11 @@ return [
'mini' => 'Your cart',
'delete' => 'Delete',
'check_cart' => 'Check the shopping cart',
'subtotal' => 'Subtotal',
'invalid_customer' => 'Invalid customer.',
'empty_selected_products' => 'Empty selected products.',
'invalid_shipping_address' => 'Invalid shipping address',
'invalid_payment_address' => 'Invalid payment address.',
'invalid_shipping_method' => 'Invalid shipping method.',
'invalid_payment_method' => 'Invalid payment method.',
];

View File

@ -29,5 +29,11 @@ return [
'mini' => '您的购物车',
'delete' => '删除',
'check_cart' => '查看购物车',
'subtotal' => '小计',
'invalid_customer' => '购物车客户无效',
'empty_selected_products' => '购物车选中商品为空',
'invalid_shipping_address' => '配送地址无效',
'invalid_payment_address' => '账单地址无效',
'invalid_shipping_method' => '配送方式不可用',
'invalid_payment_method' => '支付方式不可用',
];

View File

@ -18,7 +18,7 @@
</div>
@if ($errors->has('error'))
<x-shop-alert type="danger" msg="{{ $errors->has('error') }}" class="mt-4" />
<x-shop-alert type="danger" msg="{{ $errors->first('error') }}" class="mt-4" />
@endif
<div class="row mt-5" v-if="products.length">
@ -136,7 +136,7 @@
methods: {
checkedBtnToCheckout() {
if (!this.products.some(e => e.selected)) {
layer.msg('{{ __('shop/carts.nust_select') }}', ()=>{})
layer.msg('{{ __('shop/carts.empty_selected_products') }}', ()=>{})
return
}