Skip to content

Commit 7ed0bd6

Browse files
avoid passing ->timestamp to eloquent orders query (#1258)
1 parent 270881c commit 7ed0bd6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Console/Commands/PurgeCartOrdersCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use DuncanMcClean\SimpleCommerce\Facades\Order;
66
use DuncanMcClean\SimpleCommerce\Orders\OrderStatus;
7+
use DuncanMcClean\SimpleCommerce\SimpleCommerce;
78
use Illuminate\Console\Command;
89
use Illuminate\Support\Carbon;
910
use Statamic\Console\RunsInPlease;
@@ -20,9 +21,15 @@ public function handle()
2021
{
2122
$this->info('Cleaning up..');
2223

24+
$fourteenDaysFromNow = Carbon::now()->subDays(14);
25+
26+
if ($this->isOrExtendsClass(SimpleCommerce::orderDriver()['repository'], \DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository::class)) {
27+
$fourteenDaysFromNow = $fourteenDaysFromNow->timestamp;
28+
}
29+
2330
Order::query()
2431
->whereOrderStatus(OrderStatus::Cart)
25-
->where('updated_at', '<=', Carbon::now()->subDays(14)->timestamp)
32+
->where('updated_at', '<=', $fourteenDaysFromNow)
2633
->chunk(100, function ($orders) {
2734
$orders->each(function ($order) {
2835
$this->line("Deleting Order: {$order->id()}");

0 commit comments

Comments
 (0)