Class WC_Product_Variable

Variable Product Class

The WooCommerce product class handles individual product data.

WC_Product
Extended by WC_Product_Variable
Package: WooCommerce\Classes\Products
Category: Class
Author: WooThemes
Version: 2.0.0
Class: WC_Product_Variable
Located at includes/class-wc-product-variable.php

Methods summary

public
# __construct( mixed $product )

__construct function.

__construct function.

Parameters

$product
mixed
$product

Overrides

WC_Product::__construct
public string
# add_to_cart_text( )

Get the add to cart button text

Get the add to cart button text

Returns

string

Overrides

WC_Product::add_to_cart_text
public integer
# get_total_stock( )

Get total stock.

Get total stock.

This is the stock of parent and children combined.

Returns

integer

Overrides

WC_Product::get_total_stock
public integer
# set_stock( mixed $amount = null, string $mode = 'set' )

Set stock level of the product.

Set stock level of the product.

Parameters

$amount
mixed
$amount (default: null)
$mode
string
$mode can be set, add, or subtract

Returns

integer
Stock

Overrides

WC_Product::set_stock
public array
# get_children( boolean $visible_only = false )

Return the products children posts.

Return the products children posts.

Parameters

$visible_only
boolean
$visible_only Only return variations which are not hidden

Returns

array
of children ids

Overrides

WC_Product::get_children
public object
# get_child( mixed $child_id )

get_child function.

get_child function.

Parameters

$child_id
mixed
$child_id

Returns

object
WC_Product or WC_Product_variation
public boolean
# has_child( )

Returns whether or not the product has any child product.

Returns whether or not the product has any child product.

Returns

boolean

Overrides

WC_Product::has_child
public boolean
# is_on_sale( )

Returns whether or not the product is on sale.

Returns whether or not the product is on sale.

Returns

boolean

Overrides

WC_Product::is_on_sale
public string
# get_variation_regular_price( string $min_or_max = 'min', boolean $display = false )

Get the min or max variation regular price.

Get the min or max variation regular price.

Parameters

$min_or_max
string
$min_or_max - min or max
$display
boolean
$display Whether the value is going to be displayed

Returns

string
public string
# get_variation_sale_price( string $min_or_max = 'min', boolean $display = false )

Get the min or max variation sale price.

Get the min or max variation sale price.

Parameters

$min_or_max
string
$min_or_max - min or max
$display
boolean
$display Whether the value is going to be displayed

Returns

string
public string
# get_variation_price( string $min_or_max = 'min', boolean $display = false )

Get the min or max variation (active) price.

Get the min or max variation (active) price.

Parameters

$min_or_max
string
$min_or_max - min or max
$display
boolean
$display Whether the value is going to be displayed

Returns

string
public string
# get_price_html( string $price = '' )

Returns the price in html format.

Returns the price in html format.

Parameters

$price
string
$price (default: '')

Returns

string

Overrides

WC_Product::get_price_html
public array
# get_variation_attributes( )

Return an array of attributes used for variations, as well as their possible values.

Return an array of attributes used for variations, as well as their possible values.

Returns

array
of attributes and their available values
public array
# get_variation_default_attributes( )

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

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

Returns

array
public array
# get_available_variations( )

Get an array of available variations for the current product.

Get an array of available variations for the current product.

Returns

array
public
# variable_product_sync( mixed $product_id = '' )

Sync variable product prices with the children lowest/highest prices.

Sync variable product prices with the children lowest/highest prices.

public static
# sync( mixed $product_id )

Sync the variable product with it's children

Sync the variable product with it's children

Methods inherited from WC_Product

__get(), __isset(), add_to_cart_url(), adjust_price(), backorders_allowed(), backorders_require_notification(), enable_dimensions_display(), exists(), get_attribute(), get_attributes(), get_availability(), get_average_rating(), get_categories(), get_cross_sells(), get_dimensions(), get_file(), get_file_download_path(), get_files(), get_formatted_name(), get_gallery_attachment_ids(), get_image(), get_image_id(), get_parent(), get_permalink(), get_post_data(), get_price(), get_price_excluding_tax(), get_price_html_from_text(), get_price_html_from_to(), get_price_including_tax(), get_price_suffix(), get_rating_count(), get_rating_html(), get_regular_price(), get_related(), get_sale_price(), get_shipping_class(), get_shipping_class_id(), get_sku(), get_stock_quantity(), get_tags(), get_tax_class(), get_tax_status(), get_title(), get_upsells(), get_weight(), has_attributes(), has_dimensions(), has_enough_stock(), has_file(), has_weight(), increase_stock(), is_downloadable(), is_featured(), is_in_stock(), is_on_backorder(), is_purchasable(), is_shipping_taxable(), is_sold_individually(), is_taxable(), is_type(), is_virtual(), is_visible(), list_attributes(), managing_stock(), needs_shipping(), reduce_stock(), set_price(), set_stock_status(), single_add_to_cart_text()

Magic methods summary

Properties summary

public mixed $children
#

Public

array Array of child products/posts/variations.
public mixed $total_stock
#

Public

string The product's total stock, including that of its children.

Properties inherited from WC_Product

$id, $post, $product_type

WooCommerce API documentation generated by ApiGen 2.8.0