diff --git a/beike/Helpers.php b/beike/Helpers.php index edefacbc..7f21bbe8 100644 --- a/beike/Helpers.php +++ b/beike/Helpers.php @@ -456,6 +456,18 @@ function current_currency_code(): string return Session::get('currency') ?? system_setting('base.currency'); } +/** + * 获取当前货币 + * + * @return string + */ +function current_currency_id(): string +{ + $currencyCode = current_currency_code(); + $currency = \Beike\Models\Currency::query()->where('code', $currencyCode)->first(); + return $currency->id ?? 0; +} + /** * 数量格式化, 用于商品、订单统计 * diff --git a/beike/Shop/Services/CheckoutService.php b/beike/Shop/Services/CheckoutService.php index a3537592..84a61505 100644 --- a/beike/Shop/Services/CheckoutService.php +++ b/beike/Shop/Services/CheckoutService.php @@ -108,6 +108,22 @@ class CheckoutService } + /** + * 计算当前选中商品总重量 + * @todo + * @return int + */ + public function getCartWeight(): int + { + $weight = 0; + $selectedProducts = $this->selectedProducts; + foreach ($selectedProducts as $product) { + $weight += $this->weight->convert($product['weight'], $product['weight_class_id'], $this->config->get('config_weight_class_id')); + } + return $weight; + } + + /** * @throws \Exception */