PHP Class 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.
Author: WooThemes
Inheritance: extends WC_Data
Afficher le fichier Open project: woocommerce/woocommerce Class Usage Examples

Méthodes publiques

Свойство Type Description
$product_type string The product's type (simple, variable etc).

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Method Details

__get() public méthode

Magic __get method for backwards compatibility. Maps legacy vars to new getters.
public __get ( string $key ) : mixed
$key string Key name.
Résultat mixed

__isset() public méthode

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.
Résultat boolean

adjust_price() public méthode

Adjust a products price dynamically.
Deprecation: 2.7.0
public adjust_price ( mixed $price )
$price mixed

check_stock_status() public méthode

Check if the stock status needs changing.
Deprecation: 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() public méthode

Returns whether or not we are showing dimensions on the product page.
Deprecation: 2.7.0 Unused.
public enable_dimensions_display ( ) : boolean
Résultat boolean

get_availability() public méthode

Returns the availability of the product.
Deprecation: 2.7.0
public get_availability ( ) : string
Résultat string

get_availability_class() protected méthode

Get availability classname based on stock status.
Deprecation: 2.7.0
protected get_availability_class ( ) : string
Résultat string

get_availability_text() protected méthode

Get availability text based on stock status.
Deprecation: 2.7.0
protected get_availability_text ( ) : string
Résultat string

get_categories() public méthode

Returns the product categories.
Deprecation: 2.7.0
public get_categories ( string $sep = ', ', string $before = '', string $after = '' ) : string
$sep string (default: ', ').
$before string (default: '').
$after string (default: '').
Résultat string

get_child() public méthode

Returns the child product.
Deprecation: 2.7.0 Use wc_get_product instead.
public get_child ( mixed $child_id ) : WC_Product | WC_Product_variation
$child_id mixed
Résultat WC_Product | WC_Product_variation

get_cross_sells() public méthode

Returns the cross sell product ids.
Deprecation: 2.7.0
public get_cross_sells ( ) : array
Résultat array

get_display_price() public méthode

Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
Deprecation: 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()
Résultat string

get_files() public méthode

Same as get_downloads in CRUD.
Deprecation: 2.7.0
public get_files ( ) : array
Résultat array

get_formatted_variation_attributes() public méthode

Get formatted variation data with WC < 2.4 back compat and proper formatting of text-based attribute names.
Deprecation: 2.7.0
public get_formatted_variation_attributes ( $flat = false ) : string
Résultat string

get_matching_variation() public méthode

Match a variation to a given set of attributes using a WP_Query.
Deprecation: 2.7.0 in favour of Product data store's find_matching_product_variation.
public get_matching_variation ( $match_attributes = [] )

get_parent() public méthode

Get the parent of the post.
Deprecation: 2.7.0
public get_parent ( ) : integer
Résultat integer

get_post_data() public méthode

Get the product's post data.
Deprecation: 2.7.0
public get_post_data ( ) : WP_Post
Résultat WP_Post

get_price_excluding_tax() public méthode

Uses store base tax rates. Can work for a specific $qty for more accurate taxes.
Deprecation: 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()
Résultat string

get_price_html_from_text() public méthode

Functions for getting parts of a price, in html, used by get_price_html.
Deprecation: 2.7.0
public get_price_html_from_text ( ) : string
Résultat string

get_price_html_from_to() public méthode

Functions for getting parts of a price, in html, used by get_price_html.
Deprecation: 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
Résultat string

get_price_including_tax() public méthode

Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes.
Deprecation: 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()
Résultat string

get_price_suffix() public méthode

Get the suffix to display after prices > 0.
Deprecation: 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()
Résultat string

get_rating_html() public méthode

Returns the product rating in html format.
Deprecation: 2.7.0
public get_rating_html ( string $rating = null ) : string
$rating string (default: '')
Résultat string

get_tags() public méthode

Returns the product tags.
Deprecation: 2.7.0
public get_tags ( string $sep = ', ', string $before = '', string $after = '' ) : array
$sep string (default: ', ').
$before string (default: '').
$after string (default: '').
Résultat array

get_total_stock() public méthode

Get total stock - This is the stock of parent and children combined.
Deprecation: 2.7.0
public get_total_stock ( ) : integer
Résultat integer

get_upsells() public méthode

Returns the upsell product ids.
Deprecation: 2.7.0
public get_upsells ( ) : array
Résultat array

get_variation_default_attributes() public méthode

If set, get the default attributes for a variable product.
Deprecation: 2.7.0

get_variation_description() public méthode

Get product variation description.
Deprecation: 2.7.0
public get_variation_description ( ) : string
Résultat string

get_variation_id() public méthode

Get variation ID.
Deprecation: 2.7.0
public get_variation_id ( ) : integer
Résultat integer

grouped_product_sync() public méthode

has_all_attributes_set() public méthode

Check if all variation's attributes are set.
Deprecation: 2.7.0
public has_all_attributes_set ( ) : boolean
Résultat boolean

has_default_attributes() public méthode

Check if variable product has default attributes set.
Deprecation: 2.7.0
public has_default_attributes ( ) : boolean
Résultat boolean

increase_stock() public méthode

Increase stock level of the product.
Deprecation: 2.7.0
public increase_stock ( integer $amount = 1 ) : integer
$amount integer Amount to increase by. Default 1.
Résultat integer new stock level

list_attributes() public méthode

Lists a table of attributes for the product page.
Deprecation: 2.7.0 Use wc_display_product_attributes instead.
public list_attributes ( )

parent_is_visible() public méthode

Returns whether or not the variations parent is visible.
Deprecation: 2.7.0
public parent_is_visible ( ) : boolean
Résultat boolean

reduce_stock() public méthode

Reduce stock level of the product.
Deprecation: 2.7.0
public reduce_stock ( integer $amount = 1 ) : integer
$amount integer Amount to reduce by. Default: 1
Résultat integer new stock level

set_stock() public méthode

Set stock level of the product.
Deprecation: 2.7.0
public set_stock ( $amount = null, $mode = 'set' )

sync_attributes() public static méthode

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

sync_average_rating() public static méthode

Sync product rating. Can be called statically.
Deprecation: 2.7.0
public static sync_average_rating ( integer $post_id )
$post_id integer

sync_rating_count() public static méthode

Sync product rating count. Can be called statically.
Deprecation: 2.7.0
public static sync_rating_count ( integer $post_id )
$post_id integer

variable_product_sync() public méthode

Sync variable product prices with the children lowest/highest prices.
Deprecation: 2.7.0 not used in core.
public variable_product_sync ( $product_id = '' )

Property Details

$product_type public_oe property

The product's type (simple, variable etc).
Deprecation: 2.7.0 get_type() method should return string instead since this prop should not be changed or be public.
public string $product_type
Résultat string