PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]
Cyber Monday 2021
Cyber Monday 2021 timer

Support Forum

You need to log-in to create request (topic) to the support

Couple of suggestions for the sort panel

This support system is for all types of the plugins as for premium versions, so for free ones! If you have premium version do not forget in the private data of the request (!!not in the text of the support request!!) after its publishing insert purchase code please (see blue-green button on the right side) and press Save button.
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi guys,

Also posted this on WP forum. Unsure which one will get the fastest answer.

I've got a couple of suggestions for the sort panel.

1) It would be nice to"clean" the url when consecutive sorts are executed, in order to prevent having urls of 1000 kilometers long.
In front.js, where there is the mdf_is_search_going == 1 condition
It would be nice to have something in the likes of:
href=href.replace(/&?order_by=([^&]$|[^&]*)/i,"");
href=href.replace(/&?order=([^&]$|[^&]*)/i,"");
Otherwise if you keep clicking on different sorting options, it just keeps infinitely adding new url parameters to the current one.

2) I mainly use the button sort panel, but I guess a similar logic to this one could be applied to the other sort panels.
Currently, there is a default order given through the options, which is either ASC or DESC.
The current behaviour is that all sorting options of a given sort panel take this default order.
Then whenever you click, the order changes, but it changes everywhere and does not preserve the default order for the sorting options that are not active.

It would be nice to have a default order for each sorting option (maybe by adding a third"^" in the options? - Something like price^Price^ASC or power^Power^DESC).

Why? Let's say I offer 3 types of sorting,"By Price","By Power", and"By Rating".

They match 2 different user intents. If someone clicks"By Price", they most likely want an ascending order (cheapest to most expensive). But if they click"By Rating" or"By Power", they most likely want a descending one (most powerful/better rated first).

Currently, if they filter"By Rating" and if the rating is indeed in a descending order, if they then click on"By Power", they will see something ascending, because the order simply switches.

So now, I brute-forced my way through button_filter_panel.php to try to see if I could improve the behaviour.

The current code is:
<?php foreach ($settings as $value) : ?>
<?php $value = explode('^', $value); ?>
<li <?php if ($value[0] == $order_by): ?>class="meta_data_filter_order_<?php echo strtolower($order) ?>"<?php endif; ?>>
<a data-order-by="<?php echo $value[0] ?>" data-order="<?php echo($order == 'ASC' ? 'DESC' : 'ASC') ?>" href="javascript:void(0);"><?php echo $value[1] ?></a>
</li>
<?php endforeach; ?>

If I change this to:

<?php foreach ($settings as $value) : ?>
<?php $value = explode('^', $value); ?>
<?php
$defaultOrder=['rating'=>['DESC','ASC'],'price'=>['ASC','DESC'],'power'=>['DESC','ASC']]; ?>
<?php if ($value[0] == $order_by) { ?>
<li class="meta_data_filter_order_<?php echo strtolower($order) ?>"?>
<a data-order-by="<?php echo $value[0] ?>" data-order="<?php echo($order == $defaultOrder[$value[0]][0] ? $defaultOrder[$value[0]][1] : $defaultOrder[$value[0]][0]) ?>" href="javascript:void(0);"><?php echo $value[1] ?></a>
</li>
<?php } else { ?>
<li>
<a data-order-by="<?php echo $value[0] ?>" data-order="<?php echo $defaultOrder[$value[0]][0] ?>" href="javascript:void(0);"><?php echo $value[1] ?></a>
</li>
<?php } ?>
<?php endforeach; ?>

It now works as expected. Each sorting option keeps it own default value until it's actually active. So whatever the previous order was, if"By Rating" was not active and is being clicked,"By Rating" will always display in a descending order first.

Keep in mind that I'm just a hobbyist coder, so there surely is a cleaner way to do it :)
It was just trying to explain my reasoning.

3) And also, in the same file. <ul> as child of <span> is not that great :)

Hello

thank you for suggestions

I'll pass it to the developers