PluginProbe
Sendy / 3.4.7
Sendy v3.4.7
3.4.6 3.4.7 trunk 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 All 32 releases
sendy / lib / Modules / Orders / ProcessInBackground.php

ProcessInBackground.php in Sendy 3.4.7, at lib/Modules/Orders/ProcessInBackground.php

44 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Sendy\WooCommerce\Modules\Orders;
4
5 use Sendy\WooCommerce\Enums\ProcessingMethod;
6 use WC_Order;
7
8 class ProcessInBackground extends OrdersModule
9 {
10 public function __construct()
11 {
12 if (get_option('sendy_processing_method') === ProcessingMethod::Sendy) {
13 add_action('woocommerce_checkout_order_created', [$this, 'handle_order_created']);
14 add_action('woocommerce_order_status_changed', [$this, 'handle_order_status_change'], 10, 4);
15 }
16 }
17
18 public function handle_order_created(WC_Order $order): void
19 {
20 if ($order->get_status() !== get_option('sendy_processable_order_status')) {
21 return;
22 }
23
24 if ($order->get_meta('_sendy_shipment_id')) {
25 return;
26 }
27
28 $this->create_shipment_with_smart_rules($order);
29 }
30
31 public function handle_order_status_change(int $orderId, string $oldStatus, string $newStatus, WC_Order $order): void
32 {
33 if ($newStatus !== get_option('sendy_processable_order_status')) {
34 return;
35 }
36
37 if ($order->get_meta('_sendy_shipment_id')) {
38 return;
39 }
40
41 $this->create_shipment_with_smart_rules($order);
42 }
43 }
44