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 / wcpos-store-functions.php

wcpos-store-functions.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.17, at includes/wcpos-store-functions.php

97 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WCPOS Store Functions.
4 *
5 * Functions for store specific things.
6 *
7 * @package WCPOS\WooCommercePOS
8 */
9
10 \defined( 'ABSPATH' ) || exit;
11
12 use WCPOS\WooCommercePOS\Abstracts\Store;
13
14 /*
15 * Standard way of retrieving stores based on certain parameters.
16 *
17 * This function should be used for store retrieval so that we have a data agnostic
18 * way to get a list of stores.
19 *
20 * @since 1.4.0
21 *
22 * @param array $args Array of args.
23 * @return array|stdClass Number of pages and an array of product objects if
24 * paginate is true, or just an array of values.
25 */
26 if ( ! \function_exists( 'wcpos_get_stores' ) ) {
27 /**
28 * Get stores based on certain parameters.
29 *
30 * @param array $args Array of args.
31 * @return array
32 */
33 function wcpos_get_stores( $args = array() ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
34 $store = new Store();
35
36 return apply_filters( 'woocommerce_pos_get_stores', array( $store ), $args );
37 }
38 }
39
40 /*
41 * Main function for returning store.
42 *
43 * This function should only be called after 'init' action is finished, as there might be taxonomies that are getting
44 * registered during the init action.
45 *
46 * @since 1.4.0
47 *
48 * @param mixed $the_store Post object or post ID of the product.
49 * @param array $args Optional lookup args.
50 * @return Store|null|false
51 */
52 if ( ! \function_exists( 'wcpos_get_store' ) ) {
53 /**
54 * Main function for returning store.
55 *
56 * @param mixed $the_store Post object or post ID of the product.
57 * @param array $args Optional lookup args.
58 * @return Store|null|false
59 */
60 function wcpos_get_store( $the_store = false, array $args = array() ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
61 $store = new Store();
62
63 return apply_filters( 'woocommerce_pos_get_store', $store, $the_store, $args );
64 }
65 }
66
67 /*
68 * Helper to get the store name by ID.
69 *
70 * This function should only be called after 'init' action is finished, as there might be taxonomies that are getting
71 * registered during the init action.
72 *
73 * @since 1.4.0
74 *
75 * @param mixed $the_store Post object or post ID of the product.
76 * @param array $args Optional lookup args.
77 * @return Store|null|false
78 */
79 if ( ! \function_exists( 'wcpos_get_store_name' ) ) {
80 /**
81 * Helper to get the store name by ID.
82 *
83 * @param mixed $the_store Post object or post ID of the product.
84 * @param array $args Optional lookup args.
85 * @return string
86 */
87 function wcpos_get_store_name( $the_store = false, array $args = array() ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
88 $store = wcpos_get_store( $the_store, $args );
89
90 if ( ! \is_object( $store ) || ! \method_exists( $store, 'get_name' ) ) {
91 return '';
92 }
93
94 return $store->get_name();
95 }
96 }
97