wyyl/beike/Shop/Services/TotalServices/SumQuantityService.php

23 lines
622 B
PHP

<?php
namespace Beike\Shop\Services\TotalServices;
use Beike\Shop\Services\CheckoutService;
class SumQuantityService{
public static function getTotal(CheckoutService $checkout): ?array{
$totalService = $checkout->totalService;
$sumQuantity = $totalService->countProducts();
$totalData = [
'code' => 'sum_quantity',
'title' => trans('admin/dashboard.product_total'),
'amount' => $sumQuantity,
'amount_format' => $sumQuantity,
];
$totalService->totals[] = $totalData;
return $totalData;
}
}