PHP Класс WC_Product_Variation

The WooCommerce product variation class handles product variation data.
Автор: WooThemes
Наследование: extends WC_Product
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$post_type string Post type.

Защищенные свойства (Protected)

Свойство Тип Описание
$parent_data array Parent data.

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

Метод Описание
add_to_cart_url ( ) : string Get the add to url used mainly in loops.
get_attributes ( string $context = 'view' ) : array Returns array of attribute name value pairs. Keys are prefixed with attribute_, as stored.
get_backorders ( string $context = 'view' ) : string Get backorders.
get_height ( string $context = 'view' ) : string Returns the product height.
get_image_id ( string $context = 'view' ) : string Get main image ID.
get_length ( string $context = 'view' ) : string Returns the product length.
get_manage_stock ( string $context = 'view' ) : boolean | string Return if product manage stock.
get_permalink ( $item_object = null ) : string Wrapper for get_permalink. Adds this variations attributes to the URL.
get_sku ( string $context = 'view' ) : string Get SKU (Stock-keeping unit) - product unique ID.
get_stock_managed_by_id ( ) : integer If the stock level comes from another product ID.
get_stock_quantity ( string $context = 'view' ) : integer | null Returns number of items available for sale.
get_tax_class ( string $context = 'view' ) : string Returns the tax class.
get_title ( ) : string Get the product's title. For variations this is the parent product name.
get_type ( ) : string Get internal type.
get_variation_attributes ( ) : array Get variation attribute values. Keys are prefixed with attribute_, as stored.
get_weight ( string $context = 'view' ) : string Returns the product's weight.
get_width ( string $context = 'view' ) : string Returns the product width.
is_purchasable ( ) : boolean Returns false if the product cannot be bought.
set_attributes ( array $raw_attributes ) Set attributes. Unlike the parent product which uses terms, variations are assigned specific attributes using name value pairs.
set_parent_data ( $parent_data ) Set the parent data array for this variation.
variation_is_active ( ) : boolean Controls whether this particular variation will appear greyed-out (inactive) or not (active).
variation_is_visible ( ) : boolean Checks if this particular variation is visible. Invisible variations are enabled and can be selected, but no price / stock info is displayed.

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

Метод Описание
get_hook_prefix ( ) : string Prefix for action and filter hooks on data.

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

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

Get the add to url used mainly in loops.
public add_to_cart_url ( ) : string
Результат string

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

Returns array of attribute name value pairs. Keys are prefixed with attribute_, as stored.
public get_attributes ( string $context = 'view' ) : array
$context string
Результат array

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

Get backorders.
С версии: 2.7.0
public get_backorders ( string $context = 'view' ) : string
$context string
Результат string yes no or notify

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

Returns the product height.
public get_height ( string $context = 'view' ) : string
$context string
Результат string

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

Prefix for action and filter hooks on data.
С версии: 2.7.0
protected get_hook_prefix ( ) : string
Результат string

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

Get main image ID.
С версии: 2.7.0
public get_image_id ( string $context = 'view' ) : string
$context string
Результат string

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

Returns the product length.
public get_length ( string $context = 'view' ) : string
$context string
Результат string

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

Return if product manage stock.
С версии: 2.7.0
public get_manage_stock ( string $context = 'view' ) : boolean | string
$context string
Результат boolean | string true, false, or parent.

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

Get SKU (Stock-keeping unit) - product unique ID.
public get_sku ( string $context = 'view' ) : string
$context string
Результат string

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

If the stock level comes from another product ID.
С версии: 2.7.0
public get_stock_managed_by_id ( ) : integer
Результат integer

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

Returns number of items available for sale.
public get_stock_quantity ( string $context = 'view' ) : integer | null
$context string
Результат integer | null

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

Returns the tax class.
public get_tax_class ( string $context = 'view' ) : string
$context string
Результат string

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

Get the product's title. For variations this is the parent product name.
public get_title ( ) : string
Результат string

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

Get internal type.
public get_type ( ) : string
Результат string

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

Get variation attribute values. Keys are prefixed with attribute_, as stored.
public get_variation_attributes ( ) : array
Результат array of attributes and their values for this variation

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

Returns the product's weight.
public get_weight ( string $context = 'view' ) : string
$context string
Результат string

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

Returns the product width.
public get_width ( string $context = 'view' ) : string
$context string
Результат string

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

Override abstract method so that: i) Disabled variations are not be purchasable by admins. ii) Enabled variations are not purchasable if the parent product is not purchasable.
public is_purchasable ( ) : boolean
Результат boolean

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

Set attributes. Unlike the parent product which uses terms, variations are assigned specific attributes using name value pairs.
public set_attributes ( array $raw_attributes )
$raw_attributes array

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

Set the parent data array for this variation.
С версии: 2.7.0
public set_parent_data ( $parent_data )

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

Used by extensions to make incompatible variations appear greyed-out, etc. Other possible uses: prevent out-of-stock variations from being selected.
public variation_is_active ( ) : boolean
Результат boolean

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

Instead, a suitable 'unavailable' message is displayed. Invisible by default: Disabled variations and variations with an empty price.
public variation_is_visible ( ) : boolean
Результат boolean

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

$parent_data защищенное свойство

Parent data.
protected array $parent_data
Результат array

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

Post type.
public string $post_type
Результат string