PHP 클래스 WC_Product_Variable

The WooCommerce product class handles individual product data.
저자: WooThemes
상속: extends WC_Product
파일 보기 프로젝트 열기: woocommerce/woocommerce 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$extra_data array Stores product data.

공개 메소드들

메소드 설명
__construct ( integer | WC_Product | object $product ) Merges variable product data into the parent object.
add_to_cart_text ( ) : string Get the add to cart button text.
child_has_dimensions ( ) : boolean Does a child have dimensions set?
child_has_weight ( ) : boolean Does a child have a weight set?
child_is_in_stock ( ) : boolean Is a child in stock?
get_available_variation ( WC_Product $variation ) : array Returns an array of data for a variation. Used in the add to cart form.
get_available_variations ( ) : array Get an array of available variations for the current product.
get_children ( string $context = 'view' ) : array Return a products child ids.
get_downloadable ( $context = 'view' ) Variable products themselves cannot be downloadable.
get_price_html ( string $price = '' ) : string Returns the price in html format.
get_type ( ) : string Get internal type.
get_variation_attributes ( string $context = 'view' ) : array Return an array of attributes used for variations, as well as their possible values.
get_variation_default_attribute ( string $attribute_name ) : string If set, get the default attributes for a variable product.
get_variation_price ( string $min_or_max = 'min', boolean $include_taxes = false ) : string Get the min or max variation (active) price.
get_variation_prices ( string $context = 'view' ) : array() Get an array of all sale and regular prices from all variations. This is used for example when displaying the price range at variable product level or seeing if the variable product is on sale.
get_variation_prices_including_taxes ( string $context = 'view' ) : array() Get an array of all sale and regular prices from all variations, includes taxes.
get_variation_regular_price ( string $min_or_max = 'min', boolean $include_taxes = false ) : string Get the min or max variation regular price.
get_variation_sale_price ( string $min_or_max = 'min', boolean $include_taxes = false ) : string Get the min or max variation sale price.
get_virtual ( $context = 'view' ) Variable products themselves cannot be virtual.
get_visible_children ( string $context = 'view' ) : array Return a products child ids - visible only.
has_dimensions ( ) : boolean Returns whether or not the product has dimensions set.
has_weight ( ) : boolean Returns whether or not the product has weight set.
is_on_sale ( ) : boolean Returns whether or not the product is on sale.
save ( ) Save data (either create or update depending on if we are working on an existing product).
set_children ( $children ) Sets an array of children for the product.
set_variation_attributes ( $variation_attributes ) Sets an array of variation attributes
set_variation_prices ( $variation_prices ) Sets an array of variation prices.
set_variation_prices_including_taxes ( $variation_prices_including_taxes ) Sets an array of variation prices, including taxes.
set_visible_children ( $visible_children ) Sets an array of visible children only.
sync ( WC_Product | integer $product, boolean $save = true ) : WC_Product Sync a variable product with it's children. These sync functions sync upwards (from child to parent) when the variation is saved.
sync_stock_status ( WC_Product | integer $product, boolean $save = true ) : WC_Product Sync parent stock status with the status of all children and save.
validate_props ( ) Ensure properties are set correctly before save.

메소드 상세

__construct() 공개 메소드

Merges variable 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() 공개 메소드

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

child_has_dimensions() 공개 메소드

Does a child have dimensions set?
public child_has_dimensions ( ) : boolean
리턴 boolean

child_has_weight() 공개 메소드

Does a child have a weight set?
public child_has_weight ( ) : boolean
리턴 boolean

child_is_in_stock() 공개 메소드

Is a child in stock?
public child_is_in_stock ( ) : boolean
리턴 boolean

get_available_variation() 공개 메소드

Returns an array of data for a variation. Used in the add to cart form.
부터: 2.4.0
public get_available_variation ( WC_Product $variation ) : array
$variation WC_Product Variation product object or ID
리턴 array

get_available_variations() 공개 메소드

Get an array of available variations for the current product.
public get_available_variations ( ) : array
리턴 array

get_children() 공개 메소드

