wc_product_dropdown_categories نمایش دسته بندی محصولات به صورت dropdown

تابع ووکامرسی wc_product_dropdown_categories – نمایش دسته بندی محصولات به صورت dropdown
Syntax – سینتکس
(string) wc_product_dropdown_categories( (array) $args = array(), (int) $deprecated_hierarchical = 1, (int) $deprecated_show_uncategorized = 1, (string) $deprecated_orderby = '' );
Parameters – پارامتر ها (4)
- 1- $args (array)
- 2- $deprecated_hierarchical (int)
- 3- $deprecated_show_uncategorized (int)
- 4- $deprecated_orderby (string)
Usage – نحوه استفاده
if ( !function_exists( 'wc_product_dropdown_categories' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-term-functions.php';
}
// (default: 1)
$args = array();
// The deprecated hierarchical.
$deprecated_hierarchical = 1;
// The deprecated show uncategorized.
$deprecated_show_uncategorized = 1;
// The deprecated orderby.
$deprecated_orderby = '';
// NOTICE! Understand what this does before running.
$result = wc_product_dropdown_categories($args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby);
Defined – محل تعریف
/includes/wc-term-functions.php
function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '' ) {
global $wp_query;
if ( ! is_array( $args ) ) {
wc_deprecated_argument( 'wc_product_dropdown_categories()', '2.1', 'show_counts, hierarchical, show_uncategorized and orderby arguments are invalid - pass a single array of values instead.' );
$args['show_count'] = $args;
$args['hierarchical'] = $deprecated_hierarchical;
$args['show_uncategorized'] = $deprecated_show_uncategorized;
$args['orderby'] = $deprecated_orderby;
}
$current_product_cat = isset( $wp_query->query_vars['product_cat'] ) ? $wp_query->query_vars['product_cat'] : '';
$defaults = array(
'pad_counts' => 1,
'show_count' => 1,
'hierarchical' => 1,
'hide_empty' => 1,
'show_uncategorized' => 1,
'orderby' => 'name',
'selected' => $current_product_cat,
'menu_order' => false,
);
$args = wp_parse_args( $args, $defaults );
if ( 'order' === $args['orderby'] ) {
$args['menu_order'] = 'asc';
$args['orderby'] = 'name';
}
$terms = get_terms( 'product_cat', apply_filters( 'wc_product_dropdown_categories_get_terms_args', $args ) );
if ( empty( $terms ) ) {
return;
}
$output = "";
echo $output;
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر