تابع ووکامرسی wc_get_products نمایش و دریافت تمامی محصولات با توجه به آرگومان

تابع ووکامرسی wc_get_products – نمایش و دریافت تمامی محصولات با توجه به آرگومان داده شده در تابع
Syntax – سینتکس
(array|stdClass) wc_get_products( (array) $args );
Parameters – پارامتر ها (1)
- 1- $args (array)
Returns – مقادیر بازگشتی (array|stdClass)
دریافت تعداد صفحات در صورت پاس کردن paginate به مقدار true ، همچنین اطلاعات محصول
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_products' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php';
}
// Array of args (above)
$args = array();
// NOTICE! Understand what this does before running.
$result = wc_get_products($args);
Defined – محل تعریف
/includes/wc-product-functions.php
function wc_get_products( $args ) {
$args = wp_parse_args( $args, array(
'status' => array( 'draft', 'pending', 'private', 'publish' ),
'type' => array_merge( array_keys( wc_get_product_types() ) ),
'parent' => null,
'sku' => '',
'category' => array(),
'tag' => array(),
'limit' => get_option( 'posts_per_page' ),
'offset' => null,
'page' => 1,
'include' => array(),
'exclude' => array(),
'orderby' => 'date',
'order' => 'DESC',
'return' => 'objects',
'paginate' => false,
'shipping_class' => array(),
) );
// Handle some BW compatibility arg names wherewp_queryargs differ in naming.
$map_legacy = array(
'numberposts' => 'limit',
'post_status' => 'status',
'post_parent' => 'parent',
'posts_per_page' => 'limit',
'paged' => 'page',
);
foreach ( $map_legacy as $from => $to ) {
if ( isset( $args[ $from ] ) ) {
$args[ $to ] = $args[ $from ];
}
}
return WC_Data_Store::load( 'product' )->get_products( $args );
}
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر