Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1446866

    Hello,

    is it possible to change woocommerce sorting by price to not have the icon for ascending and descending but to have separate items in the sorting dropdown?

    Thank you

    #1446907

    Hey nebuddlho,

    Thank you for the inquiry.

    We’re not sure what you’re referring to, and we can’t find the order dropdown on the product page. Would you mind providing a screenshot of the element that you’d like to adjust and a mock of how it’s supposed to look? You can use platforms like Savvyify, Imgur or Dropbox to upload and share the screenshot. Here are the steps to follow:

    1.) Visit the website of your chosen platform, such as Savvyify, Imgur or Dropbox.
    2.) Locate the option to upload a file or an image.
    3.) Select the screenshot file from your computer or device and upload it to the platform.
    4.) After the upload is complete, you will be provided with a shareable link or an embed code.
    5.) Copy the link or code and include it in your message or response to provide us with the screenshot.

    Thank you for taking the time to share the screenshot. It will help us better understand the issue you’re facing and provide appropriate assistance.

    Best regards,
    Ismael

    #1446944

    Hello,

    the image is at https://img.savvyify.com/image/SCR-20240529-nkpt.93BcM

    Now there is Sort by price, and for asc/desc there is the arrow. I would prefer we have it without the arrows, but in the dropdown there would be
    Zoradiť podla ceny (vzostupne) – sort by price ascending
    Zoradit.. zostupne – descending

    Two items instead of one + arrows.

    #1447009

    Hi,

    Thank you for the clarification.

    Try to add this code in the functions.php file to override the sorting dropdown:

    /**
    	 * Displays a front end interface for modifying the shoplist query parameters like sorting order, product count etc
    	 *
    	 * @since < 4.0
    	 */
    	function avia_woocommerce_frontend_search_params()
    	{
    		global $avia_config;
    
    		if (!empty($avia_config['woocommerce']['disable_sorting_options'])) {
    			return;
    		}
    
    		$product_order = array();
    		$product_sort = array();
    		$params = array();
    
    		$product_order['default'] = __('Default', 'avia_framework');
    		$product_order['menu_order'] = __('Custom', 'avia_framework');
    		$product_order['title'] = __('Name', 'avia_framework');
    		$product_order['price'] = __('Price', 'avia_framework');
    		$product_order['date'] = __('Date', 'avia_framework');
    		$product_order['popularity'] = __('Popularity (sales)', 'avia_framework');
    		$product_order['rating'] = __('Average rating', 'avia_framework');
    		$product_order['relevance'] = __('Relevance', 'avia_framework');
    		$product_order['rand'] = __('Random', 'avia_framework');
    		$product_order['id'] = __('Product ID', 'avia_framework');
    
    		/**
    		 *
    		 * @since 4.5.6.2
    		 * @param array $product_order
    		 * @return array
    		 */
    		$product_order = apply_filters('avf_wc_product_order_dropdown_frontend', $product_order);
    
    		$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');
    		}
    
    		/**
    		 * ALB elements can return all elements = -1
    		 */
    		if (!empty($avia_config['woocommerce']['default_posts_per_page']) && is_numeric($avia_config['woocommerce']['default_posts_per_page'])) {
    			if ($avia_config['woocommerce']['default_posts_per_page'] > 0) {
    				$per_page = $avia_config['woocommerce']['default_posts_per_page'];
    			}
    		}
    
    		parse_str($_SERVER['QUERY_STRING'], $params);
    
    		if (!isset($params['product_order'])) {
    			$po_key = 'default';
    		} else {
    			$po_key = $params['product_order'];
    		}
    
    		if (!isset($params['product_sort'])) {
    			$ps_key = !empty($avia_config['woocommerce']['product_sort']) ? $avia_config['woocommerce']['product_sort'] : 'asc';
    		} else {
    			$ps_key = $params['product_sort'];
    		}
    
    		if ('default' == $po_key) {
    			unset($params['product_sort']);
    		}
    
    		$params['avia_extended_shop_select'] = 'yes';
    
    		//		$po_key = ! empty( $avia_config['woocommerce']['product_order'] ) ? $avia_config['woocommerce']['product_order'] : $params['product_order'];
    //		$ps_key = ! empty( $avia_config['woocommerce']['product_sort'] ) ? $avia_config['woocommerce']['product_sort'] : $params['product_sort'];
    		$pc_key = !empty($avia_config['woocommerce']['product_count']) ? $avia_config['woocommerce']['product_count'] : $per_page;
    
    		$ps_key = strtolower($ps_key);
    
    		$show_sort = !in_array($po_key, array('rand', 'popularity', 'rating', 'default'));
    
    		$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>';
    
    		foreach ($product_order as $order_key => $order_text) {
    			$query_string = 'default' == $order_key ? avia_woo_build_query_string($params, 'product_order', $order_key, 'product_sort') : avia_woo_build_query_string($params, 'product_order', $order_key);
    
    			$output .= '<li>';
    			$output .= "<a href='{$query_string}' {$nofollow}>";
    			$output .= "<span class='avia-bullet'></span>{$order_text}";
    			$output .= '</a>';
    			$output .= '</li>';
    		}
    
    		$output .= '</ul>';
    		$output .= '</li>';
    		$output .= '</ul>';
    
    		if ($show_sort) {
    			$output .= '<ul class="sort-param sort-param-sort">';
    			$output .= '<li>';
    
    			$output .= '<li' . avia_woo_active_class($ps_key, $order_key) . '>';
    			if ($ps_key == 'desc') {
    				$output .= "<li><span class='currently-selected'>" . __('Order', 'avia_framework') . " <strong>Descending</strong></span>";
    				$output .= '<ul>';
    			}
    			if ($ps_key == 'asc') {
    				$output .= "<li><span class='currently-selected'>" . __('Order', 'avia_framework') . " <strong>Ascending</strong></span>";
    				$output .= '<ul>';
    			}
    
    			foreach ($product_sort as $order_key => $order_text) {
    				$query_string = 'default' == $order_key ? avia_woo_build_query_string($params, 'product_sort', $order_key, 'product_sort') : avia_woo_build_query_string($params, 'product_sort', $order_key);
    
    				$output .= '<li>';
    				$output .= "<a href='{$query_string}' {$nofollow}>";
    				$output .= "<span class='avia-bullet'></span>{$order_text}";
    				$output .= '</a>';
    				$output .= '</li>';
    			}
    
    			$output .= '</ul>';
    			$output .= '</li>';
    
    			$output .= '</li>';
    			$output .= '</ul>';
    		}
    
    		if (!isset($avia_config['woocommerce']['default_posts_per_page']) || ($avia_config['woocommerce']['default_posts_per_page'] > 0)) {
    			$output .= "<ul class='sort-param sort-param-count'>";
    			$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 .= '</ul>';
    			$output .= '</li>';
    			$output .= '</ul>';
    		}
    
    		$output .= '</div>';
    
    		echo $output;
    	}
    

    Best regards,
    Ismael

    #1447088

    Hello,

    Thank you, this is somehow better, but what I meant was is it possible to add the ascending and descending into the first dropdown as options

    So instead of cena, there would be Cena ascending and another option cena descending

    https://img.savvyify.com/image/SCR-20240530-olov.93mUA

    #1447132

    Hi,

    Thank you for the inquiry.

    This is possible, but it will require a lot of changes to the function. By default, the product order (price, name, etc.) is separate from the product sort (asc, desc). Unfortunately, this level of customization is not covered by our support. You may need to hire a freelancer who can assist you with the customization. You can find freelancers who specialize in theme customization by visiting our customization page.

    // https://kriesi.at/contact/customization

    If you have any other questions or require further assistance, please feel free to let us know.

    Best regards,
    Ismael

    #1447188

    Ok, thank you
    Can the two li be hidden somehow so there’s no extra space at the top of the order box?

    Best regards

    • This reply was modified 4 months, 2 weeks ago by nebuddlho.
    • This reply was modified 4 months, 2 weeks ago by nebuddlho.
    #1447371

    Hi,
    Try this CSS in your Enfold Theme Options ▸ General Styling ▸ Quick CSS field:

    .sort-param.sort-param-sort > li:nth-child(-n+2) {
    	display: none;
    }

    Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
    After applying the css, please clear your browser cache and check.

    Best regards,
    Mike

    #1463070

    Ismael, there seems to be an error on line 7 of your PHP snippet…

    Snippet automatically deactivated due to an error on line 7:
    Cannot redeclare function avia_woocommerce_frontend_search_params.

    #1463131

    Hi,
    Try this code instead:

    function remove_avia_woocommerce_frontend_search_params() {
        remove_action( 'woocommerce_before_shop_loop', 'avia_woocommerce_frontend_search_params', 20 );
    }
    add_action( 'wp_loaded', 'remove_avia_woocommerce_frontend_search_params' );
    if ( ! function_exists( 'avia_woocommerce_frontend_search_params' ) ) {
        function avia_woocommerce_frontend_search_params() {
        }
    }
    
    function custom_avia_woocommerce_frontend_search_params() {
        global $avia_config;
    
        if (!empty($avia_config['woocommerce']['disable_sorting_options'])) {
            return;
        }
    
        $product_order = array();
        $product_sort = array();
        $params = array();
    
        $product_order['default'] = __('Default', 'avia_framework');
        $product_order['menu_order'] = __('Custom', 'avia_framework');
        $product_order['title'] = __('Name', 'avia_framework');
        $product_order['price'] = __('Price', 'avia_framework');
        $product_order['date'] = __('Date', 'avia_framework');
        $product_order['popularity'] = __('Popularity (sales)', 'avia_framework');
        $product_order['rating'] = __('Average rating', 'avia_framework');
        $product_order['relevance'] = __('Relevance', 'avia_framework');
        $product_order['rand'] = __('Random', 'avia_framework');
        $product_order['id'] = __('Product ID', 'avia_framework');
    
        $product_order = apply_filters('avf_wc_product_order_dropdown_frontend', $product_order);
    
        $product_sort['asc'] = __('Ascending', 'avia_framework');
        $product_sort['desc'] = __('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']) && is_numeric($avia_config['woocommerce']['default_posts_per_page'])) {
            if ($avia_config['woocommerce']['default_posts_per_page'] > 0) {
                $per_page = $avia_config['woocommerce']['default_posts_per_page'];
            }
        }
    
        parse_str($_SERVER['QUERY_STRING'], $params);
    
        if (!isset($params['product_order'])) {
            $po_key = 'default';
        } else {
            $po_key = $params['product_order'];
        }
    
        if (!isset($params['product_sort'])) {
            $ps_key = !empty($avia_config['woocommerce']['product_sort']) ? $avia_config['woocommerce']['product_sort'] : 'asc';
        } else {
            $ps_key = $params['product_sort'];
        }
    
        if ('default' == $po_key) {
            unset($params['product_sort']);
        }
    
        $params['avia_extended_shop_select'] = 'yes';
    
        $pc_key = !empty($avia_config['woocommerce']['product_count']) ? $avia_config['woocommerce']['product_count'] : $per_page;
    
        $ps_key = strtolower($ps_key);
    
        $show_sort = !in_array($po_key, array('rand', 'popularity', 'rating', 'default'));
    
        $nofollow = 'rel="nofollow"';
    
        $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>';
    
        foreach ($product_order as $order_key => $order_text) {
            $query_string = 'default' == $order_key ? avia_woo_build_query_string($params, 'product_order', $order_key, 'product_sort') : avia_woo_build_query_string($params, 'product_order', $order_key);
    
            $output .= '<li>';
            $output .= "<a href='{$query_string}' {$nofollow}>";
            $output .= "<span class='avia-bullet'></span>{$order_text}";
            $output .= '</a>';
            $output .= '</li>';
        }
    
        $output .= '</ul>';
        $output .= '</li>';
        $output .= '</ul>';
    
        if ($show_sort) {
            $output .= '<ul class="sort-param sort-param-sort">';
    
            if ($ps_key == 'desc') {
                $output .= "<li><span class='currently-selected'>" . __('Order', 'avia_framework') . " <strong>Descending</strong></span>";
                $output .= '<ul>';
            }
            if ($ps_key == 'asc') {
                $output .= "<li><span class='currently-selected'>" . __('Order', 'avia_framework') . " <strong>Ascending</strong></span>";
                $output .= '<ul>';
            }
    
            foreach ($product_sort as $order_key => $order_text) {
                $query_string = 'default' == $order_key ? avia_woo_build_query_string($params, 'product_sort', $order_key, 'product_sort') : avia_woo_build_query_string($params, 'product_sort', $order_key);
    
                $output .= '<li>';
                $output .= "<a href='{$query_string}' {$nofollow}>";
                $output .= "<span class='avia-bullet'></span>{$order_text}";
                $output .= '</a>';
                $output .= '</li>';
            }
    
            $output .= '</ul>';
            $output .= '</li>';
    
            $output .= '</li>';
            $output .= '</ul>';
        }
    
        if (!isset($avia_config['woocommerce']['default_posts_per_page']) || ($avia_config['woocommerce']['default_posts_per_page'] > 0)) {
            $output .= "<ul class='sort-param sort-param-count'>";
            $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 .= '</ul>';
            $output .= '</li>';
            $output .= '</ul>';
        }
    
        $output .= '</div>';
    
        echo $output;
    }
    add_action('woocommerce_before_shop_loop', 'custom_avia_woocommerce_frontend_search_params');
    

    Enfold Support 6409

    Best regards,
    Mike

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.