| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\Database\Seeder; |
| 4 |
|
| 5 |
use FluentCart\App\Models\OrderMeta; |
| 6 |
use FluentCart\Faker\Factory; |
| 7 |
|
| 8 |
class OrderMetaSeeder |
| 9 |
{ |
| 10 |
public static function seed($count) |
| 11 |
{ |
| 12 |
$faker = Factory::create(); |
| 13 |
|
| 14 |
$metaList = []; |
| 15 |
|
| 16 |
$json = '{"id":1,"parent":"0","title":"Test1","code":"TEST101","status":"active","type":"fixed","scope":"all","amount_type":"","amount":"500","stackable":"yes","priority":"1","settings":"","max_uses":"100","use_count":"0","max_per_customer":"100","min_purchase_amount":"2000","max_discount_amount":"0","notes":"","start_date":"2024-01-24 00:00:00","end_date":"2024-01-31 00:00:00","created_at":"2024-01-24T08:44:43+00:00","updated_at":"2024-01-24T09:19:46+00:00","discounted_amount":500}'; |
| 17 |
|
| 18 |
if (defined('WP_CLI') && WP_CLI) { |
| 19 |
$progress = \WP_CLI\Utils\make_progress_bar('%CSeeding OrderMeta', $count); |
| 20 |
} |
| 21 |
for ($i = 0; $i <= $count - 1; $i++) { |
| 22 |
$metaList[] = [ |
| 23 |
//phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key |
| 24 |
'meta_key' => 'applied_coupon', |
| 25 |
//phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value |
| 26 |
'meta_value' => $json |
| 27 |
]; |
| 28 |
|
| 29 |
if (defined('WP_CLI') && WP_CLI) { |
| 30 |
if ($i !== $count - 1) { |
| 31 |
$progress->tick(); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
} |
| 36 |
OrderMeta::insert($metaList); |
| 37 |
if (defined('WP_CLI') && WP_CLI) { |
| 38 |
$progress->tick(); |
| 39 |
$progress->finish(); |
| 40 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 41 |
echo \WP_CLI::colorize('%n'); |
| 42 |
} |
| 43 |
} |
| 44 |
} |