تابع ووکامرسی wc_get_product دریافت اطلاعات محصول با توجه به آیدی

تابع ووکامرسی wc_get_product – دریافت اطلاعات محصول با توجه به آیدی ( اطلاعاتی شامل : عنوان ، توضیحات ، تصویر شاخص ، گالری ، لینک و دیگر اطلاعات اضافه مثل post meta )
Syntax – سینتکس
(WC_Product|null) wc_get_product( (constant) $the_product = false, (array) $deprecated = array() );
Parameters – پارامتر ها (2)
- 1- $the_product (constant)
- 2- $deprecated (array)
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_product' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php';
}
// Post object or post ID of the product.
$the_product = false;
// Previously used to pass arguments to the factory, e.g. to force a type.
$deprecated = array();
// NOTICE! Understand what this does before running.
$result = wc_get_product($the_product, $deprecated);
Defined – محل تعریف
/includes/wc-product-functions.php
function wc_get_product( $the_product = false, $deprecated = array() ) {
if ( ! did_action( 'woocommerce_init' ) ) {
wc_doing_it_wrong( __FUNCTION__, __( 'wc_get_product should not be called before the woocommerce_init action.', woocommerce ), '2.5' );
return false;
}
if ( ! empty( $deprecated ) ) {
wc_deprecated_argument( 'args', '3.0', 'Passing args to wc_get_product is deprecated. If you need to force a type, construct the product class directly.' );
}
return WC()->product_factory->get_product( $the_product, $deprecated );
}
versions – نسخه ها
از نسخه : 2.2.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر