PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.17
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.17
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / API / V1 / Traits / Uuid_Handler.php

Uuid_Handler.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.17, at includes/API/V1/Traits/Uuid_Handler.php

77 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uuid_Handler.
4 *
5 * @package WCPOS\WooCommercePOS
6 */
7
8 namespace WCPOS\WooCommercePOS\API\V1\Traits;
9
10 use WC_Abstract_Order;
11 use WC_Data;
12 use WC_Order_Item;
13 use WCPOS\WooCommercePOS\Sync\Pos_Uuid;
14 use WP_User;
15
16 /**
17 * Trait Uuid_Handler.
18 *
19 * Ensures each WooCommerce record (products, orders, customers etc)
20 * has a consistent unique UUID stored in the database.
21 */
22 trait Uuid_Handler {
23 /**
24 * Make sure the WC Data Object has a UUID.
25 *
26 * @param WC_Data $object The WooCommerce data object.
27 * @return void
28 */
29 private function maybe_add_post_uuid( WC_Data $object ): void {
30 $collides = $object instanceof WC_Abstract_Order
31 ? array( 'WCPOS\\WooCommercePOS\\Sync\\Pos_Uuid', 'uuid_owned_by_other_order' )
32 : array( 'WCPOS\\WooCommercePOS\\Sync\\Pos_Uuid', 'uuid_owned_by_other' );
33
34 Pos_Uuid::ensure_uuid( $object, array( 'collides' => $collides ) );
35 }
36
37 /**
38 * Ensure the WP_User has a valid UUID.
39 *
40 * @param WP_User $user The WordPress user object.
41 * @return void
42 */
43 private function maybe_add_user_uuid( WP_User $user ): void {
44 Pos_Uuid::ensure_user_uuid( $user );
45 }
46
47 /**
48 * Ensure the WC_Order_Item has a valid UUID.
49 *
50 * @param WC_Order_Item $item The order item object.
51 * @return void
52 */
53 private function maybe_add_order_item_uuid( WC_Order_Item $item ): void {
54 Pos_Uuid::ensure_order_item_uuid( $item );
55 }
56
57 /**
58 * Ensure the term has a valid UUID and return it.
59 *
60 * @param object $term The term object.
61 * @return string
62 */
63 private function get_term_uuid( $term ): string {
64 return Pos_Uuid::ensure_term_uuid( $term );
65 }
66
67 /**
68 * Retrieve order IDs by UUID.
69 *
70 * @param string $uuid The UUID to search for.
71 * @return array
72 */
73 private function get_order_ids_by_uuid( string $uuid ) {
74 return Pos_Uuid::get_order_ids_by_uuid( $uuid );
75 }
76 }
77