PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / database / Seeder / OrderMetaSeeder.php

OrderMetaSeeder.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at database/Seeder/OrderMetaSeeder.php

44 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }