PHP Класс WC_Abstract_Legacy_Product

Legacy and deprecated functions are here to keep the WC_Abstract_Product clean. This class will be removed in future versions.
Автор: WooThemes
Наследование: extends WC_Data
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$product_type string The product's type (simple, variable etc).

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

Метод Описание
__get ( string $key ) : mixed Magic __get method for backwards compatibility. Maps legacy vars to new getters.
__isset ( string $key ) : boolean Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
adjust_price ( mixed $price ) Adjust a products price dynamically.
check_stock_status ( ) Check if the stock status needs changing.
enable_dimensions_display ( ) : boolean Returns whether or not we are showing dimensions on the product page.
get_availability ( ) : string Returns the availability of the product.
get_categories ( string $sep = ', ', string $before = '', string $after = '' ) : string Returns the product categories.
get_child ( mixed $child_id ) : WC_Product | WC_Product_variation Returns the child product.
get_cross_sells ( ) : array Returns the cross sell product ids.
get_display_price ( string $price = '', integer $qty = 1 ) : string Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
get_files ( ) : array Same as get_downloads in CRUD.
get_formatted_variation_attributes ( $flat = false ) : string Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names.
get_gallery_attachment_ids ( ) : array Returns the gallery attachment ids.
get_matching_variation ( $match_attributes = [] ) Match a variation to a given set of attributes using a WP_Query.
get_parent ( ) : integer Get the parent of the post.
get_post_data ( ) : WP_Post Get the product's post data.
get_price_excluding_tax ( integer $qty = 1, string $price = '' ) : string Returns the price (excluding tax) - ignores tax_class filters since the price may *include* tax and thus needs subtracting.
get_price_html_from_text ( ) : string Functions for getting parts of a price, in html, used by get_price_html.
get_price_html_from_to ( string $from, mixed $to ) : string Functions for getting parts of a price, in html, used by get_price_html.
get_price_including_tax ( integer $qty = 1, string $price = '' ) : string Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes.
get_price_suffix ( string $price = '', integer $qty = 1 ) : string Get the suffix to display after prices > 0.
get_rating_html ( string $rating = null ) : string Returns the product rating in html format.
get_related ( $limit = 5 ) Get and return related products.
get_tags ( string $sep = ', ', string $before = '', string $after = '' ) : array Returns the product tags.
get_total_stock ( ) : integer Get total stock - This is the stock of parent and children combined.
get_upsells ( ) : array Returns the upsell product ids.
get_variation_default_attributes ( ) : array If set, get the default attributes for a variable product.
get_variation_description ( ) : string Get product variation description.
get_variation_id ( ) : integer Get variation ID.
grouped_product_sync ( )
has_all_attributes_set ( ) : boolean Check if all variation's attributes are set.
has_default_attributes ( ) : boolean Check if variable product has default attributes set.
increase_stock ( integer $amount = 1 ) : integer Increase stock level of the product.
list_attributes ( ) Lists a table of attributes for the product page.
parent_is_visible ( ) : boolean Returns whether or not the variations parent is visible.
reduce_stock ( integer $amount = 1 ) : integer Reduce stock level of the product.
set_stock ( $amount = null, $mode = 'set' ) Set stock level of the product.
sync_attributes ( $product, $children = false ) Sync the variable product's attributes with the variations.
sync_average_rating ( integer $post_id ) Sync product rating. Can be called statically.
sync_rating_count ( integer $post_id ) Sync product rating count. Can be called statically.
variable_product_sync ( $product_id = '' ) Sync variable product prices with the children lowest/highest prices.

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

Метод Описание
build_related_query ( $cats_array, $tags_array, $exclude_ids, $limit ) Builds the related posts query.
get_availability_class ( ) : string Get availability classname based on stock status.
get_availability_text ( ) : string Get availability text based on stock status.
get_related_terms ( $term ) Retrieves related product terms.

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

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

Magic __get method for backwards compatibility. Maps legacy vars to new getters.
public __get ( string $key ) : mixed
$key string Key name.
Результат mixed

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

Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
public __isset ( string $key ) : boolean
$key string Key name.
Результат boolean

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

Adjust a products price dynamically.
Устаревший: 2.7.0
public adjust_price ( mixed $price )
$price mixed

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

Check if the stock status needs changing.
Устаревший: 2.7.0 Sync is done automatically on read/save, so calling this should not be needed any more.
public check_stock_status ( )

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

Returns whether or not we are showing dimensions on the product page.
Устаревший: 2.7.0 Unused.
public enable_dimensions_display ( ) : boolean
Результат boolean

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

Returns the availability of the product.
Устаревший: 2.7.0
public get_availability ( ) : string
Результат string

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

Get availability classname based on stock status.
Устаревший: 2.7.0
protected get_availability_class ( ) : string
Результат string

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

Get availability text based on stock status.
Устаревший: 2.7.0
protected get_availability_text ( ) : string
Результат string

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

Returns the product categories.
Устаревший: 2.7.0
public get_categories ( string $sep = ', ', string $before = '', string $after = '' ) : string
$sep string (default: ', ').
$before string (default: '').
$after string (default: '').
Результат string

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

Returns the child product.
Устаревший: 2.7.0 Use wc_get_product instead.
public get_child ( mixed $child_id ) : WC_Product | WC_Product_variation
$child_id mixed
Результат WC_Product | WC_Product_variation

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

