Skip to content

Commit 9c2c926

Browse files
committed
Merge branch 'main' into rishad-dev-tmp
2 parents 808d966 + c6004b9 commit 9c2c926

File tree

4 files changed

+1085
-735
lines changed

4 files changed

+1085
-735
lines changed

includes/Core/Util/Helper.php

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

33
namespace BitCode\FI\Core\Util;
44

5+
use BitCode\FI\Triggers\TriggerController;
56
use DateTime;
7+
use DateTimeZone;
8+
use Exception;
69
use stdClass;
710
use WP_Error;
8-
use Exception;
9-
use DateTimeZone;
10-
use BitCode\FI\Triggers\TriggerController;
1111

1212
/**
1313
* bit-integration helper class
@@ -299,6 +299,72 @@ public static function acfGetFieldGroups($type = [])
299299
});
300300
}
301301

302+
public static function getAcfFieldData($acfFieldGroups, $postId)
303+
{
304+
if (!class_exists('ACF')) {
305+
return [];
306+
}
307+
308+
$data = [];
309+
310+
foreach ($acfFieldGroups as $group) {
311+
foreach (acf_get_fields($group['ID']) as $field) {
312+
$data[$field['_name']] = get_post_meta($postId, $field['_name'])[0];
313+
}
314+
}
315+
316+
return $data;
317+
}
318+
319+
public static function getWCCustomCheckoutData($order)
320+
{
321+
if (!class_exists('WooCommerce')) {
322+
return [];
323+
}
324+
325+
$data = [];
326+
$order = \is_object($order) ? (array) $order : $order;
327+
$checkoutFields = WC()->checkout()->get_checkout_fields();
328+
329+
foreach ($checkoutFields as $group) {
330+
foreach ($group as $field) {
331+
if (!empty($field['custom'])) {
332+
$data[$field['name']] = $order[$field['name']];
333+
}
334+
}
335+
}
336+
337+
return $data;
338+
}
339+
340+
public static function getFlexibleCheckoutData($order)
341+
{
342+
if (!class_exists('WooCommerce')) {
343+
return [];
344+
}
345+
346+
$data = [];
347+
$order = \is_object($order) ? (array) $order : $order;
348+
$checkoutFields = WC()->checkout()->get_checkout_fields();
349+
350+
foreach ($checkoutFields as $groupKey => $group) {
351+
if ($groupKey == 'shipping') {
352+
continue;
353+
}
354+
355+
foreach ($group as $fieldKey => $field) {
356+
if (empty($field['custom_field'])) {
357+
continue;
358+
}
359+
360+
$fieldKey = $field['name'] ?? $fieldKey;
361+
$data[$fieldKey] = $order[$fieldKey] ?? '';
362+
}
363+
}
364+
365+
return $data;
366+
}
367+
302368
public static function isPrimaryKeysMatch($recordData, $PrimaryKeys)
303369
{
304370
foreach ($PrimaryKeys as $primaryKey) {

0 commit comments

Comments
 (0)