Return a products child ids.
public get_children ( string $context = 'view' ) : array
$context string
리턴 array Children ids

get_downloadable() 공개 메소드

Variable products themselves cannot be downloadable.
public get_downloadable ( $context = 'view' )

get_price_html() 공개 메소드

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

get_type() 공개 메소드

Get internal type.
public get_type ( ) : string
리턴 string

get_variation_attributes() 공개 메소드

Return an array of attributes used for variations, as well as their possible values.
public get_variation_attributes ( string $context = 'view' ) : array
$context string
리턴 array Attributes and their available values

get_variation_default_attribute() 공개 메소드

If set, get the default attributes for a variable product.
public get_variation_default_attribute ( string $attribute_name ) : string
$attribute_name string
리턴 string

get_variation_price() 공개 메소드

Get the min or max variation (active) price.
public get_variation_price ( string $min_or_max = 'min', boolean $include_taxes = false ) : string
$min_or_max string Min or max price.
$include_taxes boolean Should the price include taxes?
리턴 string

get_variation_prices() 공개 메소드

Get an array of all sale and regular prices from all variations. This is used for example when displaying the price range at variable product level or seeing if the variable product is on sale.
public get_variation_prices ( string $context = 'view' ) : array()
$context string
리턴 array()

get_variation_prices_including_taxes() 공개 메소드

Get an array of all sale and regular prices from all variations, includes taxes.
부터: 2.7.0
public get_variation_prices_including_taxes ( string $context = 'view' ) : array()
$context string
리턴 array()

get_variation_regular_price() 공개 메소드

Get the min or max variation regular price.
public get_variation_regular_price ( string $min_or_max = 'min', boolean $include_taxes = false ) : string
$min_or_max string Min or max price.
$include_taxes boolean Should the price include taxes?
리턴 string

get_variation_sale_price() 공개 메소드

Get the min or max variation sale price.
public get_variation_sale_price ( string $min_or_max = 'min', boolean $include_taxes = false ) : string
$min_or_max string Min or max price.
$include_taxes boolean Should the price include taxes?
리턴 string

get_virtual() 공개 메소드

Variable products themselves cannot be virtual.
public get_virtual ( $context = 'view' )

get_visible_children() 공개 메소드

Return a products child ids - visible only.
부터: 2.7.0
public get_visible_children ( string $context = 'view' ) : array
$context string
리턴 array Children ids

has_dimensions() 공개 메소드

Returns whether or not the product has dimensions set.
public has_dimensions ( ) : boolean
리턴 boolean

has_weight() 공개 메소드

Returns whether or not the product has weight set.
public has_weight ( ) : boolean
리턴 boolean

is_on_sale() 공개 메소드

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

save() 공개 메소드

Save data (either create or update depending on if we are working on an existing product).
부터: 2.7.0
public save ( )

set_children() 공개 메소드

Sets an array of children for the product.
부터: 2.7.0
public set_children ( $children )

set_variation_attributes() 공개 메소드

Sets an array of variation attributes
부터: 2.7.0
public set_variation_attributes ( $variation_attributes )

set_variation_prices() 공개 메소드

Sets an array of variation prices.
부터: 2.7.0
public set_variation_prices ( $variation_prices )

set_variation_prices_including_taxes() 공개 메소드

Sets an array of variation prices, including taxes.
부터: 2.7.0
public set_variation_prices_including_taxes ( $variation_prices_including_taxes )

set_visible_children() 공개 메소드

Sets an array of visible children only.
부터: 2.7.0
public set_visible_children ( $visible_children )

sync() 공개 정적인 메소드

Sync a variable 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.
리턴 WC_Product Synced product object.

sync_stock_status() 공개 정적인 메소드

Sync parent stock status with the status of all children and save.
public static sync_stock_status ( 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.
리턴 WC_Product Synced product object.

validate_props() 공개 메소드

Ensure properties are set correctly before save.
부터: 2.7.0
public validate_props ( )

프로퍼티 상세

$extra_data 보호되어 있는 프로퍼티

Stores product data.
protected array $extra_data
리턴 array