-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathwcpos-store-functions.php
65 lines (60 loc) · 1.77 KB
/
wcpos-store-functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* WooCommerce POS Store Functions
*
* Functions for store specific things.
*/
defined( 'ABSPATH' ) || exit;
use WCPOS\WooCommercePOS\Abstracts\Store;
/**
* Standard way of retrieving stores based on certain parameters.
*
* This function should be used for store retrieval so that we have a data agnostic
* way to get a list of stores.
*
* @since 1.4.0
*
* @param array $args Array of args.
* @return array|stdClass Number of pages and an array of product objects if
* paginate is true, or just an array of values.
*/
if ( ! \function_exists( 'wcpos_get_stores' ) ) {
function wcpos_get_stores( $args = array() ) {
$store = new Store();
return apply_filters( 'woocommerce_pos_get_stores', array( $store ), $args );
}
}
/**
* Main function for returning store.
*
* This function should only be called after 'init' action is finished, as there might be taxonomies that are getting
* registered during the init action.
*
* @since 1.4.0
*
* @param mixed $the_store Post object or post ID of the product.
* @return Store|null|false
*/
if ( ! \function_exists( 'wcpos_get_store' ) ) {
function wcpos_get_store( $the_store = false ) {
$store = new Store();
return apply_filters( 'woocommerce_pos_get_store', $store, $the_store );
}
}
/**
* Helper to get the store name by ID.
*
* This function should only be called after 'init' action is finished, as there might be taxonomies that are getting
* registered during the init action.
*
* @since 1.4.0
*
* @param mixed $the_store Post object or post ID of the product.
* @return Store|null|false
*/
if ( ! \function_exists( 'wcpos_get_store_name' ) ) {
function wcpos_get_store_name( $the_store = false ) {
$store = wcpos_get_store( $the_store );
return $store->get_name();
}
}