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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / class-wc-data-store.php
woocommerce / includes Last commit date
abstracts 2 years ago admin 2 years ago blocks 5 years ago cli 3 years ago customizer 3 years ago data-stores 2 years ago emails 2 years ago export 2 years ago gateways 2 years ago import 2 years ago integrations 4 years ago interfaces 3 years ago legacy 2 years ago libraries 3 years ago log-handlers 4 years ago payment-tokens 5 years ago queue 4 years ago react-admin 2 years ago rest-api 2 years ago shipping 2 years ago shortcodes 2 years ago theme-support 3 years ago tracks 2 years ago traits 5 years ago walkers 5 years ago wccom-site 2 years ago widgets 3 years ago class-wc-ajax.php 2 years ago class-wc-api.php 4 years ago class-wc-auth.php 4 years ago class-wc-autoloader.php 5 years ago class-wc-background-emailer.php 5 years ago class-wc-background-updater.php 5 years ago class-wc-breadcrumb.php 5 years ago class-wc-cache-helper.php 3 years ago class-wc-cart-fees.php 2 years ago class-wc-cart-session.php 2 years ago class-wc-cart-totals.php 2 years ago class-wc-cart.php 2 years ago class-wc-checkout.php 2 years ago class-wc-cli.php 3 years ago class-wc-comments.php 3 years ago class-wc-countries.php 2 years ago class-wc-coupon.php 3 years ago class-wc-customer-download-log.php 5 years ago class-wc-customer-download.php 4 years ago class-wc-customer.php 2 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 3 years ago class-wc-datetime.php 4 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 3 years ago class-wc-discounts.php 3 years ago class-wc-download-handler.php 3 years ago class-wc-emails.php 3 years ago class-wc-embed.php 5 years ago class-wc-form-handler.php 2 years ago class-wc-frontend-scripts.php 3 years ago class-wc-geo-ip.php 4 years ago class-wc-geolite-integration.php 6 years ago class-wc-geolocation.php 3 years ago class-wc-https.php 2 years ago class-wc-install.php 2 years ago class-wc-integrations.php 5 years ago class-wc-log-levels.php 5 years ago class-wc-logger.php 4 years ago class-wc-meta-data.php 4 years ago class-wc-order-factory.php 3 years ago class-wc-order-item-coupon.php 4 years ago class-wc-order-item-fee.php 4 years ago class-wc-order-item-meta.php 4 years ago class-wc-order-item-product.php 4 years ago class-wc-order-item-shipping.php 4 years ago class-wc-order-item-tax.php 4 years ago class-wc-order-item.php 4 years ago class-wc-order-query.php 4 years ago class-wc-order-refund.php 2 years ago class-wc-order.php 2 years ago class-wc-payment-gateways.php 4 years ago class-wc-payment-tokens.php 3 years ago class-wc-post-data.php 3 years ago class-wc-post-types.php 3 years ago class-wc-privacy-background-process.php 5 years ago class-wc-privacy-erasers.php 4 years ago class-wc-privacy-exporters.php 4 years ago class-wc-privacy.php 2 years ago class-wc-product-attribute.php 4 years ago class-wc-product-download.php 4 years ago class-wc-product-external.php 5 years ago class-wc-product-factory.php 5 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 5 years ago class-wc-product-simple.php 3 years ago class-wc-product-variable.php 3 years ago class-wc-product-variation.php 4 years ago class-wc-query.php 3 years ago class-wc-rate-limiter.php 4 years ago class-wc-regenerate-images-request.php 3 years ago class-wc-regenerate-images.php 3 years ago class-wc-register-wp-admin-settings.php 4 years ago class-wc-rest-authentication.php 3 years ago class-wc-rest-exception.php 5 years ago class-wc-session-handler.php 2 years ago class-wc-shipping-rate.php 3 years ago class-wc-shipping-zone.php 5 years ago class-wc-shipping-zones.php 5 years ago class-wc-shipping.php 4 years ago class-wc-shortcodes.php 5 years ago class-wc-structured-data.php 3 years ago class-wc-tax.php 2 years ago class-wc-template-loader.php 2 years ago class-wc-tracker.php 2 years ago class-wc-validation.php 3 years ago class-wc-webhook.php 2 years ago class-woocommerce.php 3 months ago wc-account-functions.php 2 years ago wc-attribute-functions.php 3 years ago wc-cart-functions.php 2 years ago wc-conditional-functions.php 2 years ago wc-core-functions.php 2 years ago wc-coupon-functions.php 3 years ago wc-deprecated-functions.php 3 years ago wc-formatting-functions.php 2 years ago wc-notice-functions.php 3 years ago wc-order-functions.php 2 years ago wc-order-item-functions.php 3 years ago wc-page-functions.php 2 years ago wc-product-functions.php 3 years ago wc-rest-functions.php 3 years ago wc-stock-functions.php 3 years ago wc-template-functions.php 2 years ago wc-template-hooks.php 5 years ago wc-term-functions.php 3 years ago wc-update-functions.php 2 years ago wc-user-functions.php 2 years ago wc-webhook-functions.php 4 years ago wc-widget-functions.php 5 years ago
class-wc-data-store.php
239 lines
1 <?php
2 /**
3 * WC Data Store.
4 *
5 * @package WooCommerce\Classes
6 * @since 3.0.0
7 * @version 3.0.0
8 */
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Data store class.
14 */
15 class WC_Data_Store {
16
17 /**
18 * Contains an instance of the data store class that we are working with.
19 *
20 * @var WC_Data_Store
21 */
22 private $instance = null;
23
24 /**
25 * Contains an array of default WC supported data stores.
26 * Format of object name => class name.
27 * Example: 'product' => 'WC_Product_Data_Store_CPT'
28 * You can also pass something like product_<type> for product stores and
29 * that type will be used first when available, if a store is requested like
30 * this and doesn't exist, then the store would fall back to 'product'.
31 * Ran through `woocommerce_data_stores`.
32 *
33 * @var array
34 */
35 private $stores = array(
36 'coupon' => 'WC_Coupon_Data_Store_CPT',
37 'customer' => 'WC_Customer_Data_Store',
38 'customer-download' => 'WC_Customer_Download_Data_Store',
39 'customer-download-log' => 'WC_Customer_Download_Log_Data_Store',
40 'customer-session' => 'WC_Customer_Data_Store_Session',
41 'order' => 'WC_Order_Data_Store_CPT',
42 'order-refund' => 'WC_Order_Refund_Data_Store_CPT',
43 'order-item' => 'WC_Order_Item_Data_Store',
44 'order-item-coupon' => 'WC_Order_Item_Coupon_Data_Store',
45 'order-item-fee' => 'WC_Order_Item_Fee_Data_Store',
46 'order-item-product' => 'WC_Order_Item_Product_Data_Store',
47 'order-item-shipping' => 'WC_Order_Item_Shipping_Data_Store',
48 'order-item-tax' => 'WC_Order_Item_Tax_Data_Store',
49 'payment-token' => 'WC_Payment_Token_Data_Store',
50 'product' => 'WC_Product_Data_Store_CPT',
51 'product-grouped' => 'WC_Product_Grouped_Data_Store_CPT',
52 'product-variable' => 'WC_Product_Variable_Data_Store_CPT',
53 'product-variation' => 'WC_Product_Variation_Data_Store_CPT',
54 'shipping-zone' => 'WC_Shipping_Zone_Data_Store',
55 'webhook' => 'WC_Webhook_Data_Store',
56 );
57
58 /**
59 * Contains the name of the current data store's class name.
60 *
61 * @var string
62 */
63 private $current_class_name = '';
64
65 /**
66 * The object type this store works with.
67 *
68 * @var string
69 */
70 private $object_type = '';
71
72
73 /**
74 * Tells WC_Data_Store which object (coupon, product, order, etc)
75 * store we want to work with.
76 *
77 * @throws Exception When validation fails.
78 * @param string $object_type Name of object.
79 */
80 public function __construct( $object_type ) {
81 $this->object_type = $object_type;
82 $this->stores = apply_filters( 'woocommerce_data_stores', $this->stores );
83
84 // If this object type can't be found, check to see if we can load one
85 // level up (so if product-type isn't found, we try product).
86 if ( ! array_key_exists( $object_type, $this->stores ) ) {
87 $pieces = explode( '-', $object_type );
88 $object_type = $pieces[0];
89 }
90
91 if ( array_key_exists( $object_type, $this->stores ) ) {
92 $store = apply_filters( 'woocommerce_' . $object_type . '_data_store', $this->stores[ $object_type ] );
93 if ( is_object( $store ) ) {
94 if ( ! $store instanceof WC_Object_Data_Store_Interface ) {
95 throw new Exception( __( 'Invalid data store.', 'woocommerce' ) );
96 }
97 $this->current_class_name = get_class( $store );
98 $this->instance = $store;
99 } else {
100 if ( ! class_exists( $store ) ) {
101 throw new Exception( __( 'Invalid data store.', 'woocommerce' ) );
102 }
103 $this->current_class_name = $store;
104 $this->instance = new $store();
105 }
106 } else {
107 throw new Exception( __( 'Invalid data store.', 'woocommerce' ) );
108 }
109 }
110
111 /**
112 * Only store the object type to avoid serializing the data store instance.
113 *
114 * @return array
115 */
116 public function __sleep() {
117 return array( 'object_type' );
118 }
119
120 /**
121 * Re-run the constructor with the object type.
122 *
123 * @throws Exception When validation fails.
124 */
125 public function __wakeup() {
126 $this->__construct( $this->object_type );
127 }
128
129 /**
130 * Loads a data store.
131 *
132 * @param string $object_type Name of object.
133 *
134 * @since 3.0.0
135 * @throws Exception When validation fails.
136 * @return WC_Data_Store
137 */
138 public static function load( $object_type ) {
139 return new WC_Data_Store( $object_type );
140 }
141
142 /**
143 * Returns the class name of the current data store.
144 *
145 * @since 3.0.0
146 * @return string
147 */
148 public function get_current_class_name() {
149 return $this->current_class_name;
150 }
151
152 /**
153 * Reads an object from the data store.
154 *
155 * @since 3.0.0
156 * @param WC_Data $data WooCommerce data instance.
157 */
158 public function read( &$data ) {
159 $this->instance->read( $data );
160 }
161
162 /**
163 * Reads multiple objects from the data store.
164 *
165 * @since 6.9.0
166 * @param array[WC_Data] $objects Array of object instances to read.
167 */
168 public function read_multiple( &$objects = array() ) {
169 // If the datastore allows for bulk-reading, use it.
170 if ( is_callable( array( $this->instance, 'read_multiple' ) ) ) {
171 $this->instance->read_multiple( $objects );
172 } else {
173 foreach ( $objects as &$obj ) {
174 $this->read( $obj );
175 }
176 }
177 }
178
179 /**
180 * Create an object in the data store.
181 *
182 * @since 3.0.0
183 * @param WC_Data $data WooCommerce data instance.
184 */
185 public function create( &$data ) {
186 $this->instance->create( $data );
187 }
188
189 /**
190 * Update an object in the data store.
191 *
192 * @since 3.0.0
193 * @param WC_Data $data WooCommerce data instance.
194 */
195 public function update( &$data ) {
196 $this->instance->update( $data );
197 }
198
199 /**
200 * Delete an object from the data store.
201 *
202 * @since 3.0.0
203 * @param WC_Data $data WooCommerce data instance.
204 * @param array $args Array of args to pass to the delete method.
205 */
206 public function delete( &$data, $args = array() ) {
207 $this->instance->delete( $data, $args );
208 }
209
210 /**
211 * Data stores can define additional functions (for example, coupons have
212 * some helper methods for increasing or decreasing usage). This passes
213 * through to the instance if that function exists.
214 *
215 * @since 3.0.0
216 * @param string $method Method.
217 * @param mixed $parameters Parameters.
218 * @return mixed
219 */
220 public function __call( $method, $parameters ) {
221 if ( is_callable( array( $this->instance, $method ) ) ) {
222 $object = array_shift( $parameters );
223 $parameters = array_merge( array( &$object ), $parameters );
224 return $this->instance->$method( ...$parameters );
225 }
226 }
227
228 /**
229 * Check if the data store we are working with has a callable method.
230 *
231 * @param string $method Method name.
232 *
233 * @return bool Whether the passed method is callable.
234 */
235 public function has_callable( string $method ) : bool {
236 return is_callable( array( $this->instance, $method ) );
237 }
238 }
239