php Enfold主题 - WooCommerce - 查看所有产品
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Enfold主题 - WooCommerce - 查看所有产品相关的知识,希望对你有一定的参考价值。
<?php
/**
* displays a front end interface for modifying the shoplist query parameters like sorting order, product count etc
*/
if(!function_exists('avia_woocommerce_frontend_search_params')) {
add_action( 'woocommerce_before_shop_loop', 'avia_woocommerce_frontend_search_params', 20);
function avia_woocommerce_frontend_search_params()
{
global $avia_config;
if(!empty($avia_config['woocommerce']['disable_sorting_options'])) return false;
$product_order['default'] = __("Default Order",'avia_framework');
$product_order['title'] = __("Name",'avia_framework');
$product_order['price'] = __("Price",'avia_framework');
$product_order['date'] = __("Date",'avia_framework');
$product_order['popularity'] = __("Popularity",'avia_framework');
$product_sort['asc'] = __("Click to order products ascending", 'avia_framework');
$product_sort['desc'] = __("Click to order products descending", 'avia_framework');
$per_page_string = __("Products per page",'avia_framework');
$per_page = get_option('avia_woocommerce_product_count');
if(!$per_page) $per_page = get_option('posts_per_page');
if(!empty($avia_config['woocommerce']['default_posts_per_page'])) $per_page = $avia_config['woocommerce']['default_posts_per_page'];
parse_str($_SERVER['QUERY_STRING'], $params);
$po_key = !empty($avia_config['woocommerce']['product_order']) ? $avia_config['woocommerce']['product_order'] : 'default';
$ps_key = !empty($avia_config['woocommerce']['product_sort']) ? $avia_config['woocommerce']['product_sort'] : 'asc';
$pc_key = !empty($avia_config['woocommerce']['product_count']) ? $avia_config['woocommerce']['product_count'] : $per_page;
$ps_key = strtolower($ps_key);
$nofollow = 'rel="nofollow"';
//generate markup
$output = "";
$output .= "<div class='product-sorting'>";
$output .= " <ul class='sort-param sort-param-order'>";
$output .= " <li><span class='currently-selected'>".__("Sort by",'avia_framework')." <strong>".$product_order[$po_key]."</strong></span>";
$output .= " <ul>";
$output .= " <li".avia_woo_active_class($po_key, 'default')."><a href='".avia_woo_build_query_string($params, 'product_order', 'default')."' {$nofollow}> <span class='avia-bullet'></span>".$product_order['default']."</a></li>";
$output .= " <li".avia_woo_active_class($po_key, 'title')."><a href='".avia_woo_build_query_string($params, 'product_order', 'title')."' {$nofollow}> <span class='avia-bullet'></span>".$product_order['title']."</a></li>";
$output .= " <li".avia_woo_active_class($po_key, 'price')."><a href='".avia_woo_build_query_string($params, 'product_order', 'price')."' {$nofollow}> <span class='avia-bullet'></span>".$product_order['price']."</a></li>";
$output .= " <li".avia_woo_active_class($po_key, 'date')."><a href='".avia_woo_build_query_string($params, 'product_order', 'date')."' {$nofollow}> <span class='avia-bullet'></span>".$product_order['date']."</a></li>";
$output .= " <li".avia_woo_active_class($po_key, 'popularity')."><a href='".avia_woo_build_query_string($params, 'product_order', 'popularity')."' {$nofollow}> <span class='avia-bullet'></span>".$product_order['popularity']."</a></li>";
$output .= " </ul>";
$output .= " </li>";
$output .= " </ul>";
$output .= " <ul class='sort-param sort-param-sort'>";
$output .= " <li>";
if($ps_key == 'desc') $output .= " <a title='".$product_sort['asc']."' class='sort-param-asc' href='".avia_woo_build_query_string($params, 'product_sort', 'asc')."' {$nofollow}>".$product_sort['desc']."</a>";
if($ps_key == 'asc') $output .= " <a title='".$product_sort['desc']."' class='sort-param-desc' href='".avia_woo_build_query_string($params, 'product_sort', 'desc')."' {$nofollow}>".$product_sort['asc']."</a>";
$output .= " </li>";
$output .= " </ul>";
$output .= " <ul class='sort-param sort-param-count'>";
if( $pc_key == -1 ) {
$output .= " <li><span class='currently-selected'>".__("Display",'avia_framework')." <strong>Alle produkter</strong></span>";
} else {
$output .= " <li><span class='currently-selected'>".__("Display",'avia_framework')." <strong>".$pc_key." ".$per_page_string."</strong></span>";
}
$output .= " <ul>";
$output .= " <li".avia_woo_active_class($pc_key, $per_page)."> <a href='".avia_woo_build_query_string($params, 'product_count', $per_page)."' {$nofollow}> <span class='avia-bullet'></span>".$per_page." ".$per_page_string."</a></li>";
$output .= " <li".avia_woo_active_class($pc_key, $per_page*2)."><a href='".avia_woo_build_query_string($params, 'product_count', $per_page * 2)."' {$nofollow}> <span class='avia-bullet'></span>".($per_page * 2)." ".$per_page_string."</a></li>";
$output .= " <li".avia_woo_active_class($pc_key, $per_page*3)."><a href='".avia_woo_build_query_string($params, 'product_count', $per_page * 3)."' {$nofollow}> <span class='avia-bullet'></span>".($per_page * 3)." ".$per_page_string."</a></li>";
$output .= " <li".avia_woo_active_class($pc_key, -1)."><a href='".avia_woo_build_query_string($params, 'product_count', -1)."' {$nofollow}> <span class='avia-bullet'></span> Alle produkter</a></li>";
$output .= " </ul>";
$output .= " </li>";
$output .= " </ul>";
$output .= "</div>";
echo $output;
}
}
以上是关于php Enfold主题 - WooCommerce - 查看所有产品的主要内容,如果未能解决你的问题,请参考以下文章