PHP Class WC_Product_Grouped

Grouped products cannot be purchased - they are wrappers for other products.
Author: WooThemes
Inheritance: extends WC_Product
Show file Open project: woocommerce/woocommerce Class Usage Examples

Protected Properties

Property Type Description
$extra_data array Stores product data.

Public Methods

Method Description
__construct ( integer | WC_Product | object $product ) Merges grouped product data into the parent object.
add_to_cart_text ( ) : string Get the add to cart button text.
get_children ( string $context = 'view' ) : array Return the children of this product.
get_price_html ( string $price = '' ) : string Returns the price in html format.
get_type ( ) : string Get internal type.
is_on_sale ( ) : boolean Returns whether or not the product is on sale.
is_purchasable ( ) : boolean Returns false if the product cannot be bought.
set_children ( array $children ) Return the children of this product.
sync ( WC_Product | integer $product, boolean $save = true ) : WC_Product Sync a grouped product with it's children. These sync functions sync upwards (from child to parent) when the variation is saved.

Method Details

__construct() public method

Merges grouped product data into the parent object.
public __construct ( integer | WC_Product | object $product )
$product integer | WC_Product | object Product to init.

add_to_cart_text() public method

Get the add to cart button text.
public add_to_cart_text ( ) : string
return string

get_children() public method

Return the children of this product.
public get_children ( string $context = 'view' ) : array
$context string
return array

get_price_html() public method

Returns the price in html format.
public get_price_html ( string $price = '' ) : string
$price string (default: '')
return string

get_type() public method

Get internal type.
public get_type ( ) : string
return string

is_on_sale() public method

Returns whether or not the product is on sale.
public is_on_sale ( ) : boolean
return boolean

is_purchasable() public method

Returns false if the product cannot be bought.
public is_purchasable ( ) : boolean
return boolean

set_children() public method

Return the children of this product.
public set_children ( array $children )
$children array

sync() public static method

Sync a grouped product with it's children. These sync functions sync upwards (from child to parent) when the variation is saved.
public static sync ( WC_Product | integer $product, boolean $save = true ) : WC_Product
$product WC_Product | integer Product object or ID for which you wish to sync.
$save boolean If true, the prouduct object will be saved to the DB before returning it.
return WC_Product Synced product object.

Property Details

$extra_data protected property

Stores product data.
protected array $extra_data
return array