There is a demo online store in which there is a filter for sorting goods sidebar enter image description here Now the sorting of goods works alphabetically (in the forward and reverse direction) and the price in the drop-down list in one direction. I strive to make the price be implemented exactly the same way as the alphabet using a link, not a drop-down list (as can be seen in the picture and website), but unlike the list the link is not &orderby=price How can this be corrected? I give the code:

 $product_order = array(); $product_order['menu_order'] = "Default"; $product_order['price'] = "Price"; $product_order_key = !empty($params['orderby']) ? $params['orderby'] : 'menu_order'; $product_sort_key = !empty($params['product_sort']) ? $params['product_sort'] : 'ASC'; $product_sort_key = strtolower($product_sort_key); ?> <div class="sort-param sort-param-order"> <div class="custom-select"> <div class="select-title"><?php echo $product_order[$product_order_key] ?></div> <ul class="select-list"></ul> <select name="param-count"> <option data-href="menu_order" selected value="menu_order"> <?php echo $product_order['menu_order'] ?> </option> <option data-href="price" value="price"> <?php echo $product_order['price'] ?> </option> </select> </div><!--/ .custom-select--> </div> <div class="order-param-button"> <a title="<?php esc_html_e('Click to order products', MAD_BASE_TEXTDOMAIN) ?>" data-href="price" data-sort="<?php echo esc_attr($product_sort_key) ?>&orderby=price" class="order-param-<?php echo sanitize_html_class($product_sort_key) ?>" href="javascript:void(0)"> <?php echo $product_order['price'] ?></a> </div><!--/ .order-param-button--> <div class="order-param-button"> <a title="<?php esc_html_e('Click to order products', MAD_BASE_TEXTDOMAIN) ?>" data-sort="<?php echo esc_attr($product_sort_key) ?>" class="order-param-<?php echo sanitize_html_class($product_sort_key) ?>" href="javascript:void(0)"> Алфавит</a> </div><!--/ .order-param-button--> 

ps now the price and the alphabet are considered only in one direction correctly, and when you click on them again, everything gets lost in a heap and the filter for some reason starts to be considered for all products

Closed due to the fact that PashaPash April 22 '16 at 20:00 is off topic.

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - PashaPash
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • you have a very heavy site, it loads for about half a minute, I personally have not enough patience to check anything, I only counted 71 js scripts and 49 css files on the main page. And the code given by you practically says nothing, it doesn’t completely understand how product sorting is implemented. You urgently need to work on optimizing your project, and not on the introduction of new features! - Blacknife
  • I also noticed that you are reworking your already working site with CMS bitrix into CMS WordPress. What are you based on when choosing a new CMS for your resource? - Blacknife
  • @Blacknife do you have that answer the question or will you argue not on the merits? - Vasya
  • I do not argue in any way, I gave you one advice-recommendation and asked one question. If you do not want to listen or answer questions - we do not suffer from this. Successes! - Blacknife

1 answer 1

@ Vasya In general, I looked at the code that generates AJAX requests on your site ... He lives in a script The data collection script for the sorting widget I will not publish all the script code here, because oh there ... In line 88, data collection starts when clicked on the arrows in your widget.

The problem lies in the fact that the sorting parameter orderby you do not pass

Insert in front of 105 lines ( mad_woof_ajax_page_num = 1; ) That will be your happiness ...


mad_woof_current_values.orderby = $ this.data (). href || '';

  • only this trick works 1 time, and with further clicks, what’s the price, what kind of confusion is going on the alphabet - all the goods are sorted into one heap - you don’t know what could be the reason? - Vasya
  • I know you, if not the advanced parameter of her, then alphabetically, the sorting goes - Bear GRiZZLY Xi
  • it's not entirely clear what the her parameter is and where can I see the difference? I don’t see any differences in the address bar except orderby=price - Vasya
  • 2
    Sorry not her but href and you can see it in devtulses - Bear GRiZZLY Xi
  • and where exactly is it shown there, on which tab and at what point - pressing the button? - I do not know how it can be seen - Vasya