PHP Interface WC_Product_Data_Store_Interface

Functions that must be defined by product store classes.
Author: WooThemes
Show file Open project: woocommerce/woocommerce

Public Methods

Method Description
find_matching_product_variation ( WC_Product $product, array $match_attributes = [] ) : integer Find a matching (enabled) variation within a variable product.
get_ending_sales ( ) : array Returns an array of IDs of products that have sales which are due to end.
get_featured_product_ids ( ) : array Returns a list of product IDs ( id as key => parent as value) that are featured. Uses get_posts instead of wc_get_products since we want some extra meta queries and ALL products (posts_per_page = -1).
get_on_sale_products ( ) : array Returns an array of on sale products, as an array of objects with an ID and parent_id present. Example: $return[0]->id, $return[0]->parent_id.
get_product_id_by_sku ( string $sku ) : integer Return product ID based on SKU.
get_products ( array $args = [] ) : array Returns an array of products.
get_related_products ( array $cats_array, array $tags_array, array $exclude_ids, integer $limit, integer $product_id ) : array Return a list of related products (using data like categories and IDs).
get_shipping_class_id_by_slug ( $slug ) : integer | false Get shipping class ID by slug.
get_starting_sales ( ) : array Returns an array of IDs of products that have sales starting soon.
is_existing_sku ( integer $product_id, string $sku ) : boolean Check if product sku is found for any other product IDs.
update_product_stock ( $product_id_with_stock, integer | null $stock_quantity = null, string $operation = 'set' ) Update a product's stock amount directly.

Method Details

find_matching_product_variation() public method

Find a matching (enabled) variation within a variable product.
public find_matching_product_variation ( WC_Product $product, array $match_attributes = [] ) : integer
$product WC_Product Variable product.
$match_attributes array Array of attributes we want to try to match.
return integer Matching variation ID or 0.

get_ending_sales() public method

Returns an array of IDs of products that have sales which are due to end.
public get_ending_sales ( ) : array
return array

get_on_sale_products() public method

Returns an array of on sale products, as an array of objects with an ID and parent_id present. Example: $return[0]->id, $return[0]->parent_id.
public get_on_sale_products ( ) : array
return array

get_product_id_by_sku() public method

Return product ID based on SKU.
public get_product_id_by_sku ( string $sku ) : integer
$sku string
return integer

get_products() public method

Returns an array of products.
public get_products ( array $args = [] ) : array
$args array @see wc_get_products
return array

get_shipping_class_id_by_slug() public method

Get shipping class ID by slug.
public get_shipping_class_id_by_slug ( $slug ) : integer | false
$slug string
return integer | false

get_starting_sales() public method

Returns an array of IDs of products that have sales starting soon.
public get_starting_sales ( ) : array
return array

is_existing_sku() public method

Check if product sku is found for any other product IDs.
public is_existing_sku ( integer $product_id, string $sku ) : boolean
$product_id integer
$sku string
return boolean

update_product_stock() public method

Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues).
public update_product_stock ( $product_id_with_stock, integer | null $stock_quantity = null, string $operation = 'set' )
$stock_quantity integer | null
$operation string set, increase and decrease.