Skip to content

Commit 0ddb8fb

Browse files
committed
refactor: wooCommerce trigger controller
1 parent 5c7a1ab commit 0ddb8fb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

includes/Triggers/WC/WCController.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace BitCode\FI\Triggers\WC;
44

5+
use BitCode\FI\Core\Util\Helper;
6+
use BitCode\FI\Flow\Flow;
57
use WC_Booking;
68
use WC_Checkout;
79
use WC_Product_Simple;
8-
use BitCode\FI\Flow\Flow;
910
use WC_Subscriptions_Product;
10-
use BitCode\FI\Core\Util\Helper;
1111

1212
final class WCController
1313
{
@@ -600,7 +600,7 @@ public static function handle_customer_update($customer_id, $oldData, $newData)
600600
return false;
601601
}
602602

603-
if (isset($importType['role']) && $newData['role'] !== 'customer') {
603+
if (isset($newData['role']) && $newData['role'] !== 'customer') {
604604
return false;
605605
}
606606
$customer_data = (array) $newData;
@@ -626,9 +626,11 @@ public static function handle_customer_delete($customer_id)
626626

627627
$user_meta = get_userdata($customer_id);
628628
$user_roles = $user_meta->roles;
629-
if (isset($importType['role']) && \in_array('customer', $user_roles)) {
629+
630+
if (!\in_array('customer', $user_roles)) {
630631
return false;
631632
}
633+
632634
$customer_data = ['customer_id' => $customer_id];
633635
if (!empty($customer_id) && $flows = Flow::exists('WC', 3)) {
634636
Flow::execute('WC', 3, $customer_data, $flows);
@@ -885,7 +887,7 @@ public static function accessOrderData($order)
885887
$data['line_items'][] = (object) $itemData;
886888
}
887889
$data['product_names'] = implode(', ', array_column($data['line_items'], 'product_name'));
888-
$data['line_items_quantity'] = count($data['line_items']);
890+
$data['line_items_quantity'] = \count($data['line_items']);
889891

890892
return $data;
891893
}

0 commit comments

Comments
 (0)