Deploy Ladill Woo Manager / deploy (push) Successful in 51s
Free: 1 store and 20 products. Pro/Business mirrors Invoice pricing (GHS 49/149) with wallet renewals, Paystack prepay, session-based store switcher, and scoped UI. Co-authored-by: Cursor <cursoragent@cursor.com>
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Woo;
|
|
|
|
use App\Models\WooStore;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class StoreSyncService
|
|
{
|
|
public function __construct(
|
|
private CatalogSyncService $catalog,
|
|
private OrderSyncService $orders,
|
|
) {}
|
|
|
|
/** @return array{categories: int, products: int, orders: int} */
|
|
public function syncAll(WooStore $store): array
|
|
{
|
|
$counts = [
|
|
'categories' => 0,
|
|
'products' => 0,
|
|
'orders' => 0,
|
|
];
|
|
|
|
try {
|
|
$catalogCounts = $this->catalog->syncAll($store, $store->user);
|
|
$counts['categories'] = $catalogCounts['categories'];
|
|
$counts['products'] = $catalogCounts['products'];
|
|
} catch (\Throwable $e) {
|
|
Log::warning('Woo catalog sync failed', [
|
|
'store_id' => $store->id,
|
|
'message' => $e->getMessage(),
|
|
]);
|
|
}
|
|
|
|
try {
|
|
$counts['orders'] = $this->orders->syncOrders($store);
|
|
} catch (\Throwable $e) {
|
|
Log::warning('Woo order sync failed', [
|
|
'store_id' => $store->id,
|
|
'message' => $e->getMessage(),
|
|
]);
|
|
}
|
|
|
|
return $counts;
|
|
}
|
|
}
|