PHP Класс WC_Product_Data_Store_CPT

Автор: WooThemes
Наследование: extends WC_Data_Store_WP, implements WC_Object_Data_Store_Interface, implements WC_Product_Data_Store_Interface
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$extra_data_saved If we have already saved our extra data, don't do automatic / default handling.
$internal_meta_keys array Data stored in meta keys, but not considered "meta".

Открытые методы

Метод Описание
create ( &$product ) Method to create a new product in the database.
delete ( &$product, array $args = [] ) Method to delete a product from the database.
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_related_products_query ( array $cats_array, array $tags_array, array $exclude_ids, integer $limit ) : string Builds the related posts query.
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.
read ( &$product ) Method to read a product from the database.
search_products ( string $term, string $type = '', boolean $include_variations = false ) : array Search product data for a term and return ids.
update ( &$product ) Method to update a product in the database.
update_average_rating ( WC_Product $product ) Update a products average rating meta.
update_product_stock ( $product_id_with_stock, integer | null $stock_quantity = null, string $operation = 'set' ) Update a product's stock amount directly.
update_rating_counts ( WC_Product $product ) Update a products rating counts.
update_review_count ( WC_Product $product ) Update a products review count meta.

Защищенные методы

Метод Описание
clear_caches ( &$product ) Clear any caches.
read_attributes ( &$product ) Read attributes from post meta.
read_downloads ( &$product ) Read downloads from post meta.
read_product_data ( &$product ) Read product data. Can be overridden by child classes to load other props.
update_attributes ( &$product ) Update attributes which are a mix of terms and meta data.
update_downloads ( &$product ) Update downloads.
update_post_meta ( &$product ) Helper method that updates all the post meta for a product based on it's settings in the WC_Product class.
update_term_counts ( &$product ) Count terms. These are done at this point so all product props are set in advance.
update_terms ( &$product ) For all stored terms in all taxonomies, save them to the DB.
update_version_and_type ( &$product ) Make sure we store the product type and version (to track data changes).

Описание методов

clear_caches() защищенный Метод

Clear any caches.
С версии: 2.7.0
protected clear_caches ( &$product )

create() публичный Метод

Method to create a new product in the database.
public create ( &$product )

delete() публичный Метод

Method to delete a product from the database.
public delete ( &$product, array $args = [] )
$args array Array of args to pass to the delete method.

find_matching_product_variation() публичный Метод

Find a matching (enabled) variation within a variable product.
С версии: 2.7.0
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.
Результат integer Matching variation ID or 0.

get_ending_sales() публичный Метод

Returns an array of IDs of products that have sales which are due to end.
С версии: 2.7.0
public get_ending_sales ( ) : array
Результат array

get_on_sale_products() публичный Метод

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.
С версии: 2.7.0
public get_on_sale_products ( ) : array
Результат array

get_product_id_by_sku() публичный Метод

Return product ID based on SKU.
С версии: 2.7.0
public get_product_id_by_sku ( string $sku ) : integer
$sku string
Результат integer

get_products() публичный Метод

Returns an array of products.
public get_products ( array $args = [] ) : array
$args array @see wc_get_products
Результат array

get_shipping_class_id_by_slug() публичный Метод

Get shipping class ID by slug.
С версии: 2.7.0
public get_shipping_class_id_by_slug ( $slug ) : integer | false
$slug string
Результат integer | false

get_starting_sales() публичный Метод

Returns an array of IDs of products that have sales starting soon.
С версии: 2.7.0
public get_starting_sales ( ) : array
Результат array

is_existing_sku() публичный Метод

Check if product sku is found for any other product IDs.
С версии: 2.7.0
public is_existing_sku ( integer $product_id, string $sku ) : boolean
$product_id integer
$sku string Will be slashed to work around https://core.trac.wordpress.org/ticket/27421
Результат boolean

read() публичный Метод

Method to read a product from the database.
public read ( &$product )

read_attributes() защищенный Метод

Read attributes from post meta.
С версии: 2.7.0
protected read_attributes ( &$product )

read_downloads() защищенный Метод

Read downloads from post meta.
С версии: 2.7.0
protected read_downloads ( &$product )

read_product_data() защищенный Метод

Read product data. Can be overridden by child classes to load other props.
С версии: 2.7.0
protected read_product_data ( &$product )

search_products() публичный Метод

Search product data for a term and return ids.
public search_products ( string $term, string $type = '', boolean $include_variations = false ) : array
$term string
$type string of product
$include_variations boolean in search or not
Результат array of ids

update() публичный Метод

Method to update a product in the database.
public update ( &$product )

update_attributes() защищенный Метод

Update attributes which are a mix of terms and meta data.
С версии: 2.7.0
protected update_attributes ( &$product )

update_average_rating() публичный Метод

Update a products average rating meta.
С версии: 2.7.0
public update_average_rating ( WC_Product $product )
$product WC_Product

update_downloads() защищенный Метод

Update downloads.
С версии: 2.7.0
protected update_downloads ( &$product )

update_post_meta() защищенный Метод

Helper method that updates all the post meta for a product based on it's settings in the WC_Product class.
С версии: 2.7.0
protected update_post_meta ( &$product )

update_product_stock() публичный Метод

Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues).
С версии: 2.7.0 this supports set, increase and decrease.
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.

update_rating_counts() публичный Метод

Update a products rating counts.
С версии: 2.7.0
public update_rating_counts ( WC_Product $product )
$product WC_Product

update_review_count() публичный Метод

Update a products review count meta.
С версии: 2.7.0
public update_review_count ( WC_Product $product )
$product WC_Product

update_term_counts() защищенный Метод

Count terms. These are done at this point so all product props are set in advance.
С версии: 2.7.0
protected update_term_counts ( &$product )

update_terms() защищенный Метод

For all stored terms in all taxonomies, save them to the DB.
С версии: 2.7.0
protected update_terms ( &$product )

update_version_and_type() защищенный Метод

Make sure we store the product type and version (to track data changes).
С версии: 2.7.0
protected update_version_and_type ( &$product )

Описание свойств

$extra_data_saved защищенное свойство

If we have already saved our extra data, don't do automatic / default handling.
protected $extra_data_saved

$internal_meta_keys защищенное свойство

Data stored in meta keys, but not considered "meta".
С версии: 2.7.0
protected array $internal_meta_keys
Результат array