PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.1
1.6.5 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 All 48 releases
fluent-cart / database / Seeder / AppliedCouponsSeeder.php

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

48 lines 1.3 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\AppliedCoupon;
6 use FluentCart\Faker\Factory;
7
8 class AppliedCouponsSeeder
9 {
10 public static function seed($count)
11 {
12 $faker = Factory::create();
13
14 $appliedCouponsLists = [];
15
16 if (defined('WP_CLI') && WP_CLI) {
17 $progress = \WP_CLI\Utils\make_progress_bar('%CSeeding AppliedCoupons', $count);
18 }
19 for ($i = 0; $i <= $count - 1; $i++) {
20 if($i%2==0){
21 $code = 'TEST101';
22 }
23 else {
24 $code = 'TEST102';
25 }
26 $appliedCouponsLists[] = [
27 'title' => $faker->text(200),
28 'code' => $code,
29 'status' => $faker->text(20),
30 'type' => $faker->text(20),
31 ];
32
33 if (defined('WP_CLI') && WP_CLI) {
34 if ($i !== $count - 1) {
35 $progress->tick();
36 }
37 }
38
39 }
40 AppliedCoupon::insert($appliedCouponsLists);
41 if (defined('WP_CLI') && WP_CLI) {
42 $progress->tick();
43 $progress->finish();
44 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
45 echo \WP_CLI::colorize('%n');
46 }
47 }
48 }