Files
ladill-woo-manager/app/Console/Commands/RenewProSubscriptionsCommand.php
T
isaaccladandCursor cebf0d2e61
Deploy Ladill Woo Manager / deploy (push) Successful in 51s
Add Woo Manager Pro with multi-store switching and free-tier limits.
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>
2026-07-07 01:14:08 +00:00

39 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\Woo\ProSubscription;
use App\Services\Woo\SubscriptionService;
use Illuminate\Console\Command;
class RenewProSubscriptionsCommand extends Command
{
protected $signature = 'woo:pro-renew';
protected $description = 'Renew due Woo Manager Pro/Business subscriptions from wallet balance';
public function handle(SubscriptionService $subscriptions): int
{
if (! $subscriptions->gatingActive()) {
$this->info('Woo Pro gating is disabled or billing is not configured.');
return self::SUCCESS;
}
$due = ProSubscription::query()
->where('status', ProSubscription::STATUS_ACTIVE)
->where('auto_renew', true)
->whereNotNull('current_period_end')
->where('current_period_end', '<=', now())
->get();
foreach ($due as $subscription) {
$subscriptions->renewIfDue($subscription);
}
$this->info('Processed '.$due->count().' subscription(s).');
return self::SUCCESS;
}
}