WC_Data_Store::__construct PHP Method

__construct() public method

Tells WC_Data_Store which object (coupon, product, order, etc) store we want to work with.
public __construct ( string $object_type )
$object_type string Name of object.
    public function __construct($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 (!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'));
        }
    }