PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.23
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.23
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 / OrderOperationSeeder.php

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

281 lines 8.8 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\Faker\Factory;
6 use FluentCart\App\Models\Order;
7 use FluentCart\App\Models\OrderOperation;
8
9 class OrderOperationSeeder
10 {
11 public static $socialMedias = [
12 'facebook',
13 'instagram',
14 'google',
15 'youtube',
16 'linkedin',
17 'twitter'
18 ];
19
20 public static $utmParameters = [
21 [
22 'source' => 'social_media',
23 'medium' => 'cpc',
24 'campaign' => 'launch2024',
25 'term' => 'discount_code',
26 'content' => 'banner1'
27 ],
28 [
29 'source' => 'newsletter',
30 'medium' => 'email',
31 'campaign' => 'spring_sale',
32 'term' => 'special_offer',
33 'content' => 'top_banner'],
34 [
35 'source' => 'affiliate',
36 'medium' => 'referral',
37 'campaign' => 'affiliate_promo',
38 'term' => 'product_launch',
39 'content' => 'sidebar_ad'
40 ],
41 ['source' => 'google',
42 'medium' => 'organic',
43 'campaign' => 'summer_discounts',
44 'term' => 'new_product',
45 'content' => 'footer_link'],
46 [
47 'source' => 'facebook',
48 'medium' => 'social',
49 'campaign' => 'holiday_specials',
50 'term' => 'limited_time_offer',
51 'content' => 'video_ad'
52 ],
53 [
54 'source' => 'youtube',
55 'medium' => 'video',
56 'campaign' => '2024_trends',
57 'term' => 'feature_highlight',
58 'content' => 'watch_demo'
59 ],
60 [
61 'source' => 'instagram',
62 'medium' => 'paid',
63 'campaign' => 'exclusive_deal',
64 'term' => 'top_sellers',
65 'content' => 'image_post'
66 ],
67 [
68 'source' => 'linkedin',
69 'medium' => 'display',
70 'campaign' => 'professional_gear',
71 'term' => 'upgrade',
72 'content' => 'infeed_ad'
73 ],
74 [
75 'source' => 'twitter',
76 'medium' => 'social',
77 'campaign' => 'winter_sale',
78 'term' => 'must_have',
79 'content' => 'tweet_link'
80 ],
81 [
82 'source' => 'blog',
83 'medium' => 'banner',
84 'campaign' => 'new_arrivals',
85 'term' => 'just_arrived',
86 'content' => 'read_more_button'
87 ],
88 [
89 'source' => 'email_campaign',
90 'medium' => 'newsletter',
91 'campaign' => 'mid_year_sale',
92 'term' => 'promo_july',
93 'content' => 'email_link1',
94 ],
95 [
96 'source' => 'search_engine',
97 'medium' => 'seo',
98 'campaign' => 'organic_growth',
99 'term' => 'keyword_optimization',
100 'content' => 'organic_link',
101 ],
102 [
103 'source' => 'partner_site',
104 'medium' => 'affiliate',
105 'campaign' => 'partner_discount',
106 'term' => 'affiliate2024',
107 'content' => 'partner_banner',
108 ],
109 [
110 'source' => 'linkedin',
111 'medium' => 'ad',
112 'campaign' => 'b2b_leads',
113 'term' => 'lead_gen',
114 'content' => 'profile_ad',
115 ],
116 [
117 'source' => 'twitter',
118 'medium' => 'tweet',
119 'campaign' => 'brand_awareness',
120 'term' => 'spread_the_word',
121 'content' => 'tweet1',
122 ],
123 [
124 'source' => 'facebook',
125 'medium' => 'post',
126 'campaign' => 'product_launch',
127 'term' => 'new_release',
128 'content' => 'post_link',
129 ],
130 [
131 'source' => 'google_ads',
132 'medium' => 'ppc',
133 'campaign' => 'adwords_boost',
134 'term' => 'click_through',
135 'content' => 'ad_variation1',
136 ],
137 [
138 'source' => 'youtube',
139 'medium' => 'channel',
140 'campaign' => 'video_campaign',
141 'term' => 'tutorial_series',
142 'content' => 'video1',
143 ],
144 [
145 'source' => 'instagram',
146 'medium' => 'story',
147 'campaign' => 'flash_sale',
148 'term' => '24hr_special',
149 'content' => 'story_ad',
150 ],
151 [
152 'source' => 'pinterest',
153 'medium' => 'pin',
154 'campaign' => 'home_decor',
155 'term' => 'interior_tips',
156 'content' => 'pin_post',
157 ],
158 [
159 'source' => 'email_blast',
160 'medium' => 'direct',
161 'campaign' => 'exclusive_offer',
162 'term' => 'vip_list',
163 'content' => 'email1',
164 ],
165 [
166 'source' => 'webinar',
167 'medium' => 'live_event',
168 'campaign' => 'educational_series',
169 'term' => 'session1',
170 'content' => 'signup_page',
171 ],
172 [
173 'source' => 'google',
174 'medium' => 'display',
175 'campaign' => 'retargeting',
176 'term' => 'visitor_retarget',
177 'content' => 'display_ad1',
178 ],
179 [
180 'source' => 'twitter',
181 'medium' => 'promotion',
182 'campaign' => 'tweet_special',
183 'term' => 'limited_offer',
184 'content' => 'promo_tweet',
185 ],
186 [
187 'source' => 'facebook',
188 'medium' => 'video_ad',
189 'campaign' => 'video_promotion',
190 'term' => 'watch_now',
191 'content' => 'video_banner',
192 ],
193 [
194 'source' => 'instagram',
195 'medium' => 'photo_ad',
196 'campaign' => 'image_campaign',
197 'term' => 'product_photo',
198 'content' => 'product_image',
199 ],
200 [
201 'source' => 'pinterest',
202 'medium' => 'image',
203 'campaign' => 'diy_projects',
204 'term' => 'do_it_yourself',
205 'content' => 'diy_pin',
206 ],
207 [
208 'source' => 'newsletter',
209 'medium' => 'email',
210 'campaign' => 'weekly_update',
211 'term' => 'latest_news',
212 'content' => 'newsletter_link',
213 ],
214 [
215 'source' => 'google',
216 'medium' => 'organic',
217 'campaign' => 'seo_boost',
218 'term' => 'search_term',
219 'content' => 'landing_page',
220 ],
221 [
222 'source' => 'email',
223 'medium' => 'retargeting_mail',
224 'campaign' => 'customer_followup',
225 'term' => 'follow_up',
226 'content' => 'second_email',
227 ]
228
229 ];
230
231
232 public static function seed($count, $assoc_args = [])
233 {
234 $orders = Order::query()->limit($count)->get();
235 $operationData = [];
236 $faker = Factory::create();
237
238 if (defined('WP_CLI') && WP_CLI) {
239 $progress = \WP_CLI\Utils\make_progress_bar('%CSeeding Order Operations', $count);
240 }
241
242 foreach ($orders as $order) {
243 $utmParameter = $faker->randomElement(self::$utmParameters);
244 $operationData[] = [
245 'order_id' => $order->id,
246 'created_via' => 'web',
247 'has_tax' => wp_rand(0, 1),
248 'has_discount' => wp_rand(0, 1),
249 'coupons_counted' => wp_rand(1, 3),
250 'emails_sent' => wp_rand(0, 1),
251 'sales_recorded' => wp_rand(0, 1),
252 'utm_campaign' => $utmParameter['campaign'],
253 'utm_term' => $utmParameter['term'],
254 'utm_source' => $utmParameter['source'],
255 'utm_content' => $utmParameter['content'],
256 'utm_medium' => $utmParameter['medium'],
257 'utm_id' => wp_rand(1, 7),
258 'cart_hash' => wp_rand(100, 2345),
259 'refer_url' => in_array($utmParameter['source'], self::$socialMedias, '') ?
260 'https://www.' . $utmParameter['source'] . '.com' : '',
261 'created_at' => $faker->date('Y-m-d H:i:s'),
262 'updated_at' => $faker->date('Y-m-d H:i:s'),
263 ];
264
265 if (defined('WP_CLI') && WP_CLI) {
266 $progress->tick();
267 }
268 }
269
270
271 OrderOperation::query()->insert($operationData);
272
273 if (defined('WP_CLI') && WP_CLI) {
274 $progress->tick();
275 $progress->finish();
276 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
277 echo \WP_CLI::colorize('%n');
278 }
279 }
280 }
281