• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_product_dropdown_categories函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_product_dropdown_categories函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_product_dropdown_categories函数的具体用法?PHP wc_product_dropdown_categories怎么用?PHP wc_product_dropdown_categories使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wc_product_dropdown_categories函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: woocommerce_product_dropdown_categories

/**
 * @deprecated
 */
function woocommerce_product_dropdown_categories($args = array(), $deprecated_hierarchical = 1, $deprecated_show_uncategorized = 1, $deprecated_orderby = '')
{
    return wc_product_dropdown_categories($args, $deprecated_hierarchical, $deprecated_show_uncategorized, $deprecated_orderby);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php


示例2: product_filters

 /**
  * Show a category filter box
  */
 public function product_filters()
 {
     global $wp_query;
     // Category Filtering
     wc_product_dropdown_categories();
     // Type filtering
     $terms = get_terms('product_type');
     $output = '<select name="product_type" id="dropdown_product_type">';
     $output .= '<option value="">' . __('Show all product types', 'woocommerce') . '</option>';
     foreach ($terms as $term) {
         $output .= '<option value="' . sanitize_title($term->name) . '" ';
         if (isset($wp_query->query['product_type'])) {
             $output .= selected($term->slug, $wp_query->query['product_type'], false);
         }
         $output .= '>';
         switch ($term->name) {
             case 'grouped':
                 $output .= __('Grouped product', 'woocommerce');
                 break;
             case 'external':
                 $output .= __('External/Affiliate product', 'woocommerce');
                 break;
             case 'variable':
                 $output .= __('Variable product', 'woocommerce');
                 break;
             case 'simple':
                 $output .= __('Simple product', 'woocommerce');
                 break;
             default:
                 // Assuming that we have other types in future
                 $output .= ucfirst($term->name);
                 break;
         }
         $output .= '</option>';
         if ('simple' == $term->name) {
             $output .= '<option value="downloadable" ';
             if (isset($wp_query->query['product_type'])) {
                 $output .= selected('downloadable', $wp_query->query['product_type'], false);
             }
             $output .= '> &rarr; ' . __('Downloadable', 'woocommerce') . '</option>';
             $output .= '<option value="virtual" ';
             if (isset($wp_query->query['product_type'])) {
                 $output .= selected('virtual', $wp_query->query['product_type'], false);
             }
             $output .= '> &rarr;  ' . __('Virtual', 'woocommerce') . '</option>';
         }
     }
     $output .= '</select>';
     echo apply_filters('woocommerce_product_filters', $output);
 }
开发者ID:vkolova,项目名称:bgscena,代码行数:53,代码来源:class-wc-admin-post-types.php


示例3: widget

 /**
  * widget function.
  *
  * @see WP_Widget
  *
  * @param array $args
  * @param array $instance
  */
 public function widget($args, $instance)
 {
     global $wp_query, $post;
     $c = isset($instance['count']) ? $instance['count'] : $this->settings['count']['std'];
     $h = isset($instance['hierarchical']) ? $instance['hierarchical'] : $this->settings['hierarchical']['std'];
     $s = isset($instance['show_children_only']) ? $instance['show_children_only'] : $this->settings['show_children_only']['std'];
     $d = isset($instance['dropdown']) ? $instance['dropdown'] : $this->settings['dropdown']['std'];
     $o = isset($instance['orderby']) ? $instance['orderby'] : $this->settings['orderby']['std'];
     $dropdown_args = array('hide_empty' => false);
     $list_args = array('show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'product_cat', 'hide_empty' => false);
     // Menu Order
     $list_args['menu_order'] = false;
     if ($o == 'order') {
         $list_args['menu_order'] = 'asc';
     } else {
         $list_args['orderby'] = 'title';
     }
     // Setup Current Category
     $this->current_cat = false;
     $this->cat_ancestors = array();
     if (is_tax('product_cat')) {
         $this->current_cat = $wp_query->queried_object;
         $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat');
     } elseif (is_singular('product')) {
         $product_category = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent'));
         if ($product_category) {
             $this->current_cat = end($product_category);
             $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat');
         }
     }
     // Show Siblings and Children Only
     if ($s && $this->current_cat) {
         // Top level is needed
         $top_level = get_terms('product_cat', array('fields' => 'ids', 'parent' => 0, 'hierarchical' => true, 'hide_empty' => false));
         // Direct children are wanted
         $direct_children = get_terms('product_cat', array('fields' => 'ids', 'parent' => $this->current_cat->term_id, 'hierarchical' => true, 'hide_empty' => false));
         // Gather siblings of ancestors
         $siblings = array();
         if ($this->cat_ancestors) {
             foreach ($this->cat_ancestors as $ancestor) {
                 $ancestor_siblings = get_terms('product_cat', array('fields' => 'ids', 'parent' => $ancestor, 'hierarchical' => false, 'hide_empty' => false));
                 $siblings = array_merge($siblings, $ancestor_siblings);
             }
         }
         if ($h) {
             $include = array_merge($top_level, $this->cat_ancestors, $siblings, $direct_children, array($this->current_cat->term_id));
         } else {
             $include = array_merge($direct_children);
         }
         $dropdown_args['include'] = implode(',', $include);
         $list_args['include'] = implode(',', $include);
         if (empty($include)) {
             return;
         }
     } elseif ($s) {
         $dropdown_args['depth'] = 1;
         $dropdown_args['child_of'] = 0;
         $dropdown_args['hierarchical'] = 1;
         $list_args['depth'] = 1;
         $list_args['child_of'] = 0;
         $list_args['hierarchical'] = 1;
     }
     $this->widget_start($args, $instance);
     // Dropdown
     if ($d) {
         $dropdown_defaults = array('show_counts' => $c, 'hierarchical' => $h, 'show_uncategorized' => 0, 'orderby' => $o, 'selected' => $this->current_cat ? $this->current_cat->slug : '');
         $dropdown_args = wp_parse_args($dropdown_args, $dropdown_defaults);
         // Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258
         wc_product_dropdown_categories(apply_filters('woocommerce_product_categories_widget_dropdown_args', $dropdown_args));
         wc_enqueue_js("\n\t\t\t\tjQuery( '.dropdown_product_cat' ).change( function() {\n\t\t\t\t\tif ( jQuery(this).val() != '' ) {\n\t\t\t\t\t\tvar this_page = '';\n\t\t\t\t\t\tvar home_url  = '" . esc_js(home_url('/')) . "';\n\t\t\t\t\t\tif ( home_url.indexOf( '?' ) > 0 ) {\n\t\t\t\t\t\t\tthis_page = home_url + '&product_cat=' + jQuery(this).val();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis_page = home_url + '?product_cat=' + jQuery(this).val();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlocation.href = this_page;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t");
         // List
     } else {
         include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php';
         $list_args['walker'] = new WC_Product_Cat_List_Walker();
         $list_args['title_li'] = '';
         $list_args['pad_counts'] = 1;
         $list_args['show_option_none'] = __('No product categories exist.', 'woocommerce');
         $list_args['current_category'] = $this->current_cat ? $this->current_cat->term_id : '';
         $list_args['current_category_ancestors'] = $this->cat_ancestors;
         echo '<ul class="product-categories">';
         wp_list_categories(apply_filters('woocommerce_product_categories_widget_args', $list_args));
         echo '</ul>';
     }
     $this->widget_end($args);
 }
开发者ID:CannedHead,项目名称:feelingsurf,代码行数:93,代码来源:class-wc-widget-product-categories.php


示例4: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    public function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post, $woocommerce;
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $c = isset($instance['count']) && $instance['count'] ? '1' : '0';
        $h = $instance['hierarchical'] ? true : false;
        $s = isset($instance['show_children_only']) && $instance['show_children_only'] ? '1' : '0';
        $d = isset($instance['dropdown']) && $instance['dropdown'] ? '1' : '0';
        $o = $instance['orderby'] ? $instance['orderby'] : 'order';
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $dropdown_args = array();
        $cat_args = array('show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'product_cat');
        // Menu Order
        $cat_args['menu_order'] = false;
        if ($o == 'order') {
            $cat_args['menu_order'] = 'asc';
        } else {
            $cat_args['orderby'] = 'title';
        }
        // Setup Current Category
        $this->current_cat = false;
        $this->cat_ancestors = array();
        if (is_tax('product_cat')) {
            $this->current_cat = $wp_query->queried_object;
            $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat');
        } elseif (is_singular('product')) {
            $product_category = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent'));
            if ($product_category) {
                $this->current_cat = end($product_category);
                $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat');
            }
        }
        // Show Siblings and Children Only
        if ($s && $this->current_cat) {
            // Top level is needed
            $top_level = get_terms('product_cat', array('fields' => 'ids', 'parent' => 0, 'hierarchical' => false, 'hide_empty' => false));
            // Direct children are wanted
            $direct_children = get_terms('product_cat', array('fields' => 'ids', 'parent' => $this->current_cat->term_id, 'hierarchical' => true, 'hide_empty' => false));
            // Gather siblings of ancestors
            $siblings = array();
            if ($this->cat_ancestors) {
                foreach ($this->cat_ancestors as $ancestor) {
                    $siblings = array_merge($siblings, get_terms('product_cat', array('fields' => 'ids', 'parent' => $ancestor, 'hierarchical' => false, 'hide_empty' => false)));
                }
            }
            $include = array_merge($top_level, $this->cat_ancestors, $siblings, $direct_children, array($this->current_cat->term_id));
            $dropdown_args['include'] = implode(',', $include);
            $cat_args['include'] = implode(',', $include);
        } elseif ($s) {
            $dropdown_args['depth'] = 1;
            $dropdown_args['child_of'] = 0;
            $cat_args['depth'] = 1;
            $cat_args['child_of'] = 0;
        }
        // Dropdown
        if ($d) {
            $dropdown_defaults = array('show_counts' => $c, 'hierarchical' => $h, 'show_uncategorized' => 0, 'orderby' => $o, 'selected' => $this->current_cat ? $this->current_cat->slug : '');
            $dropdown_args = wp_parse_args($dropdown_args, $dropdown_defaults);
            // Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258
            wc_product_dropdown_categories($dropdown_args);
            ?>
			<script type='text/javascript'>
			/* <![CDATA[ */
				var product_cat_dropdown = document.getElementById("dropdown_product_cat");
				function onProductCatChange() {
					if ( product_cat_dropdown.options[product_cat_dropdown.selectedIndex].value !=='' ) {
						location.href = "<?php 
            echo home_url();
            ?>
/?product_cat="+product_cat_dropdown.options[product_cat_dropdown.selectedIndex].value;
					}
				}
				product_cat_dropdown.onchange = onProductCatChange;
			/* ]]> */
			</script>
			<?php 
            // List
        } else {
            include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php';
            $cat_args['walker'] = new WC_Product_Cat_List_Walker();
            $cat_args['title_li'] = '';
            $cat_args['pad_counts'] = 1;
            $cat_args['show_option_none'] = __('No product categories exist.', 'woocommerce');
            $cat_args['current_category'] = $this->current_cat ? $this->current_cat->term_id : '';
            $cat_args['current_category_ancestors'] = $this->cat_ancestors;
            echo '<ul class="product-categories">';
            wp_list_categories(apply_filters('woocommerce_product_categories_widget_args', $cat_args));
//.........这里部分代码省略.........
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:101,代码来源:class-wc-widget-product-categories.php


示例5: product_filters

 /**
  * Show a category filter box
  */
 public function product_filters()
 {
     global $typenow, $wp_query;
     if ($typenow != 'product') {
         return;
     }
     // Category Filtering
     wc_product_dropdown_categories();
     // Type filtering
     $terms = get_terms('product_type');
     $output = "<select name='product_type' id='dropdown_product_type'>";
     $output .= '<option value="">' . __('Show all product types', 'woocommerce') . '</option>';
     foreach ($terms as $term) {
         $output .= "<option value='" . sanitize_title($term->name) . "' ";
         if (isset($wp_query->query['product_type'])) {
             $output .= selected($term->slug, $wp_query->query['product_type'], false);
         }
         $output .= ">";
         switch ($term->name) {
             case 'grouped':
                 $output .= __('Grouped product', 'woocommerce');
                 break;
             case 'external':
                 $output .= __('External/Affiliate product', 'woocommerce');
                 break;
             case 'variable':
                 $output .= __('Variable product', 'woocommerce');
                 break;
             case 'simple':
                 $output .= __('Simple product', 'woocommerce');
                 break;
             default:
                 // Assuming that we have other types in future
                 $output .= ucfirst($term->name);
                 break;
         }
         $output .= " ({$term->count})</option>";
         if ($term->name == 'simple') {
             $output .= "<option value='downloadable' ";
             if (isset($wp_query->query['product_type'])) {
                 $output .= selected('downloadable', $wp_query->query['product_type'], false);
             }
             $output .= "> &rarr; " . __('Downloadable', 'woocommerce') . "</option>";
             $output .= "<option value='virtual' ";
             if (isset($wp_query->query['product_type'])) {
                 $output .= selected('virtual', $wp_query->query['product_type'], false);
             }
             $output .= "> &rarr;  " . __('Virtual', 'woocommerce') . "</option>";
         }
     }
     $output .= "</select>";
     echo apply_filters('woocommerce_product_filters', $output);
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:56,代码来源:class-wc-admin-cpt-product.php


示例6: shopping_searchform

    function shopping_searchform()
    {
        if (class_exists('WooCommerce')) {
            global $wpdb;
            $dropdown_args = array('show_counts' => false, 'hierarchical' => true, 'show_uncategorized' => 0);
            ?>
			<form role="search" method="get" class="searchform-categoris" action="<?php 
            echo home_url('/');
            ?>
">
	            <div class="wpo-search">
	                <div class="wpo-search-inner">
                        <div class="select-categories">
                            <?php 
            wc_product_dropdown_categories($dropdown_args);
            ?>
                        </div>
                        <div class="input-group">
                            <input name="s" id="s" maxlength="40"
                                   class="form-control input-search" type="text" size="20"
                                   placeholder="Enter search...">
                            <span class="input-group-addon">
                                <input type="submit" id="searchsubmit" class="fa" value="&#xf002;"/>
                                <input type="hidden" name="post_type" value="product"/>
                            </span>
                        </div>
	                </div>
	            </div>
	        </form>
        <?php 
        } else {
            get_search_form();
        }
    }
开发者ID:shubham79,项目名称:Jhintaak,代码行数:34,代码来源:theme.php


示例7: widget

    /**
     * widget function.
     *
     * @see WP_Widget
     * @access public
     * @param array $args
     * @param array $instance
     * @return void
     */
    public function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $c = isset($instance['count']) && $instance['count'] ? '1' : '0';
        $h = $instance['hierarchical'] ? true : false;
        $s = isset($instance['show_children_only']) && $instance['show_children_only'] ? '1' : '0';
        $d = isset($instance['dropdown']) && $instance['dropdown'] ? '1' : '0';
        $o = $instance['orderby'] ? $instance['orderby'] : 'order';
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        $cat_args = array('show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'product_cat');
        $cat_args['menu_order'] = false;
        if ($o == 'order') {
            $cat_args['menu_order'] = 'asc';
        } else {
            $cat_args['orderby'] = 'title';
        }
        if ($d) {
            // Stuck with this until a fix for http://core.trac.wordpress.org/ticket/13258
            wc_product_dropdown_categories(array('show_counts' => $c, 'hierarchical' => $h, 'show_uncategorized' => 0, 'orderby' => $o));
            ?>
			<script type='text/javascript'>
			/* <![CDATA[ */
				var product_cat_dropdown = document.getElementById("dropdown_product_cat");
				function onProductCatChange() {
					if ( product_cat_dropdown.options[product_cat_dropdown.selectedIndex].value !=='' ) {
						location.href = "<?php 
            echo home_url();
            ?>
/?product_cat="+product_cat_dropdown.options[product_cat_dropdown.selectedIndex].value;
					}
				}
				product_cat_dropdown.onchange = onProductCatChange;
			/* ]]> */
			</script>
			<?php 
        } else {
            global $wp_query, $post, $woocommerce;
            $this->current_cat = false;
            $this->cat_ancestors = array();
            if (is_tax('product_cat')) {
                $this->current_cat = $wp_query->queried_object;
                $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat');
            } elseif (is_singular('product')) {
                $product_category = wc_get_product_terms($post->ID, 'product_cat', array('orderby' => 'parent'));
                if ($product_category) {
                    $this->current_cat = end($product_category);
                    $this->cat_ancestors = get_ancestors($this->current_cat->term_id, 'product_cat');
                }
            }
            include_once WC()->plugin_path() . '/includes/walkers/class-product-cat-list-walker.php';
            $cat_args['walker'] = new WC_Product_Cat_List_Walker();
            $cat_args['title_li'] = '';
            $cat_args['show_children_only'] = isset($instance['show_children_only']) && $instance['show_children_only'] ? 1 : 0;
            $cat_args['pad_counts'] = 1;
            $cat_args['show_option_none'] = __('No product categories exist.', 'woocommerce');
            $cat_args['current_category'] = $this->current_cat ? $this->current_cat->term_id : '';
            $cat_args['current_category_ancestors'] = $this->cat_ancestors;
            echo '<ul class="product-categories">';
            wp_list_categories(apply_filters('woocommerce_product_categories_widget_args', $cat_args));
            echo '</ul>';
        }
        echo $after_widget;
    }
开发者ID:hoonio,项目名称:PhoneAfrika,代码行数:76,代码来源:class-wc-widget-product-categories.php


示例8: categories_searchform

    function categories_searchform()
    {
        if (class_exists('WooCommerce')) {
            global $wpdb;
            $dropdown_args = array('show_counts' => false, 'hierarchical' => true, 'show_uncategorized' => 0);
            ?>
		<form role="search" method="get" class="input-group search-category" action="<?php 
            echo esc_url(home_url('/'));
            ?>
">
            <div class="input-group-addon search-category-container">
            	<label class="select">
            		<?php 
            wc_product_dropdown_categories($dropdown_args);
            ?>
            	</label>
            </div>
            <input name="s" id="s" maxlength="60" class="form-control search-category-input" type="text" size="20" placeholder="Enter search...">
            <div class="input-group-btn">
                <label class="btn btn-link btn-search">
                  <span id="wpo-title-search" class="title-search hidden"><?php 
            _e('Search', TEXTDOMAIN);
            ?>
</span>
                  <input type="submit" id="searchsubmit" class="fa searchsubmit" value="&#xf002;"/>
                </label>
                <input type="hidden" name="post_type" value="product"/>
            </div>
        </form>
        <?php 
        } else {
            get_search_form();
        }
    }
开发者ID:jimmitjoo,项目名称:mnh,代码行数:34,代码来源:theme.php



注:本文中的wc_product_dropdown_categories函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_product_has_unique_sku函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_product_dimensions_enabled函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap