activities_helper.php
1 year ago
agent_helper.php
1 year ago
auth_helper.php
9 months ago
blocks_helper.php
1 year ago
booking_helper.php
1 year ago
bricks_helper.php
1 year ago
bundles_helper.php
1 year ago
calendar_helper.php
9 months ago
carts_helper.php
1 year ago
connector_helper.php
9 months ago
csv_helper.php
9 months ago
customer_helper.php
9 months ago
customer_import_helper.php
9 months ago
database_helper.php
9 months ago
debug_helper.php
1 year ago
defaults_helper.php
1 year ago
elementor_helper.php
1 year ago
email_helper.php
9 months ago
encrypt_helper.php
1 year ago
events_helper.php
9 months ago
form_helper.php
9 months ago
icalendar_helper.php
1 year ago
image_helper.php
1 year ago
invoices_helper.php
9 months ago
license_helper.php
1 year ago
location_helper.php
1 year ago
marketing_systems_helper.php
1 year ago
meeting_systems_helper.php
1 year ago
menu_helper.php
9 months ago
meta_helper.php
1 year ago
migrations_helper.php
1 year ago
money_helper.php
1 year ago
notifications_helper.php
9 months ago
order_intent_helper.php
9 months ago
orders_helper.php
1 year ago
otp_helper.php
9 months ago
pages_helper.php
1 year ago
params_helper.php
1 year ago
payments_helper.php
1 year ago
price_breakdown_helper.php
1 year ago
process_jobs_helper.php
1 year ago
processes_helper.php
1 year ago
replacer_helper.php
1 year ago
resource_helper.php
1 year ago
roles_helper.php
9 months ago
router_helper.php
1 year ago
service_helper.php
1 year ago
sessions_helper.php
1 year ago
settings_helper.php
9 months ago
short_links_systems_helper.php
9 months ago
shortcodes_helper.php
9 months ago
sms_helper.php
1 year ago
steps_helper.php
9 months ago
stripe_connect_helper.php
9 months ago
styles_helper.php
9 months ago
support_topics_helper.php
1 year ago
time_helper.php
9 months ago
timeline_helper.php
9 months ago
transaction_helper.php
1 year ago
transaction_intent_helper.php
1 year ago
util_helper.php
9 months ago
version_specific_updates_helper.php
9 months ago
whatsapp_helper.php
1 year ago
work_periods_helper.php
1 year ago
wp_datetime.php
1 year ago
wp_user_helper.php
1 year ago
meta_helper.php
118 lines
| 1 | <?php |
| 2 | |
| 3 | class OsMetaHelper { |
| 4 | |
| 5 | function __construct(){ |
| 6 | } |
| 7 | |
| 8 | public static function get_service_meta_by_key($meta_key, $service_id, $default = false){ |
| 9 | $meta = new OsServiceMetaModel(); |
| 10 | return $meta->get_by_key($meta_key, $service_id, $default); |
| 11 | } |
| 12 | |
| 13 | public static function save_service_meta_by_key($meta_key, $meta_value, $service_id){ |
| 14 | $meta = new OsServiceMetaModel(); |
| 15 | return $meta->save_by_key($meta_key, $meta_value, $service_id); |
| 16 | } |
| 17 | |
| 18 | public static function delete_service_meta_by_key($meta_key, $service_id){ |
| 19 | $meta = new OsServiceMetaModel(); |
| 20 | return $meta->delete_by_key($meta_key, $service_id); |
| 21 | } |
| 22 | |
| 23 | |
| 24 | public static function get_agent_meta_by_key($meta_key, $agent_id, $default = false){ |
| 25 | $meta = new OsAgentMetaModel(); |
| 26 | return $meta->get_by_key($meta_key, $agent_id, $default); |
| 27 | } |
| 28 | |
| 29 | public static function save_agent_meta_by_key($meta_key, $meta_value, $agent_id){ |
| 30 | $meta = new OsAgentMetaModel(); |
| 31 | return $meta->save_by_key($meta_key, $meta_value, $agent_id); |
| 32 | } |
| 33 | |
| 34 | public static function delete_agent_meta_by_key($meta_key, $agent_id){ |
| 35 | $meta = new OsAgentMetaModel(); |
| 36 | return $meta->delete_by_key($meta_key, $agent_id); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | |
| 41 | public static function get_booking_metas($booking_id, $default = []){ |
| 42 | $meta = new OsBookingMetaModel(); |
| 43 | return $meta->get_by_object_id($booking_id, $default); |
| 44 | } |
| 45 | |
| 46 | public static function get_booking_meta_by_key($meta_key, $booking_id, $default = false){ |
| 47 | $meta = new OsBookingMetaModel(); |
| 48 | return $meta->get_by_key($meta_key, $booking_id, $default); |
| 49 | } |
| 50 | |
| 51 | public static function save_booking_meta_by_key($meta_key, $meta_value, $booking_id){ |
| 52 | $meta = new OsBookingMetaModel(); |
| 53 | return $meta->save_by_key($meta_key, $meta_value, $booking_id); |
| 54 | } |
| 55 | |
| 56 | public static function delete_booking_meta($meta_key, $booking_id){ |
| 57 | if(empty($meta_key) || empty($booking_id)) return; |
| 58 | $booking_meta_model = new OsBookingMetaModel(); |
| 59 | $booking_meta_model->delete_by_key($meta_key, $booking_id); |
| 60 | } |
| 61 | |
| 62 | |
| 63 | public static function get_customer_metas($customer_id, $default = []){ |
| 64 | $meta = new OsCustomerMetaModel(); |
| 65 | return $meta->get_by_object_id($customer_id, $default); |
| 66 | } |
| 67 | |
| 68 | public static function get_customer_meta_by_key($meta_key, $customer_id, $default = false){ |
| 69 | $meta = new OsCustomerMetaModel(); |
| 70 | return $meta->get_by_key($meta_key, $customer_id, $default); |
| 71 | } |
| 72 | |
| 73 | public static function save_customer_meta_by_key($meta_key, $meta_value, $customer_id){ |
| 74 | $meta = new OsCustomerMetaModel(); |
| 75 | return $meta->save_by_key($meta_key, $meta_value, $customer_id); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get Customers By Filter |
| 80 | * @param $filters |
| 81 | * @return array |
| 82 | */ |
| 83 | public static function get_customers_by_filter( $filters ): array { |
| 84 | $meta = new OsCustomerMetaModel(); |
| 85 | $where = []; |
| 86 | foreach ( $filters as $filter_key => $filter_value ) { |
| 87 | $where['OR'][] = [ 'AND' => [ 'meta_key' => $filter_key, 'meta_value LIKE' => '%' . esc_sql( $filter_value ) . '%' ] ]; |
| 88 | } |
| 89 | $customers = $meta->select( 'object_id' ) |
| 90 | ->where( $where ) |
| 91 | ->group_by( 'object_id' ) |
| 92 | ->having( 'COUNT(DISTINCT meta_key)=' . count( $filters ) ) |
| 93 | ->get_results(); |
| 94 | |
| 95 | return array_column( $customers, 'object_id' ); |
| 96 | } |
| 97 | |
| 98 | public static function get_booking_id_by_meta_value($meta_key, $meta_value){ |
| 99 | $meta = new OsBookingMetaModel(); |
| 100 | return $meta->get_object_id_by_value($meta_key, $meta_value); |
| 101 | } |
| 102 | |
| 103 | public static function get_order_id_by_meta_value($meta_key, $meta_value){ |
| 104 | $meta = new OsOrderMetaModel(); |
| 105 | return $meta->get_object_id_by_value($meta_key, $meta_value); |
| 106 | } |
| 107 | |
| 108 | public static function get_order_meta_by_key($meta_key, $order_id, $default = false){ |
| 109 | $meta = new OsOrderMetaModel(); |
| 110 | return $meta->get_by_key($meta_key, $order_id, $default); |
| 111 | } |
| 112 | |
| 113 | public static function save_order_meta_by_key($meta_key, $meta_value, $order_id){ |
| 114 | $meta = new OsOrderMetaModel(); |
| 115 | return $meta->save_by_key($meta_key, $meta_value, $order_id); |
| 116 | } |
| 117 | } |
| 118 | ?> |