Returns the cross sell product ids.
Устаревший: 2.7.0
public get_cross_sells ( ) : array
Результат array

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

Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
Устаревший: 2.7.0 Use wc_get_price_to_display instead.
public get_display_price ( string $price = '', integer $qty = 1 ) : string
$price string to calculate, left blank to just use get_price()
$qty integer passed on to get_price_including_tax() or get_price_excluding_tax()
Результат string

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

Same as get_downloads in CRUD.
Устаревший: 2.7.0
public get_files ( ) : array
Результат array

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

Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names.
Устаревший: 2.7.0
public get_formatted_variation_attributes ( $flat = false ) : string
Результат string

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

Match a variation to a given set of attributes using a WP_Query.
Устаревший: 2.7.0 in favour of Product data store's find_matching_product_variation.
public get_matching_variation ( $match_attributes = [] )

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

Get the parent of the post.
Устаревший: 2.7.0
public get_parent ( ) : integer
Результат integer

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

Get the product's post data.
Устаревший: 2.7.0
public get_post_data ( ) : WP_Post
Результат WP_Post

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

Uses store base tax rates. Can work for a specific $qty for more accurate taxes.
Устаревший: 2.7.0 Use wc_get_price_excluding_tax instead.
public get_price_excluding_tax ( integer $qty = 1, string $price = '' ) : string
$qty integer
$price string to calculate, left blank to just use get_price()
Результат string

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

Functions for getting parts of a price, in html, used by get_price_html.
Устаревший: 2.7.0
public get_price_html_from_text ( ) : string
Результат string

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

Functions for getting parts of a price, in html, used by get_price_html.
Устаревший: 2.7.0 Use wc_format_sale_price instead.
public get_price_html_from_to ( string $from, mixed $to ) : string
$from string String or float to wrap with 'from' text
$to mixed String or float to wrap with 'to' text
Результат string

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

Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes.
Устаревший: 2.7.0 Use wc_get_price_including_tax instead.
public get_price_including_tax ( integer $qty = 1, string $price = '' ) : string
$qty integer
$price string to calculate, left blank to just use get_price()
Результат string

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

Get the suffix to display after prices > 0.
Устаревший: 2.7.0 Use wc_get_price_suffix instead.
public get_price_suffix ( string $price = '', integer $qty = 1 ) : string
$price string to calculate, left blank to just use get_price()
$qty integer passed on to get_price_including_tax() or get_price_excluding_tax()
Результат string

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

Returns the product rating in html format.
Устаревший: 2.7.0
public get_rating_html ( string $rating = null ) : string
$rating string (default: '')
Результат string

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

Returns the product tags.
Устаревший: 2.7.0
public get_tags ( string $sep = ', ', string $before = '', string $after = '' ) : array
$sep string (default: ', ').
$before string (default: '').
$after string (default: '').
Результат array

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

Get total stock - This is the stock of parent and children combined.
Устаревший: 2.7.0
public get_total_stock ( ) : integer
Результат integer

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

Returns the upsell product ids.
Устаревший: 2.7.0
public get_upsells ( ) : array
Результат array

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

If set, get the default attributes for a variable product.
Устаревший: 2.7.0
public get_variation_default_attributes ( ) : array
Результат array

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

Get product variation description.
Устаревший: 2.7.0
public get_variation_description ( ) : string
Результат string

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

Get variation ID.
Устаревший: 2.7.0
public get_variation_id ( ) : integer
Результат integer

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

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

Check if all variation's attributes are set.
Устаревший: 2.7.0
public has_all_attributes_set ( ) : boolean
Результат boolean

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

Check if variable product has default attributes set.
Устаревший: 2.7.0
public has_default_attributes ( ) : boolean
Результат boolean

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

Increase stock level of the product.
Устаревший: 2.7.0
public increase_stock ( integer $amount = 1 ) : integer
$amount integer Amount to increase by. Default 1.
Результат integer new stock level

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

Lists a table of attributes for the product page.
Устаревший: 2.7.0 Use wc_display_product_attributes instead.
public list_attributes ( )

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

Returns whether or not the variations parent is visible.
Устаревший: 2.7.0
public parent_is_visible ( ) : boolean
Результат boolean

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

Reduce stock level of the product.
Устаревший: 2.7.0
public reduce_stock ( integer $amount = 1 ) : integer
$amount integer Amount to reduce by. Default: 1
Результат integer new stock level

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

Set stock level of the product.
Устаревший: 2.7.0
public set_stock ( $amount = null, $mode = 'set' )

sync_attributes() публичный статический Метод

Sync the variable product's attributes with the variations.
public static sync_attributes ( $product, $children = false )

sync_average_rating() публичный статический Метод

Sync product rating. Can be called statically.
Устаревший: 2.7.0
public static sync_average_rating ( integer $post_id )
$post_id integer

sync_rating_count() публичный статический Метод

Sync product rating count. Can be called statically.
Устаревший: 2.7.0
public static sync_rating_count ( integer $post_id )
$post_id integer

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

Sync variable product prices with the children lowest/highest prices.
Устаревший: 2.7.0 not used in core.
public variable_product_sync ( $product_id = '' )

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

$product_type публичное свойство

The product's type (simple, variable etc).
Устаревший: 2.7.0 get_type() method should return string instead since this prop should not be changed or be public.
public string $product_type
Результат string