PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.18
ووسلام – همگام سازی ووکامرس و باسلام v1.10.18
1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 1.8.7 1.8.4 All 51 releases
sync-basalam / includes / Utilities / OrderManagerUtilities.php

OrderManagerUtilities.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.18, at includes/Utilities/OrderManagerUtilities.php

46 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Utilities;
4
5 class OrderManagerUtilities
6 {
7 public static function getAllItemIdsFromMeta($wpdb, $orderId)
8 {
9 $metaKeyPattern = '_sync_basalam_item_id_%';
10
11 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct lookup on WooCommerce orders-meta table; no object cache for this query.
12 $results = $wpdb->get_results(
13 $wpdb->prepare(
14 "SELECT meta_value FROM {$wpdb->prefix}wc_orders_meta
15 WHERE order_id = %d AND meta_key LIKE %s",
16 $orderId,
17 $metaKeyPattern
18 )
19 );
20
21 $itemIds = [];
22 if ($results) {
23 foreach ($results as $row) {
24 $itemIds[] = $row->meta_value;
25 }
26 }
27
28 return $itemIds;
29 }
30
31 public static function getInvoiceId($wpdb, $orderId)
32 {
33 $tableName = $wpdb->prefix . 'sync_basalam_payments';
34
35 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Custom plugin table; identifier from $wpdb->prefix, not user input.
36 $orderData = $wpdb->get_row(
37 $wpdb->prepare(
38 "SELECT invoice_id FROM {$tableName} WHERE order_id = %d LIMIT 1",
39 $orderId
40 )
41 );
42
43 return $orderData ? $orderData->invoice_id : null;
44 }
45 }
46