Code for sort option PRICE Low |High

Hello,
I used the code shown below to create Price “High” and “Low” on each page on my website.

When I click on either “High” or “Low” it is not showing all the the items either in a ascending or descending order on the page.

For example if there are 30 Items in one page with a variety of prices starting from ( 10, 20, 30, 40, 50s) if I click on price “High” (descending) it will show prices from 30s in a descending order first, then when I scrolling down suddenly after twenty items it will start showing prices from 50s in a descending order.

It is the same when I click on “Low” ( Ascending order) as well.


This is how I add the code-

  1. Click on “High”
  2. I click on “OnClick”


2) Then I paste the whole code, and change the four ID’s

import wixData from ‘wix-data’;
$w.onReady( function() {
$w(“#button228”).onClick( (event, $w) => {
$w(“#dresses1”).setSort( wixData.sort()
.descending(“price”) );
} );
$w(“#button227”).onClick( (event, $w) => {
$w(“#dresses1”).setSort( wixData.sort()
.ascending(“price”) );
} );
} );

Can someone please let me not know how to solve this issue .

I appreciate it very much.

Thank you.

Hi Dilly!

Your code seems fine.
Please send us an URL to the site and the page you’re facing issues with so we can look into it.

Doron. :slight_smile:

Hello Doron,

Many thanks for your reply.
Apologise for taking some time to reply, I had a family matter to attend to.

The link is
https://deli236.wixsite.com/mynewsite/PantsandJeans/brand/TOMMY-HILFIGER

When you click on “HIGH” on TOMMY HILFIGER you will see what is happening.

I look forward to your reply.
Kind regards,
Dilly

I just noticed something else.
When I click on the Collection “PantsandJeans” and Click Sort Z to A on the Price Column

The first price showing is 99.95
When I scroll down to Row Number 662 the price showing is 199

Can you please have a look at this as well.

Thank you.

Hi Dilly!

I believe that the issue is due to the fact that the field of the price in your collection (database) is set to be a ‘text’ type and so it sorts the numbers according to the first digit only.
Try and change it to a field of type “numbers” and inform us if the issue isn’t resolved.

Hope it helps!
Best of luck!

Doron. :slight_smile:

Hello Doron

I deleted the items on the collection and changed the Field type to “Number” as you mentioned. It is working! Brilliant.

Thank you SO… MUCH for your help. I appreciate it very much.

One more thing please.

On the CSV sheet I import, under the IMAGE Column section have added links.

On the Collection (database) I changed the Field Type to Image
Then I import the CSV sheet to Collection (database)
As you can see on Image 2. bellow, some of the images appears and some do not.

Image 1.

Image 2.

Maybe I will have to change the Field type to URL? I prefer if I can see the Images.

Can you please have a look at this.

Thank you
Kind regards,
Dilly

Hi Dilly,

As you’ve stated the content management shows part of the images just fine and part as broken links
I’ve noticed that the ones that fail to present are actually valid image URLs but ones that do not end with an image file type (*.jpg for example)

For example:
http://images.asos-media.com/inv/media/9/1/2/2/9372219/lightgrey/image1xxl.jpg is working fine
while…
http://houseoffraser.scene7.com/is/image/HOF/I_5055810543501_50_20170113 is not…

This is currently a known issue and we are working on a fix

Thanks
Adi

Oh yes! I can see that now.

Thank you very much Adi for your reply. I appreciate it a lot

All the best,
Dilly