diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php
index 397461dccba..bb0feaa3e25 100644
--- a/includes/abstracts/abstract-wc-product.php
+++ b/includes/abstracts/abstract-wc-product.php
@@ -1,4 +1,10 @@
set_prop( 'featured', wc_string_to_bool( $featured ) );
@@ -748,7 +760,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set catalog visibility.
*
* @since 3.0.0
- * @throws WC_Data_Exception
+ * @throws WC_Data_Exception Throws exception when invalid data is found.
* @param string $visibility Options: 'hidden', 'visible', 'search' and 'catalog'.
*/
public function set_catalog_visibility( $visibility ) {
@@ -783,7 +795,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set SKU.
*
* @since 3.0.0
- * @throws WC_Data_Exception
+ * @throws WC_Data_Exception Throws exception when invalid data is found.
* @param string $sku Product SKU.
*/
public function set_sku( $sku ) {
@@ -859,7 +871,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set the tax status.
*
* @since 3.0.0
- * @throws WC_Data_Exception
+ * @throws WC_Data_Exception Throws exception when invalid data is found.
* @param string $status Tax status.
*/
public function set_tax_status( $status ) {
@@ -903,7 +915,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set if product manage stock.
*
* @since 3.0.0
- * @param bool
+ * @param bool $manage_stock Whether or not manage stock is enabled.
*/
public function set_manage_stock( $manage_stock ) {
$this->set_prop( 'manage_stock', wc_string_to_bool( $manage_stock ) );
@@ -942,7 +954,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set if should be sold individually.
*
* @since 3.0.0
- * @param bool
+ * @param bool $sold_individually Whether or not product is sold individually.
*/
public function set_sold_individually( $sold_individually ) {
$this->set_prop( 'sold_individually', wc_string_to_bool( $sold_individually ) );
@@ -1073,7 +1085,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
*/
public function set_default_attributes( $default_attributes ) {
$this->set_prop( 'default_attributes',
- array_filter( (array) $default_attributes, 'wc_array_filter_default_attributes' ) );
+ array_filter( (array) $default_attributes, 'wc_array_filter_default_attributes' ) );
}
/**
@@ -1110,7 +1122,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set if the product is virtual.
*
* @since 3.0.0
- * @param bool|string
+ * @param bool|string $virtual Whether product is virtual or not.
*/
public function set_virtual( $virtual ) {
$this->set_prop( 'virtual', wc_string_to_bool( $virtual ) );
@@ -1120,7 +1132,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set shipping class ID.
*
* @since 3.0.0
- * @param int
+ * @param int $id Product shipping class id.
*/
public function set_shipping_class_id( $id ) {
$this->set_prop( 'shipping_class_id', absint( $id ) );
@@ -1130,7 +1142,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set if the product is downloadable.
*
* @since 3.0.0
- * @param bool|string
+ * @param bool|string $downloadable Whether product is downloadable or not.
*/
public function set_downloadable( $downloadable ) {
$this->set_prop( 'downloadable', wc_string_to_bool( $downloadable ) );
@@ -1140,7 +1152,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set downloads.
*
* @since 3.0.0
- * @param $downloads_array array of WC_Product_Download objects or arrays.
+ * @param array $downloads_array Array of WC_Product_Download objects or arrays.
*/
public function set_downloads( $downloads_array ) {
$downloads = array();
@@ -1160,7 +1172,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$download_object->set_previous_hash( $download['previous_hash'] );
}
- // Validate the file extension
+ // Validate the file extension.
if ( ! $download_object->is_allowed_filetype() ) {
if ( $this->get_object_read() ) {
$errors[] = sprintf( __( 'The downloadable file %1$s cannot be used as it does not have an allowed file type. Allowed types include: %2$s', 'woocommerce' ), '' . basename( $download_object->get_file() ) . '
', '' . implode( ', ', array_keys( $download_object->get_allowed_mime_types() ) ) . '
' );
@@ -1190,7 +1202,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set download limit.
*
* @since 3.0.0
- * @param int|string $download_limit
+ * @param int|string $download_limit Product download limit.
*/
public function set_download_limit( $download_limit ) {
$this->set_prop( 'download_limit', -1 === (int) $download_limit || '' === $download_limit ? -1 : absint( $download_limit ) );
@@ -1200,7 +1212,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set download expiry.
*
* @since 3.0.0
- * @param int|string $download_limit
+ * @param int|string $download_expiry Product download expiry.
*/
public function set_download_expiry( $download_expiry ) {
$this->set_prop( 'download_expiry', -1 === (int) $download_expiry || '' === $download_expiry ? -1 : absint( $download_expiry ) );
@@ -1210,7 +1222,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set gallery attachment ids.
*
* @since 3.0.0
- * @param array $image_ids
+ * @param array $image_ids List of image ids.
*/
public function set_gallery_image_ids( $image_ids ) {
$image_ids = wp_parse_id_list( $image_ids );
@@ -1226,7 +1238,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
* Set main image ID.
*
* @since 3.0.0
- * @param int $image_id
+ * @param int|string $image_id Product image id.
*/
public function set_image_id( $image_id = '' ) {
$this->set_prop( 'image_id', $image_id );
@@ -1234,7 +1246,8 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Set rating counts. Read only.
- * @param array $counts
+ *
+ * @param array $counts Product rating counts.
*/
public function set_rating_counts( $counts ) {
$this->set_prop( 'rating_counts', array_filter( array_map( 'absint', (array) $counts ) ) );
@@ -1242,7 +1255,8 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Set average rating. Read only.
- * @param float $average
+ *
+ * @param float $average Product average rating.
*/
public function set_average_rating( $average ) {
$this->set_prop( 'average_rating', wc_format_decimal( $average ) );
@@ -1250,7 +1264,8 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Set review count. Read only.
- * @param int $count
+ *
+ * @param int $count Product review count.
*/
public function set_review_count( $count ) {
$this->set_prop( 'review_count', absint( $count ) );
@@ -1264,6 +1279,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Ensure properties are set correctly before save.
+ *
* @since 3.0.0
*/
public function validate_props() {
@@ -1272,11 +1288,11 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$this->set_stock_quantity( '' );
$this->set_backorders( 'no' );
- // If we are stock managing and we don't have stock, force out of stock status.
+ // If we are stock managing and we don't have stock, force out of stock status.
} elseif ( $this->get_stock_quantity() <= get_option( 'woocommerce_notify_no_stock_amount' ) && 'no' === $this->get_backorders() ) {
$this->set_stock_status( 'outofstock' );
- // If the stock level is changing and we do now have enough, force in stock status.
+ // If the stock level is changing and we do now have enough, force in stock status.
} elseif ( $this->get_stock_quantity() > get_option( 'woocommerce_notify_no_stock_amount' ) && array_key_exists( 'stock_quantity', $this->get_changes() ) ) {
$this->set_stock_status( 'instock' );
}
@@ -1340,7 +1356,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
*
* Backwards compatibility with downloadable/virtual.
*
- * @param string|array $type Array or string of types
+ * @param string|array $type Array or string of types.
* @return bool
*/
public function is_type( $type ) {
@@ -1521,7 +1537,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Check if a product is on backorder.
*
- * @param int $qty_in_cart (default: 0)
+ * @param int $qty_in_cart (default: 0).
* @return bool
*/
public function is_on_backorder( $qty_in_cart = 0 ) {
@@ -1531,7 +1547,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Returns whether or not the product has enough stock for the order.
*
- * @param mixed $quantity
+ * @param mixed $quantity Quantity of a product added to an order.
* @return bool
*/
public function has_enough_stock( $quantity ) {
@@ -1586,7 +1602,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
*
* @since 1.6.2
*
- * @param string $download_id file identifier
+ * @param string $download_id file identifier.
* @return bool Whether downloadable product has a file attached.
*/
public function has_file( $download_id = '' ) {
@@ -1621,6 +1637,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Product permalink.
+ *
* @return string
*/
public function get_permalink() {
@@ -1638,6 +1655,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* If the stock level comes from another product ID, this should be modified.
+ *
* @since 3.0.0
* @return int
*/
@@ -1648,7 +1666,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Returns the price in html format.
*
- * @param string $deprecated
+ * @param string $deprecated Deprecated param.
*
* @return string
*/
@@ -1728,9 +1746,9 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Returns the main product image.
*
- * @param string $size (default: 'shop_thumbnail')
- * @param array $attr
- * @param bool $placeholder True to return $placeholder if no image is found, or false to return an empty string.
+ * @param string $size (default: 'shop_thumbnail').
+ * @param array $attr Image attributes.
+ * @param bool $placeholder True to return $placeholder if no image is found, or false to return an empty string.
* @return string
*/
public function get_image( $size = 'shop_thumbnail', $attr = array(), $placeholder = true ) {
@@ -1764,6 +1782,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Returns a single product attribute as a string.
+ *
* @param string $attribute to get.
* @return string
*/
@@ -1783,6 +1802,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Get the total amount (COUNT) of ratings, or just the count for one rating e.g. number of 5 star ratings.
+ *
* @param int $value Optional. Rating value to get the count for. By default returns the count of all rating values.
* @return int
*/
@@ -1801,14 +1821,14 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Get a file by $download_id.
*
- * @param string $download_id file identifier
+ * @param string $download_id file identifier.
* @return array|false if not found
*/
public function get_file( $download_id = '' ) {
$files = $this->get_downloads();
if ( '' === $download_id ) {
- $file = sizeof( $files ) ? current( $files ) : false;
+ $file = count( $files ) ? current( $files ) : false;
} elseif ( isset( $files[ $download_id ] ) ) {
$file = $files[ $download_id ];
} else {
@@ -1821,22 +1841,22 @@ class WC_Product extends WC_Abstract_Legacy_Product {
/**
* Get file download path identified by $download_id.
*
- * @param string $download_id file identifier
+ * @param string $download_id file identifier.
* @return string
*/
public function get_file_download_path( $download_id ) {
$files = $this->get_downloads();
$file_path = isset( $files[ $download_id ] ) ? $files[ $download_id ]->get_file() : '';
- // allow overriding based on the particular file being requested
+ // allow overriding based on the particular file being requested.
return apply_filters( 'woocommerce_product_file_download_path', $file_path, $this, $download_id );
}
/**
* Get the suffix to display after prices > 0.
*
- * @param string $price to calculate, left blank to just use get_price()
- * @param integer $qty passed on to get_price_including_tax() or get_price_excluding_tax()
+ * @param string $price to calculate, left blank to just use get_price().
+ * @param integer $qty passed on to get_price_including_tax() or get_price_excluding_tax().
* @return string
*/
public function get_price_suffix( $price = '', $qty = 1 ) {
diff --git a/includes/class-wc-product-variation.php b/includes/class-wc-product-variation.php
index 6fb77ba4fc9..4991c24bdcb 100644
--- a/includes/class-wc-product-variation.php
+++ b/includes/class-wc-product-variation.php
@@ -1,4 +1,10 @@
parent_data = $parent_data;
@@ -410,7 +421,8 @@ class WC_Product_Variation extends WC_Product_Simple {
/**
* Set attributes. Unlike the parent product which uses terms, variations are assigned
* specific attributes using name value pairs.
- * @param array $raw_attributes
+ *
+ * @param array $raw_attributes array of raw attributes.
*/
public function set_attributes( $raw_attributes ) {
$raw_attributes = (array) $raw_attributes;