public
|
#
__construct( integer|WC_Product |WP_Post $product )
Constructor gets the post object and sets the ID for the loaded product.
Constructor gets the post object and sets the ID for the loaded product.
Parameters
- $product
integer|WC_Product |WP_Post $product Product ID, post object, or product object
|
public
boolean
|
#
__isset( mixed $key )
__isset function.
Parameters
Returns
boolean
|
public
mixed
|
#
__get( mixed $key )
__get function.
Parameters
Returns
mixed
|
public
object
|
#
get_post_data( )
Get the product's post data.
Get the product's post data.
Returns
object
|
public
array
|
|
public
string
|
#
get_permalink( )
Wrapper for get_permalink
Wrapper for get_permalink
Returns
string
|
public
string
|
#
get_sku( )
Get SKU (Stock-keeping unit) - product unique ID.
Get SKU (Stock-keeping unit) - product unique ID.
Returns
string
|
public
integer
|
#
get_stock_quantity( )
Returns number of items available for sale.
Returns number of items available for sale.
Returns
integer
|
public
integer
|
|
public
integer
|
#
set_stock( mixed $amount = null )
Set stock level of the product.
Set stock level of the product.
Parameters
- $amount
mixed $amount (default: null)
Returns
integer Stock
|
public
integer
|
#
reduce_stock( integer $by = 1 )
Reduce stock level of the product.
Reduce stock level of the product.
Parameters
- $by
integer $by (default: 1) Amount to reduce by.
Returns
integer Stock
|
public
integer
|
#
increase_stock( integer $by = 1 )
Increase stock level of the product.
Increase stock level of the product.
Parameters
- $by
integer $by (default: 1) Amount to increase by
Returns
integer Stock
|
public
|
#
set_stock_status( mixed $status )
set_stock_status function.
set_stock_status function.
|
public
boolean
|
#
is_type( mixed $type )
Checks the product type.
Backwards compat with downloadable/virtual.
Parameters
- $type
mixed $type Array or string of types
Returns
boolean
|
public
boolean
|
#
is_downloadable( )
Checks if a product is downloadable
Checks if a product is downloadable
Returns
boolean
|
public
boolean
|
#
has_file( string $download_id = '' )
Check if downloadable product has a file attached.
Check if downloadable product has a file attached.
Parameters
- $download_id
string $download_id file identifier
Returns
boolean Whether downloadable product has a file attached.
Since
1.6.2
|
public
array
|
#
get_files( )
Gets an array of downloadable files for this product.
Gets an array of downloadable files for this product.
Returns
array
Since
2.1.0
|
public
array|false
|
#
get_file( string $download_id = '' )
Get a file by $download_id
Get a file by $download_id
Parameters
- $download_id
string $download_id file identifier
Returns
array|false if not found
|
public
string
|
#
get_file_download_path( string $download_id )
Get file download path identified by $download_id
Get file download path identified by $download_id
Parameters
- $download_id
string $download_id file identifier
Returns
string
|
public
boolean
|
#
is_virtual( )
Checks if a product is virtual (has no shipping).
Checks if a product is virtual (has no shipping).
Returns
boolean
|
public
boolean
|
#
needs_shipping( )
Checks if a product needs shipping.
Checks if a product needs shipping.
Returns
boolean
|
public
boolean
|
#
is_sold_individually( )
Check if a product is sold individually (no quantities)
Check if a product is sold individually (no quantities)
Returns
boolean
|
public
array
|
|
public
boolean
|
#
has_child( )
Returns whether or not the product has any child product.
Returns whether or not the product has any child product.
Returns
boolean
|
public
boolean
|
#
exists( )
Returns whether or not the product post exists.
Returns whether or not the product post exists.
Returns
boolean
|
public
boolean
|
#
is_taxable( )
Returns whether or not the product is taxable.
Returns whether or not the product is taxable.
Returns
boolean
|
public
boolean
|
#
is_shipping_taxable( )
Returns whether or not the product shipping is taxable.
Returns whether or not the product shipping is taxable.
Returns
boolean
|
public
string
|
#
get_title( )
Get the title of the post.
Get the title of the post.
Returns
string
|
public
integer
|
#
get_parent( )
Get the parent of the post.
Get the parent of the post.
Returns
integer
|
public
string
|
#
add_to_cart_url( )
Get the add to url used mainly in loops.
Get the add to url used mainly in loops.
Returns
string
|
public
string
|
#
single_add_to_cart_text( )
Get the add to cart button text for the single page
Get the add to cart button text for the single page
Returns
string
|
public
string
|
#
add_to_cart_text( )
Get the add to cart button text
Get the add to cart button text
Returns
string
|
public
boolean
|
#
managing_stock( )
Returns whether or not the product is stock managed.
Returns whether or not the product is stock managed.
Returns
boolean
|
public
boolean
|
#
is_in_stock( )
Returns whether or not the product is in stock.
Returns whether or not the product is in stock.
Returns
boolean
|
public
boolean
|
#
backorders_allowed( )
Returns whether or not the product can be backordered.
Returns whether or not the product can be backordered.
Returns
boolean
|
public
boolean
|
#
backorders_require_notification( )
Returns whether or not the product needs to notify the customer on
backorder.
Returns whether or not the product needs to notify the customer on
backorder.
Returns
boolean
|
public
boolean
|
#
is_on_backorder( integer $qty_in_cart = 0 )
is_on_backorder function.
is_on_backorder function.
Parameters
- $qty_in_cart
integer $qty_in_cart (default: 0)
Returns
boolean
|
public
boolean
|
#
has_enough_stock( mixed $quantity )
Returns whether or not the product has enough stock for the order.
Returns whether or not the product has enough stock for the order.
Parameters
Returns
boolean
|
public
string
|
#
get_availability( )
Returns the availability of the product.
Returns the availability of the product.
Returns
string
|
public
boolean
|
#
is_featured( )
Returns whether or not the product is featured.
Returns whether or not the product is featured.
Returns
boolean
|
public
boolean
|
#
is_visible( )
Returns whether or not the product is visible.
Returns whether or not the product is visible.
Returns
boolean
|
public
boolean
|
#
is_on_sale( )
Returns whether or not the product is on sale.
Returns whether or not the product is on sale.
Returns
boolean
|
public
string
|
#
get_weight( )
Returns the product's weight.
Returns the product's weight.
Returns
string
|
public
boolean
|
#
is_purchasable( )
Returns false if the product cannot be bought.
Returns false if the product cannot be bought.
Returns
boolean
|
public
|
#
set_price( float $price )
Set a products price dynamically.
Set a products price dynamically.
Parameters
- $price
float $price Price to set.
|
public
|
#
adjust_price( mixed $price )
Adjust a products price dynamically.
Adjust a products price dynamically.
Parameters
|
public
string
|
#
get_sale_price( )
Returns the product's sale price.
Returns the product's sale price.
Returns
string price
|
public
string
|
#
get_regular_price( )
Returns the product's regular price.
Returns the product's regular price.
Returns
string price
|
public
string
|
#
get_price( )
Returns the product's active price.
Returns the product's active price.
Returns
string price
|
public
string
|
#
get_price_including_tax( string $qty = 1, mixed $price = '' )
Returns the price (including tax). Uses customer tax rates. Can work for a
specific $qty for more accurate taxes.
Returns the price (including tax). Uses customer tax rates. Can work for a
specific $qty for more accurate taxes.
Parameters
- $qty
string $price to calculdate, left blank to just use get_price()
- $price
Returns
string
|
public
string
|
#
get_price_excluding_tax( string $qty = 1, mixed $price = '' )
Returns the price (excluding tax) - ignores tax_class filters since the price
may include tax and thus needs subtracting. Uses store base tax rates.
Can work for a specific $qty for more accurate taxes.
Returns the price (excluding tax) - ignores tax_class filters since the price
may include tax and thus needs subtracting. Uses store base tax rates.
Can work for a specific $qty for more accurate taxes.
Parameters
- $qty
string $price to calculdate, left blank to just use get_price()
- $price
Returns
string
|
public
string
|
#
get_price_suffix( )
Get the suffix to display after prices > 0
Get the suffix to display after prices > 0
Returns
string
|
public
string
|
#
get_price_html( string $price = '' )
Returns the price in html format.
Returns the price in html format.
Parameters
- $price
string $price (default: '')
Returns
string
|
public
string
|
#
get_price_html_from_text( )
Functions for getting parts of a price, in html, used by get_price_html.
Functions for getting parts of a price, in html, used by get_price_html.
Returns
string
|
public
string
|
#
get_price_html_from_to( mixed $from, mixed $to )
Functions for getting parts of a price, in html, used by get_price_html.
Functions for getting parts of a price, in html, used by get_price_html.
Parameters
- $from
mixed $from String or float to wrap with 'from' text
- $to
mixed $to String or float to wrap with 'to' text
Returns
string
|
public
string
|
|
public
string
|
|
public
string
|
#
get_average_rating( )
get_average_rating function.
get_average_rating function.
Returns
string
|
public
integer
|
#
get_rating_count( )
get_rating_count function.
get_rating_count function.
Returns
integer
|
public
string
|
#
get_rating_html( string $rating = null )
Returns the product rating in html format.
Returns the product rating in html format.
Parameters
- $rating
string $rating (default: '')
Returns
string
|
public
array
|
#
get_upsells( )
Returns the upsell product ids.
Returns the upsell product ids.
Returns
array
|
public
array
|
#
get_cross_sells( )
Returns the cross sell product ids.
Returns the cross sell product ids.
Returns
array
|
public
string
|
#
get_categories( string $sep = ', ', mixed $before = '', string $after = '' )
Returns the product categories.
Returns the product categories.
Parameters
- $sep
string $sep (default: ')
- $before
mixed '
- $after
string $before (default: '')
Returns
string
|
public
array
|
#
get_tags( string $sep = ', ', string $before = '', string $after = '' )
Returns the product tags.
Returns the product tags.
Parameters
- $sep
string $sep (default: ', ')
- $before
string $before (default: '')
- $after
string $after (default: '')
Returns
array
|
public
string
|
#
get_shipping_class( )
Returns the product shipping class.
Returns the product shipping class.
Returns
string
|
public
integer
|
#
get_shipping_class_id( )
Returns the product shipping class ID.
Returns the product shipping class ID.
Returns
integer
|
public
array
|
#
get_related( integer $limit = 5 )
Get and return related products.
Get and return related products.
Parameters
- $limit
integer $limit (default: 5)
Returns
array Array of post IDs
|
public
string
|
#
get_attribute( mixed $attr )
Returns a single product attribute.
Returns a single product attribute.
Parameters
Returns
string
|
public
array
|
#
get_attributes( )
Returns product attributes.
Returns product attributes.
Returns
array
|
public
mixed
|
#
has_attributes( )
Returns whether or not the product has any attributes set.
Returns whether or not the product has any attributes set.
Returns
mixed
|
public
boolean
|
#
enable_dimensions_display( )
Returns whether or not we are showing dimensions on the product page.
Returns whether or not we are showing dimensions on the product page.
Returns
boolean
|
public
boolean
|
#
has_dimensions( )
Returns whether or not the product has dimensions set.
Returns whether or not the product has dimensions set.
Returns
boolean
|
public
boolean
|
#
has_weight( )
Returns whether or not the product has weight set.
Returns whether or not the product has weight set.
Returns
boolean
|
public
string
|
|
public
|
#
list_attributes( )
Lists a table of attributes for the product page.
Lists a table of attributes for the product page.
|
public
integer
|
#
get_image_id( )
Gets the main product image ID.
Gets the main product image ID.
Returns
integer
|
public
string
|
#
get_image( string $size = 'shop_thumbnail', mixed $attr = array() )
Returns the main product image
Returns the main product image
Parameters
- $size
string $size (default: 'shop_thumbnail')
- $attr
Returns
string
|
public
string
|
#
get_formatted_name( )
Get product name with SKU or ID. Used within admin.
Get product name with SKU or ID. Used within admin.
Returns
string Formatted product name
|