Woocommerce技術文章系列,會記錄許多開發工程師在用的東西,會慢慢隨著時間補充唷!此篇是關於Woocommerce商品技術系列的程式唷!
Woocommerce商品技術文章
If you would like to get an object of product, you can use function wc_get_product( $product_id )
$product = wc_get_product( $product_id )
About Product Information |Woocommerce商品資訊取得
Then you can operate $product
to get information about this product.
- Get product name:$product->get_title() & $product->get_name() are same. But get_title() could be filter by hook woocommerce_product_title.
- Get product slug:$product->get_slug()
- Get product type:$product->get_type(), return simple, variable, grouped or external. Or any value from others extension plugins for product type.
- Get product created date:$product->get_date_created(), return WC_DateTime Object.
- Get product modified date:$product->get_date_modified(), return WC_DateTime Object.
- Get product status:$product->get_staus().
- Get product featured:$product->get_featured(), return boolean.
- Get product visibility:$product->get_catalog_visibility().
- Get product content:$product->get_description().
- Get product excerpt:$product->get_short_description().
- Get product sku:$product->get_sku().
- Get product final price:$product->get_price() will return number and this price is final price, means if product is on sale then return sale price.
- Get product regular price:$product->get_regular_price().
- Get product on sale price:$product->get_sale_price().
- Get product on sale start date:$product->get_date_on_sale_from(), return WC_DateTime Object.
- Get product on sale end date:$product->get_date_on_sale_to(), return WC_DateTime Object.
- Get product total sold:$product->get_total_sales(), return total sold of this product from orders.
- Get product tax status:$product->get_tax_status().
- Get product tax class:$product->get_tax_class().
- Get product stock manage status:$product->get_manage_stock(), return boolean.
- Get product stock quantity:$product->get_stock_quantity(), return number or null.
- Get product stock status:$product->get_stock_status(), return on_stock or out_of_stock.
- Get product backorders status:$product->get_backorders(), return yes or no. If product can be purchase when out of stock, then yes.
- Get product low stock amount:$product->get_low_stock_amount().
- Get product sold individually:$product->get_sold_individually(), return boolean.
- Get product size of weight:$product->get_weight().
- Get product size of width:$product->get_width().
- Get product size of length:$product->get_length().
- Get product size of height:$product->get_height().
- Get product dimensions:$product->get_dimensions(), return string or array.
- Get product upsell products:$product->get_upsell_ids().
- Get product cross sell products:$product->get_cross_sell_ids().
- Get product parent id:$product->get_parent_id(), return number if this product is variation.
- Get product reviews status:$product->get_reviews_allowed(), return bool.
- Get product purchase note:$product->get_purchase_note().
- Get product attributes:$product->get_attributes(), return Array of WC_Product_Attribute.
- Get product default attributes:$product->get_default_attributes(), return Array of WC_Product_Attribute.
- Get product sort number:$product->get_menu_order().
- Get product password:$product->get_post_password().
- Get product categories:$product->get_category_ids().
- Get product tags:$product->get_tag_ids().
- Get product virtual:$product->get_virtual(), return bool.
- Get product gallery images:$product->get_gallery_image_ids().
- Get product featured image:$product->get_image_id().
- Get product shipping class:$product->get_shipping_class_id().
- Get product how many downloads:$product->get_downloads().
- Get product download expiry date:$product->get_download_expiry(), return timestamp.
- Get product downloadable status:$product->get_downloadable(), return bool.
- Get product download limit:$product->get_download_limit().
- Get product rating counts:$product->get_rating_counts().
- Get product average rating:$product->get_average_rating().
- Get product review count:$product->get_review_count().
偷偷說…
本網站 Woocommerce技術文章系列,是來自 創意數位科技團隊 的小小筆記…