PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.27
Booktics – Appointment Booking Calendar for Service Businesses v1.0.27
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
← All changes | core/dummy-data/dummy-data-manager.php +320 -6 1.0.3 → 1.0.27 View file →
@@ -2,10 +2,9 @@
2 2
3 3 namespace Booktics\Dummy_Data;
4 4
5 5 use Booktics\Models\Service_Model;
6 -use ENS\Config;
7 -use ENS\Flow\Flow;
6 +use Ens\Flow\Flow;
8 7 use Exception;
9 8 use stdClass;
10 9
11 10 class Dummy_Data_Manager {
@@ -10,8 +9,13 @@
10 9
11 10 class Dummy_Data_Manager {
12 11 private $generator;
13 12
13 + /**
14 + * Constructor for dummy data manager
15 + *
16 + * @return void
17 + */
14 18 public function __construct() {
15 19 $this->generator = new Generator();
16 20 }
17 21
@@ -88,8 +92,13 @@
88 92
89 93 return $result;
90 94 }
91 95
96 + /**
97 + * Create automation flows
98 + *
99 + * @return array Created flow IDs
100 + */
92 101 public function create_automation_flows() {
93 102 $result = array(
94 103 'flow_ids' => array(),
95 104 'errors' => array(),
@@ -138,9 +147,9 @@
138 147 'label' => 'send_email',
139 148 'subtitle' => 'Subject: You just placed and order!',
140 149 'receiverType' => 'user_email',
141 150 'from_address' => '',
142 - 'subject' => 'You are invited to join the team',
151 + 'subject' => 'You just placed and order!',
143 152 'body' => '<p>Hi {{customer_name}}, </p><p>We are glad to let you know that your order placed successful.</p><p>Your order no: {{order_no}}</p>',
144 153 ),
145 154 'position' => array(
146 155 'x' => 200,
@@ -247,17 +256,321 @@
247 256 ),
248 257 ),
249 258 ),
250 259 ),
260 + array(
261 + 'name' => 'Appointment Scheduled',
262 + 'trigger' => 'appointment_scheduled',
263 + 'status' => 'draft',
264 + 'flow_config' => array(
265 + 'nodes' => array(
266 + array(
267 + 'id' => 'node_1',
268 + 'type' => 'trigger',
269 + 'name' => 'trigger',
270 + 'data' => array(
271 + 'label' => 'trigger: appointment_scheduled',
272 + 'subtitle' => 'Appointment Scheduled',
273 + 'triggerValue' => 'appointment_scheduled',
274 + ),
275 + 'position' => array(
276 + 'x' => 200,
277 + 'y' => 50,
278 + ),
279 + ),
280 + array(
281 + 'id' => 'node_2',
282 + 'type' => 'end',
283 + 'name' => 'end',
284 + 'data' => array(
285 + 'label' => 'end_flow',
286 + 'subtitle' => 'End execution path',
287 + ),
288 + 'position' => array(
289 + 'x' => 200,
290 + 'y' => 410,
291 + ),
292 + ),
293 + array(
294 + 'id' => 'node_3',
295 + 'type' => 'action',
296 + 'name' => 'email',
297 + 'data' => array(
298 + 'actionType' => 'send_email',
299 + 'label' => 'send_email',
300 + 'subtitle' => 'Subject: You have a new appointment.',
301 + 'receiverType' => 'user_email',
302 + 'from_address' => '',
303 + 'subject' => 'You have a new appointment',
304 + 'body' => '<p>Dear {{customer_name}}, </p><p>We are glad to let you know that you have a new appointment schedule for {{appointment_service}} with {{appointment_team_member}} on {{appointment_date}} at {{start_time}}.</p>',
305 + ),
306 + 'position' => array(
307 + 'x' => 200,
308 + 'y' => 230,
309 + ),
310 + ),
311 + ),
312 + 'edges' => array(
313 + array(
314 + 'id' => 'edge_node_1-node_3',
315 + 'type' => 'smoothstep',
316 + 'markerEnd' => array(
317 + 'type' => 'arrowclosed',
318 + ),
319 + 'source' => 'node_1',
320 + 'target' => 'node_3',
321 + 'data' => new stdClass(),
322 + ),
323 + array(
324 + 'id' => 'edge_node_3-node_2',
325 + 'type' => 'smoothstep',
326 + 'markerEnd' => array(
327 + 'type' => 'arrowclosed',
328 + ),
329 + 'source' => 'node_3',
330 + 'target' => 'node_2',
331 + 'data' => new stdClass(),
332 + ),
333 + ),
334 + ),
335 + ),
336 + array(
337 + 'name' => 'Appointment Rescheduled',
338 + 'trigger' => 'appointment_rescheduled',
339 + 'status' => 'draft',
340 + 'flow_config' => array(
341 + 'nodes' => array(
342 + array(
343 + 'id' => 'node_1',
344 + 'type' => 'trigger',
345 + 'name' => 'trigger',
346 + 'data' => array(
347 + 'label' => 'trigger: appointment_rescheduled',
348 + 'subtitle' => 'Appointment Rescheduled',
349 + 'triggerValue' => 'appointment_rescheduled',
350 + ),
351 + 'position' => array(
352 + 'x' => 200,
353 + 'y' => 50,
354 + ),
355 + ),
356 + array(
357 + 'id' => 'node_2',
358 + 'type' => 'end',
359 + 'name' => 'end',
360 + 'data' => array(
361 + 'label' => 'end_flow',
362 + 'subtitle' => 'End execution path',
363 + ),
364 + 'position' => array(
365 + 'x' => 200,
366 + 'y' => 410,
367 + ),
368 + ),
369 + array(
370 + 'id' => 'node_3',
371 + 'type' => 'action',
372 + 'name' => 'email',
373 + 'data' => array(
374 + 'actionType' => 'send_email',
375 + 'label' => 'send_email',
376 + 'subtitle' => 'Subject: Your appointment has been rescheduled.',
377 + 'receiverType' => 'user_email',
378 + 'from_address' => '',
379 + 'subject' => 'Your appointment has been rescheduled',
380 + 'body' => '<p>Dear {{customer_name}}, </p><p>We want to inform you that your appointment has been rescheduled for {{appointment_service}} with {{appointment_team_member}} on {{appointment_date}} at {{start_time}}.</p>',
381 + ),
382 + 'position' => array(
383 + 'x' => 200,
384 + 'y' => 230,
385 + ),
386 + ),
387 + ),
388 + 'edges' => array(
389 + array(
390 + 'id' => 'edge_node_1-node_3',
391 + 'type' => 'smoothstep',
392 + 'markerEnd' => array(
393 + 'type' => 'arrowclosed',
394 + ),
395 + 'source' => 'node_1',
396 + 'target' => 'node_3',
397 + 'data' => new stdClass(),
398 + ),
399 + array(
400 + 'id' => 'edge_node_3-node_2',
401 + 'type' => 'smoothstep',
402 + 'markerEnd' => array(
403 + 'type' => 'arrowclosed',
404 + ),
405 + 'source' => 'node_3',
406 + 'target' => 'node_2',
407 + 'data' => new stdClass(),
408 + ),
409 + ),
410 + ),
411 + ),
412 + array(
413 + 'name' => 'Appointment Cancelled',
414 + 'trigger' => 'appointment_cancelled',
415 + 'status' => 'draft',
416 + 'flow_config' => array(
417 + 'nodes' => array(
418 + array(
419 + 'id' => 'node_1',
420 + 'type' => 'trigger',
421 + 'name' => 'trigger',
422 + 'data' => array(
423 + 'label' => 'trigger: appointment_cancelled',
424 + 'subtitle' => 'Appointment Cancelled',
425 + 'triggerValue' => 'appointment_cancelled',
426 + ),
427 + 'position' => array(
428 + 'x' => 200,
429 + 'y' => 50,
430 + ),
431 + ),
432 + array(
433 + 'id' => 'node_2',
434 + 'type' => 'end',
435 + 'name' => 'end',
436 + 'data' => array(
437 + 'label' => 'end_flow',
438 + 'subtitle' => 'End execution path',
439 + ),
440 + 'position' => array(
441 + 'x' => 200,
442 + 'y' => 410,
443 + ),
444 + ),
445 + array(
446 + 'id' => 'node_3',
447 + 'type' => 'action',
448 + 'name' => 'email',
449 + 'data' => array(
450 + 'actionType' => 'send_email',
451 + 'label' => 'send_email',
452 + 'subtitle' => 'Subject: Your appointment has been cancelled.',
453 + 'receiverType' => 'user_email',
454 + 'from_address' => '',
455 + 'subject' => 'Your appointment has been cancelled',
456 + 'body' => '<p>Dear {{customer_name}}, </p><p>We want to inform you that your appointment has been cancelled for {{appointment_service}} with {{appointment_team_member}} on {{date}} at {{start_time}}.</p>',
457 + ),
458 + 'position' => array(
459 + 'x' => 200,
460 + 'y' => 230,
461 + ),
462 + ),
463 + ),
464 + 'edges' => array(
465 + array(
466 + 'id' => 'edge_node_1-node_3',
467 + 'type' => 'smoothstep',
468 + 'markerEnd' => array(
469 + 'type' => 'arrowclosed',
470 + ),
471 + 'source' => 'node_1',
472 + 'target' => 'node_3',
473 + 'data' => new stdClass(),
474 + ),
475 + array(
476 + 'id' => 'edge_node_3-node_2',
477 + 'type' => 'smoothstep',
478 + 'markerEnd' => array(
479 + 'type' => 'arrowclosed',
480 + ),
481 + 'source' => 'node_3',
482 + 'target' => 'node_2',
483 + 'data' => new stdClass(),
484 + ),
485 + ),
486 + ),
487 + ),
488 + array(
489 + 'name' => 'Customer Invitation',
490 + 'trigger' => 'customer_created',
491 + 'status' => 'publish',
492 + 'flow_config' => array(
493 + 'nodes' => array(
494 + array(
495 + 'id' => 'node_1',
496 + 'type' => 'trigger',
497 + 'name' => 'trigger',
498 + 'data' => array(
499 + 'label' => 'trigger: customer_created',
500 + 'subtitle' => 'Customer Created',
501 + 'triggerValue' => 'customer_created',
502 + ),
503 + 'position' => array(
504 + 'x' => 200,
505 + 'y' => 50,
506 + ),
507 + ),
508 + array(
509 + 'id' => 'node_2',
510 + 'type' => 'end',
511 + 'name' => 'end',
512 + 'data' => array(
513 + 'label' => 'end_flow',
514 + 'subtitle' => 'End execution path',
515 + ),
516 + 'position' => array(
517 + 'x' => 200,
518 + 'y' => 410,
519 + ),
520 + ),
521 + array(
522 + 'id' => 'node_3',
523 + 'type' => 'action',
524 + 'name' => 'email',
525 + 'data' => array(
526 + 'actionType' => 'send_email',
527 + 'label' => 'send_email',
528 + 'subtitle' => 'Subject: Your customer profile created.',
529 + 'receiverType' => 'customer_email',
530 + 'from_address' => '',
531 + 'subject' => 'Your customer profile created.',
532 + 'body' => '<p>Dear {{customer_full_name}}, </p><p>We are glad to let you know that you are invited as customer to our platform.</p><p>Please reset your password from the below link.</p><p><a href="{{password_reset_url}}" rel="noopener noreferrer" target="_blank">{{password_reset_url}}</a></p>',
533 + ),
534 + 'position' => array(
535 + 'x' => 200,
536 + 'y' => 230,
537 + ),
538 + ),
539 + ),
540 + 'edges' => array(
541 + array(
542 + 'id' => 'edge_node_1-node_3',
543 + 'type' => 'smoothstep',
544 + 'markerEnd' => array(
545 + 'type' => 'arrowclosed',
546 + ),
547 + 'source' => 'node_1',
548 + 'target' => 'node_3',
549 + 'data' => new stdClass(),
550 + ),
551 + array(
552 + 'id' => 'edge_node_3-node_2',
553 + 'type' => 'smoothstep',
554 + 'markerEnd' => array(
555 + 'type' => 'arrowclosed',
556 + ),
557 + 'source' => 'node_3',
558 + 'target' => 'node_2',
559 + 'data' => new stdClass(),
560 + ),
561 + ),
562 + ),
563 + ),
251 564 );
252 565 try {
253 - Config::set( 'general_prefix', 'bt' );
254 - $prefix_for_cpt = Config::get( 'general_prefix' );
566 + $prefix_for_cpt = 'bt';
255 567 $post_type = $prefix_for_cpt . '-flow';
256 568 foreach ( $automation_flows as $key => $automation_flow ) {
257 569 $existing_flow = get_posts(
258 570 array(
259 571 'post_type' => $post_type,
572 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Meta query is necessary for filtering appointments by meta fields
260 573 'meta_query' => array(
261 574 array(
262 575 'key' => '_bt_notification_flow_trigger',
263 576 'value' => $automation_flow['trigger'],
@@ -263,8 +576,9 @@
263 576 'value' => $automation_flow['trigger'],
264 577 'compare' => '=',
265 578 ),
266 579 ),
580 + 'post_status' => 'any',
267 581 'numberposts' => 1,
268 582 )
269 583 );
270 584 if ( ! empty( $existing_flow ) ) {
@@ -270,9 +584,9 @@
270 584 if ( ! empty( $existing_flow ) ) {
271 585 continue;
272 586 }
273 587
274 - $flow = new Flow( 0 );
588 + $flow = new Flow( 'bt', 0 );
275 589 $flow->set_props( $automation_flow );
276 590 $flow_id = $flow->save();
277 591 if ( $flow_id ) {
278 592 $result['flow_ids'][] = $flow_id;