WC_Data_Store::__construct( string $object_type )
Tells WC_Data_Store which object (coupon, product, order, etc) store we want to work with.
Description Description
Parameters Parameters
- $object_type
-
(Required) Name of object.
Source Source
File: includes/class-wc-data-store.php
public function __construct( $object_type ) { $this->object_type = $object_type; $this->stores = apply_filters( 'woocommerce_data_stores', $this->stores ); // If this object type can't be found, check to see if we can load one // level up (so if product-type isn't found, we try product). if ( ! array_key_exists( $object_type, $this->stores ) ) { $pieces = explode( '-', $object_type ); $object_type = $pieces[0]; } if ( array_key_exists( $object_type, $this->stores ) ) { $store = apply_filters( 'woocommerce_' . $object_type . '_data_store', $this->stores[ $object_type ] ); if ( is_object( $store ) ) { if ( ! $store instanceof WC_Object_Data_Store_Interface ) { throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); } $this->current_class_name = get_class( $store ); $this->instance = $store; } else { if ( ! class_exists( $store ) ) { throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); } $this->current_class_name = $store; $this->instance = new $store(); } } else { throw new Exception( __( 'Invalid data store.', 'woocommerce' ) ); } }