PHP Class WC_Product_External

External products cannot be bought; they link offsite. Extends simple 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 external product data into the parent object.
add_to_cart_text ( ) : string Get the add to cart button text.
add_to_cart_url ( ) : string Get the add to url used mainly in loops.
get_button_text ( string $context = 'view' ) : string Get button text.
get_product_url ( string $context = 'view' ) : string Get product url.
get_type ( ) : string Get internal type.
is_purchasable ( ) : boolean Returns false if the product cannot be bought.
set_backorders ( string $backorders ) xternal products cannot be backordered.
set_button_text ( string $button_text ) Set button text.
set_manage_stock ( $manage_stock ) External products cannot be stock managed.
set_product_url ( string $product_url ) Set product URL.
set_stock_status ( $stock_status = '' ) External products cannot be stock managed.
single_add_to_cart_text ( ) : string Get the add to cart button text for the single page.

Protected Methods

Method Description
read_product_data ( ) Read post data.
update_post_meta ( ) Helper method that updates all the post meta for an external product.

Method Details

__construct() public method

Merges external 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

add_to_cart_url() public method

Get the add to url used mainly in loops.
public add_to_cart_url ( ) : string
return string

get_button_text() public method

Get button text.
public get_button_text ( string $context = 'view' ) : string
$context string
return string

get_product_url() public method

Get product url.
public get_product_url ( string $context = 'view' ) : string
$context string
return string

get_type() public method

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

is_purchasable() public method

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

read_product_data() protected method

Read post data.
Since: 2.7.0
protected read_product_data ( )

set_backorders() public method

xternal products cannot be backordered.
Since: 2.7.0
public set_backorders ( string $backorders )
$backorders string Options: 'yes', 'no' or 'notify'.

set_button_text() public method

Set button text.
Since: 2.7.0
public set_button_text ( string $button_text )
$button_text string Button text.

set_manage_stock() public method

External products cannot be stock managed.
Since: 2.7.0
public set_manage_stock ( $manage_stock )

set_product_url() public method

Set product URL.
Since: 2.7.0
public set_product_url ( string $product_url )
$product_url string Product URL.

set_stock_status() public method

External products cannot be stock managed.
Since: 2.7.0
public set_stock_status ( $stock_status = '' )

single_add_to_cart_text() public method

Get the add to cart button text for the single page.
public single_add_to_cart_text ( ) : string
return string

update_post_meta() protected method

Helper method that updates all the post meta for an external product.
Since: 2.7.0
protected update_post_meta ( )

Property Details

$extra_data protected property

Stores product data.
protected array $extra_data
return array