Свойство | Type | Description | |
---|---|---|---|
$cache_group | string | Cache group. | |
$data | array | Stores product data. | |
$post_type | string | Post type. | |
$supports | array | Supported features such as 'ajax_add_to_cart'. |
Méthode | 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. |
Méthode | Description | |
---|---|---|
get_hook_prefix ( ) : string | Prefix for action and filter hooks on data. | |
sanitize_term_ids ( array $terms, string $taxonomy ) | Get term ids from either a list of names, ids, or terms. |
public __construct ( integer | WC_Product | object $product ) | ||
$product | integer | WC_Product | object | Product to init. |
public add_to_cart_text ( ) : string | ||
Résultat | string |
public add_to_cart_url ( ) : string | ||
Résultat | string |
public backorders_allowed ( ) : boolean | ||
Résultat | boolean |
public backorders_require_notification ( ) : boolean | ||
Résultat | boolean |
public child_has_dimensions ( ) : boolean | ||
Résultat | boolean |
public child_has_weight ( ) : boolean | ||
Résultat | boolean |
public get_attribute ( string $attribute ) : string | ||
$attribute | string | to get. |
Résultat | string |
public get_attributes ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_average_rating ( string $context = 'view' ) : float | ||
$context | string | |
Résultat | float |
public get_backorders ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string | yes no or notify |
public get_catalog_visibility ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_category_ids ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_children ( ) : array | ||
Résultat | array | of IDs |
public get_cross_sell_ids ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_date_created ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string | Timestamp. |
public get_date_modified ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string | Timestamp. |
public get_date_on_sale_from ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_date_on_sale_to ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_default_attributes ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_description ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_dimensions ( $formatted = true ) : string | array | ||
$formatted | True by default for legacy support - will be false/not set in future versions to return the array only. Use wc_format_dimensions for formatted versions instead. | |
Résultat | string | array |
public get_download_expiry ( string $context = 'view' ) : integer | ||
$context | string | |
Résultat | integer |
public get_download_limit ( string $context = 'view' ) : integer | ||
$context | string | |
Résultat | integer |
public get_downloadable ( string $context = 'view' ) : boolean | ||
$context | string | |
Résultat | boolean |
public get_downloads ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_featured ( string $context = 'view' ) : boolean | ||
$context | string | |
Résultat | boolean |
public get_file_download_path ( string $download_id ) : string | ||
$download_id | string | file identifier |
Résultat | string |
public get_formatted_name ( ) : string | ||
Résultat | string | Formatted product name |
public get_gallery_image_ids ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_height ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
protected get_hook_prefix ( ) : string | ||
Résultat | string |
public get_image_id ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_length ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_manage_stock ( string $context = 'view' ) : boolean | ||
$context | string | |
Résultat | boolean |
public get_parent_id ( string $context = 'view' ) : integer | ||
$context | string | |
Résultat | integer |
public get_price_html ( $deprecated = '' ) : string | ||
Résultat | string |
public get_purchase_note ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_rating_count ( integer $value = null ) : integer | ||
$value | integer | Optional. Rating value to get the count for. By default returns the count of all rating values. |
Résultat | integer |
public get_rating_counts ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array | of counts |
public get_regular_price ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string | price |
public get_review_count ( string $context = 'view' ) : integer | ||
$context | string | |
Résultat | integer |
public get_reviews_allowed ( string $context = 'view' ) : boolean | ||
$context | string | |
Résultat | boolean |
public get_sale_price ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string | price |
public get_shipping_class ( ) : string | ||
Résultat | string |
public get_shipping_class_id ( string $context = 'view' ) : integer | ||
$context | string | |
Résultat | integer |
public get_short_description ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_sold_individually ( string $context = 'view' ) : boolean | ||
$context | string | |
Résultat | boolean |
public get_status ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_stock_managed_by_id ( ) : integer | ||
Résultat | integer |
public get_stock_status ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_tag_ids ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_tax_class ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_tax_status ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public get_total_sales ( string $context = 'view' ) : integer | ||
$context | string | |
Résultat | integer |
public get_upsell_ids ( string $context = 'view' ) : array | ||
$context | string | |
Résultat | array |
public get_virtual ( string $context = 'view' ) : boolean | ||
$context | string | |
Résultat | boolean |
public get_weight ( string $context = 'view' ) : string | ||
$context | string | |
Résultat | string |
public has_attributes ( ) : boolean | ||
Résultat | boolean |
public has_dimensions ( ) : boolean | ||
Résultat | boolean |
public has_enough_stock ( mixed $quantity ) : boolean | ||
$quantity | mixed | |
Résultat | boolean |
public has_weight ( ) : boolean | ||
Résultat | boolean |
public is_downloadable ( ) : boolean | ||
Résultat | boolean |
public is_featured ( ) : boolean | ||
Résultat | boolean |
public is_in_stock ( ) : boolean | ||
Résultat | boolean |
public is_on_backorder ( integer $qty_in_cart ) : boolean | ||
$qty_in_cart | integer | (default: 0) |
Résultat | boolean |
public is_on_sale ( ) : boolean | ||
Résultat | boolean |
public is_purchasable ( ) : boolean | ||
Résultat | boolean |
public is_shipping_taxable ( ) : boolean | ||
Résultat | boolean |
public is_sold_individually ( ) : boolean | ||
Résultat | boolean |
public is_taxable ( ) : boolean | ||
Résultat | boolean |
public is_virtual ( ) : boolean | ||
Résultat | boolean |
public is_visible ( ) : boolean | ||
Résultat | boolean |
public managing_stock ( ) : boolean | ||
Résultat | boolean |
public needs_shipping ( ) : boolean | ||
Résultat | boolean |
protected sanitize_term_ids ( array $terms, string $taxonomy ) | ||
$terms | array | |
$taxonomy | string |
public save ( ) |
public set_attributes ( array $raw_attributes ) | ||
$raw_attributes | array | Array of WC_Product_Attribute objects. |
public set_average_rating ( float $average ) | ||
$average | float |
public set_backorders ( string $backorders ) | ||
$backorders | string | Options: 'yes', 'no' or 'notify'. |
public set_catalog_visibility ( string $visibility ) | ||
$visibility | string | Options: 'hidden', 'visible', 'search' and 'catalog'. |
public set_category_ids ( array $term_ids ) | ||
$term_ids | array | List of terms IDs. |
public set_cross_sell_ids ( array $cross_sell_ids ) | ||
$cross_sell_ids | array | IDs from the cross-sell products. |
public set_date_created ( string $timestamp ) | ||
$timestamp | string | Timestamp. |
public set_date_modified ( string $timestamp ) | ||
$timestamp | string | Timestamp. |
public set_date_on_sale_from ( string $timestamp ) | ||
$timestamp | string | Sale from date. |
public set_date_on_sale_to ( string $timestamp ) | ||
$timestamp | string | Sale to date. |
public set_default_attributes ( array $default_attributes ) | ||
$default_attributes | array | List of default attributes. |
public set_description ( string $description ) | ||
$description | string | Product description. |
public set_download_expiry ( integer $download_expiry ) | ||
$download_expiry | integer |
public set_download_limit ( integer $download_limit ) | ||
$download_limit | integer |
public set_downloadable ( $downloadable ) |
public set_downloads ( $downloads_array ) | ||
$downloads_array | array of WC_Product_Download objects or arrays. |
public set_gallery_image_ids ( array $image_ids ) | ||
$image_ids | array |
public set_height ( float | string $height ) | ||
$height | float | string | Total height. |
public set_image_id ( integer $image_id = '' ) | ||
$image_id | integer |
public set_length ( float | string $length ) | ||
$length | float | string | Total length. |
public set_manage_stock ( $manage_stock ) |
public set_parent_id ( integer $parent_id ) | ||
$parent_id | integer | Product parent ID. |
public set_purchase_note ( string $purchase_note ) | ||
$purchase_note | string | Purchase note. |
public set_rating_counts ( array $counts ) | ||
$counts | array |
public set_regular_price ( string $price ) | ||
$price | string | Regular price. |
public set_review_count ( integer $count ) | ||
$count | integer |
public set_reviews_allowed ( boolean $reviews_allowed ) | ||
$reviews_allowed | boolean | Reviews allowed or not. |
public set_sale_price ( string $price ) | ||
$price | string | sale price. |
public set_short_description ( string $short_description ) | ||
$short_description | string | Product short description. |
public set_sold_individually ( $sold_individually ) |
public set_status ( string $status ) | ||
$status | string | Product status. |
public set_stock_quantity ( float | null $quantity ) | ||
$quantity | float | null | Stock quantity. |
public set_stock_status ( string $status = '' ) | ||
$status | string | New status. |
public set_tag_ids ( array $term_ids ) | ||
$term_ids | array | List of terms IDs. |
public set_tax_class ( string $class ) | ||
$class | string | Tax class. |
public set_tax_status ( string $status ) | ||
$status | string | Tax status. |
public set_total_sales ( integer $total ) | ||
$total | integer | Total of sales. |
public set_upsell_ids ( array $upsell_ids ) | ||
$upsell_ids | array | IDs from the up-sell products. |
public set_weight ( float | string $weight ) | ||
$weight | float | string | Total weight. |
public single_add_to_cart_text ( ) : string | ||
Résultat | string |
public validate_props ( ) |
protected array $supports | ||
Résultat | array |