Method |
Description |
|
__construct ( integer | WC_Product | object $product ) |
Get the product if ID is passed, otherwise the product is new and empty. |
|
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. |
|
backorders_allowed ( ) : boolean |
Returns whether or not the product can be backordered. |
|
backorders_require_notification ( ) : boolean |
Returns whether or not the product needs to notify the customer on backorder. |
|
child_has_dimensions ( ) : boolean |
Does a child have dimensions? |
|
child_has_weight ( ) : boolean |
Does a child have a weight? |
|
exists ( ) : boolean |
Returns whether or not the product post exists. |
|
get_attribute ( string $attribute ) : string |
Returns a single product attribute as a string. |
|
get_attributes ( string $context = 'view' ) : array |
Returns product attributes. |
|
get_average_rating ( string $context = 'view' ) : float |
Get average rating. |
|
get_backorders ( string $context = 'view' ) : string |
Get backorders. |
|
get_catalog_visibility ( string $context = 'view' ) : string |
Get catalog visibility. |
|
get_category_ids ( string $context = 'view' ) : array |
Get category ids. |
|
get_children ( ) : array |
Returns the children IDs if applicable. Overridden by child classes. |
|
get_cross_sell_ids ( string $context = 'view' ) : array |
Get cross sell IDs. |
|
get_data ( ) : array |
Get all class data in array format. |
|
get_date_created ( string $context = 'view' ) : string |
Get product created date. |
|
get_date_modified ( string $context = 'view' ) : string |
Get product modified date. |
|
get_date_on_sale_from ( string $context = 'view' ) : string |
Get date on sale from. |
|
get_date_on_sale_to ( string $context = 'view' ) : string |
Get date on sale to. |
|
get_default_attributes ( string $context = 'view' ) : array |
Get default attributes. |
|
get_description ( string $context = 'view' ) : string |
Get product description. |
|
get_dimensions ( $formatted = true ) : string | array |
Returns formatted dimensions. |
|
get_download_expiry ( string $context = 'view' ) : integer |
Get download expiry. |
|
get_download_limit ( string $context = 'view' ) : integer |
Get download limit. |
|
get_downloadable ( string $context = 'view' ) : boolean |
Get downloadable. |
|
get_downloads ( string $context = 'view' ) : array |
Get downloads. |
|
get_featured ( string $context = 'view' ) : boolean |
If the product is featured. |
|
get_file ( string $download_id = '' ) : array | false |
Get a file by $download_id. |
|
get_file_download_path ( string $download_id ) : string |
Get file download path identified by $download_id. |
|
get_formatted_name ( ) : string |
Get product name with SKU or ID. Used within admin. |
|
get_gallery_image_ids ( string $context = 'view' ) : array |
Returns the gallery attachment ids. |
|
get_height ( string $context = 'view' ) : string |
Returns the product height. |
|
get_image ( string $size = 'shop_thumbnail', array $attr = [], $placeholder = true ) : string |
Returns the main product image. |
|
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 |
Return if product manage stock. |
|
get_menu_order ( string $context = 'view' ) : integer |
Get menu order. |
|
get_name ( string $context = 'view' ) : string |
Get product name. |
|
get_parent_id ( string $context = 'view' ) : integer |
Get parent ID. |
|
get_permalink ( ) : string |
Product permalink. |
|
get_price ( string $context = 'view' ) : string |
Returns the product's active price. |
|
get_price_html ( $deprecated = '' ) : string |
Returns the price in html format. |
|
get_purchase_note ( string $context = 'view' ) : string |
Get purchase note. |
|
get_rating_count ( integer $value = null ) : integer |
Get the total amount (COUNT) of ratings, or just the count for one rating e.g. number of 5 star ratings. |
|
get_rating_counts ( string $context = 'view' ) : array |
Get rating count. |
|
get_regular_price ( string $context = 'view' ) : string |
Returns the product's regular price. |
|
get_review_count ( string $context = 'view' ) : integer |
Get review count. |
|
get_reviews_allowed ( string $context = 'view' ) : boolean |
Return if reviews is allowed. |
|
get_sale_price ( string $context = 'view' ) : string |
Returns the product's sale price. |
|
get_shipping_class ( ) : string |
Returns the product shipping class SLUG. |
|
get_shipping_class_id ( string $context = 'view' ) : integer |
Get shipping class ID. |
|
get_short_description ( string $context = 'view' ) : string |
Get product short description. |
|
get_sku ( string $context = 'view' ) : string |
Get SKU (Stock-keeping unit) - product unique ID. |
|
get_slug ( string $context = 'view' ) : string |
Get product slug. |
|
get_sold_individually ( string $context = 'view' ) : boolean |
Return if should be sold individually. |
|
get_status ( string $context = 'view' ) : string |
Get product status. |
|
get_stock_managed_by_id ( ) : integer |
If the stock level comes from another product ID, this should be modified. |
|
get_stock_quantity ( string $context = 'view' ) : integer | null |
Returns number of items available for sale. |
|
get_stock_status ( string $context = 'view' ) : string |
Return the stock status. |
|
get_tag_ids ( string $context = 'view' ) : array |
Get tag ids. |
|
get_tax_class ( string $context = 'view' ) : string |
Returns the tax class. |
|
get_tax_status ( string $context = 'view' ) : string |
Returns the tax status. |
|
get_title ( ) : string |
Get the product's title. For products this is the product name. |
|
get_total_sales ( string $context = 'view' ) : integer |
Get number total of sales. |
|
get_type ( ) : string |
Get internal type. Should return string and *should be overridden* by child classes. |
|
get_upsell_ids ( string $context = 'view' ) : array |
Get upsel IDs. |
|
get_virtual ( string $context = 'view' ) : boolean |
Get virtual. |
|
get_weight ( string $context = 'view' ) : string |
Returns the product's weight. |
|
get_width ( string $context = 'view' ) : string |
Returns the product width. |
|
has_attributes ( ) : boolean |
Returns whether or not the product has any visible attributes. |
|
has_child ( ) : boolean |
Returns whether or not the product has any child product. |
|
has_dimensions ( ) : boolean |
Returns whether or not the product has dimensions set. |
|
has_enough_stock ( mixed $quantity ) : boolean |
Returns whether or not the product has enough stock for the order. |
|
has_file ( string $download_id = '' ) : boolean |
Check if downloadable product has a file attached. |
|
has_weight ( ) : boolean |
Returns whether or not the product has weight set. |
|
is_downloadable ( ) : boolean |
Checks if a product is downloadable. |
|
is_featured ( ) : boolean |
Returns whether or not the product is featured. |
|
is_in_stock ( ) : boolean |
Returns whether or not the product is in stock. |
|
is_on_backorder ( integer $qty_in_cart ) : boolean |
Check if a product is on backorder. |
|
is_on_sale ( ) : boolean |
Returns whether or not the product is on sale. |
|
is_purchasable ( ) : boolean |
Returns false if the product cannot be bought. |
|
is_shipping_taxable ( ) : boolean |
Returns whether or not the product shipping is taxable. |
|
is_sold_individually ( ) : boolean |
Check if a product is sold individually (no quantities). |
|
is_taxable ( ) : boolean |
Returns whether or not the product is taxable. |
|
is_type ( string $type ) : boolean |
Checks the product type. |
|
is_virtual ( ) : boolean |
Checks if a product is virtual (has no shipping). |
|
is_visible ( ) : boolean |
Returns whether or not the product is visible in the catalog. |
|
managing_stock ( ) : boolean |
Returns whether or not the product is stock managed. |
|
needs_shipping ( ) : boolean |
Checks if a product needs shipping. |
|
save ( ) |
Save data (either create or update depending on if we are working on an existing product). |
|
set_attributes ( array $raw_attributes ) |
Set product attributes. |
|
set_average_rating ( float $average ) |
Set average rating. Read only. |
|
set_backorders ( string $backorders ) |
Set backorders. |
|
set_catalog_visibility ( string $visibility ) |
Set catalog visibility. |
|
set_category_ids ( array $term_ids ) |
Set the product categories. |
|
set_cross_sell_ids ( array $cross_sell_ids ) |
Set crosssell IDs. |
|
set_date_created ( string $timestamp ) |
Set product created date. |
|
set_date_modified ( string $timestamp ) |
Set product modified date. |
|
set_date_on_sale_from ( string $timestamp ) |
Set date on sale from. |
|
set_date_on_sale_to ( string $timestamp ) |
Set date on sale to. |
|
set_default_attributes ( array $default_attributes ) |
Set default attributes. |
|
set_description ( string $description ) |
Set product description. |
|
set_download_expiry ( integer $download_expiry ) |
Set download expiry. |
|
set_download_limit ( integer $download_limit ) |
Set download limit. |
|
set_downloadable ( $downloadable ) |
Set if the product is downloadable. |
|
set_downloads ( $downloads_array ) |
Set downloads. |
|
set_featured ( $featured ) |
Set if the product is featured. |
|
set_gallery_image_ids ( array $image_ids ) |
Set gallery attachment ids. |
|
set_height ( float | string $height ) |
Set the product height. |
|
set_image_id ( integer $image_id = '' ) |
Set main image ID. |
|
set_length ( float | string $length ) |
Set the product length. |
|
set_manage_stock ( $manage_stock ) |
Set if product manage stock. |
|
set_menu_order ( integer $menu_order ) |
Set menu order. |
|
set_name ( string $name ) |
Set product name. |
|
set_parent_id ( integer $parent_id ) |
Set parent ID. |
|
set_price ( string $price ) |
Set the product's active price. |
|
set_purchase_note ( string $purchase_note ) |
Set purchase note. |
|
set_rating_counts ( array $counts ) |
Set rating counts. Read only. |
|
set_regular_price ( string $price ) |
Set the product's regular price. |
|
set_review_count ( integer $count ) |
Set review count. Read only. |
|
set_reviews_allowed ( boolean $reviews_allowed ) |
Set if reviews is allowed. |
|
set_sale_price ( string $price ) |
Set the product's sale price. |
|
set_shipping_class_id ( $id ) |
Set shipping class ID. |
|
set_short_description ( string $short_description ) |
Set product short description. |
|
set_sku ( string $sku ) |
Set SKU. |
|
set_slug ( string $slug ) |
Set product slug. |
|
set_sold_individually ( $sold_individually ) |
Set if should be sold individually. |
|
set_status ( string $status ) |
Set product status. |
|
set_stock_quantity ( float | null $quantity ) |
Set number of items available for sale. |
|
set_stock_status ( string $status = '' ) |
Set stock status. |
|
set_tag_ids ( array $term_ids ) |
Set the product tags. |
|
set_tax_class ( string $class ) |
Set the tax class. |
|
set_tax_status ( string $status ) |
Set the tax status. |
|
set_total_sales ( integer $total ) |
Set number total of sales. |
|
set_upsell_ids ( array $upsell_ids ) |
Set upsell IDs. |
|
set_virtual ( $virtual ) |
Set if the product is virtual. |
|
set_weight ( float | string $weight ) |
Set the product's weight. |
|
set_width ( float | string $width ) |
Set the product width. |
|
single_add_to_cart_text ( ) : string |
Get the add to cart button text for the single page. |
|
supports ( string $feature ) : boolean |
Check if a product supports a given feature. |
|
validate_props ( ) |
Ensure properties are set correctly before save. |
|