修复前台支付和配送多语言
This commit is contained in:
parent
74f8cdafe9
commit
1a653be8fa
|
|
@ -18,7 +18,7 @@ class PluginResource extends JsonResource
|
|||
{
|
||||
$currentLocale = locale();
|
||||
|
||||
$name = is_array($this->name) ? ($this->name[$currentLocale] ?? '') : (string) $this->name;
|
||||
$name = is_array($this->name) ? ($this->name[$currentLocale] ?? '') : (string) $this->name;
|
||||
$description = is_array($this->description) ? ($this->description[$currentLocale] ?? '') : (string) $this->description;
|
||||
|
||||
$data = [
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Beike\Services;
|
||||
|
||||
use Beike\Admin\Http\Resources\PluginResource;
|
||||
use Beike\Repositories\PluginRepo;
|
||||
use Beike\Shop\Services\CheckoutService;
|
||||
use Illuminate\Support\Str;
|
||||
|
|
@ -40,9 +41,10 @@ class ShippingMethodService
|
|||
}
|
||||
$quotes = (new $className)->getQuotes($checkout, $plugin);
|
||||
if ($quotes) {
|
||||
$pluginResource = (new PluginResource($plugin))->jsonSerialize();
|
||||
$shippingMethods[] = [
|
||||
'code' => $pluginCode,
|
||||
'name' => $plugin->name,
|
||||
'name' => $pluginResource['name'],
|
||||
'quotes' => $quotes,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Beike\Shop\Http\Resources\Checkout;
|
||||
|
||||
use Beike\Admin\Http\Resources\PluginResource;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
|
|
@ -16,14 +17,14 @@ class PaymentMethodItem extends JsonResource
|
|||
*/
|
||||
public function toArray($request): array
|
||||
{
|
||||
$pluginSetting = $this->plugin;
|
||||
$pluginResource = (new PluginResource($this->plugin))->jsonSerialize();
|
||||
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'code' => $this->code,
|
||||
'name' => $pluginSetting->name,
|
||||
'description' => $pluginSetting->description,
|
||||
'icon' => plugin_resize($this->code, $pluginSetting->icon),
|
||||
'name' => $pluginResource['name'],
|
||||
'description' => $pluginResource['description'],
|
||||
'icon' => $pluginResource['icon'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Plugin\FlatShipping;
|
||||
|
||||
use Beike\Admin\Http\Resources\PluginResource;
|
||||
use Beike\Plugin\Plugin;
|
||||
use Beike\Shop\Services\CheckoutService;
|
||||
|
||||
|
|
@ -27,12 +28,13 @@ class Bootstrap
|
|||
public function getQuotes(CheckoutService $checkout, Plugin $plugin): array
|
||||
{
|
||||
$code = $plugin->code;
|
||||
$pluginResource = (new PluginResource($plugin))->jsonSerialize();
|
||||
$quotes[] = [
|
||||
'type' => 'shipping',
|
||||
'code' => "{$code}.0",
|
||||
'name' => $plugin->getName(),
|
||||
'description' => $plugin->getDescription(),
|
||||
'icon' => plugin_resize($code, $plugin->icon),
|
||||
'name' => $pluginResource['name'],
|
||||
'description' => $pluginResource['description'],
|
||||
'icon' => $pluginResource['icon'],
|
||||
'cost' => $this->getShippingFee($checkout),
|
||||
];
|
||||
return $quotes;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
{
|
||||
"code": "flat_shipping",
|
||||
"name": "固定运费",
|
||||
"description": "按订单总额收取固定运费",
|
||||
"name": {
|
||||
"zh_cn": "固定运费",
|
||||
"en": "Flat Rate Shipping"
|
||||
},
|
||||
"description": {
|
||||
"zh_cn": "按订单总额收取固定运费",
|
||||
"en": "Fixed shipping fee by order total"
|
||||
},
|
||||
"type": "shipping",
|
||||
"version": "v1.0.0",
|
||||
"icon": "/image/logo.png",
|
||||
|
|
|
|||
Loading…
Reference in New Issue