修改固定运费计算

This commit is contained in:
Edward Yang 2022-12-05 17:40:04 +08:00
parent fc496aa4dd
commit 9451ab57a6
2 changed files with 5 additions and 4 deletions

View File

@ -35,9 +35,9 @@ class ShippingService
$className = "Plugin\\{$pluginCode}\\Bootstrap";
if (!method_exists($className, 'getShippingFee')) {
throw new \Exception("请在插件 {$className} 实现方法: public function getShippingFee(\$totalService)");
throw new \Exception("请在插件 {$className} 实现方法: public function getShippingFee(CheckoutService \$checkout)");
}
$amount = (float)(new $className)->getShippingFee($totalService);
$amount = (float)(new $className)->getShippingFee($checkout);
$totalData = [
'code' => 'shipping',
'title' => trans('shop/carts.shipping_fee'),

View File

@ -41,11 +41,12 @@ class Bootstrap
/**
* 计算固定运费
*
* @param $totalService
* @param CheckoutService $checkout
* @return float|int
*/
public function getShippingFee($totalService): float|int
public function getShippingFee(CheckoutService $checkout): float|int
{
$totalService = $checkout->totalService;
$amount = $totalService->amount;
$shippingType = plugin_setting('flat_shipping.type', 'fixed');
$shippingValue = plugin_setting('flat_shipping.value', 0);