Thread Starter
Joy
(@joyously)
Shortly after adding that “+0” to the code, I added some product tags and put the taxonomy widget in the sidebar. I clicked on my new tags and sorted by price (I put the code from the Order Panel widget into my loop-tcp-grid). This is when things didn’t look right. I had several products with a zero price suddenly.
I looked at my product list in the back-end and figured out that it was the products with the new tags that I had just displayed sorted by price that had a zero. And I had just put that +0 fix in.
So I edited all those products and set the values. It turns out all the meta values were gone on those. I took the +0 back out of the code. I then clicked on the same links as before and had no problems, sorted by price too (although it sorts wrong). I then put the +0 back in the code and clicked around again. I couldn’t get it to misbehave. It all looks good (and sorts correctly).
Since I couldn’t find the reason for the loss of data, I suspect there is still some bug lurking in the code.
Just thought I’d let you know…
Hi
I have fixed this error with a CAST, but still there are problems with the order, so for the moment is a known bug.
I’d like to sort only tcp_products. But with the TheCartPress code all the post types are sorted
Best regards
Thread Starter
Joy
(@joyously)
Why can’t you use the conditional template functions to determine if you should apply your sort?
if (is_tax('tcp_product_tag') || is_tax('tcp_product_category') || is_tax('tcp_product_supplier'))
...do your orderby...
Or at least make the sort optional?
Hi Joy,
I have changed it and I think it works!!
I have to test it more, Thank you very much!!
Have you download the beta version? It has a lot of new features…
Thanks again and best regards
Thread Starter
Joy
(@joyously)
Sensei,
This method of sorting causes a problem when using a TCP loop in a page or a sidebar. There is no way to tell that loop to come out in a different order than the user chose.
I want to put a list of products on my home page, so I generated a shortcode and the products show up. But they are in whatever order I last chose on the category page. I want them in the order I specified in the backend.
Thread Starter
Joy
(@joyously)
The fix of the sort with the CAST does not fix the numerical sort problem. When you fix it with +0, it sorts correctly.
Oh! I see you put the CAST on the tcp_postmeta_order instead of tcp_postmeta_price. The order would have the same problem, if you get into double digits which is easy to do, but price is the one that is really apparent.
Thread Starter
Joy
(@joyously)
I’ve been trying to get this to work on the front page on the 1.0.9 beta.
I just realized that you put the conditional tags into your parseRequest function, so now you only respond to the user trying to change the sort on a tcp_product taxonomy page. But me trying to put a list of products on the home page is still affected by your ordering (whatever was chosen last).
I think it’s a bad practice to ignore a request variable that’s there (only available sometimes). I would remove the conditional from parseRequest. This might be what is causing it to now take 2 clicks of the sort button (Order in the Order Panel) to get it to sort, even though you can be on a list page. It redraws the screen, but the products are not sorted. The second time I click, the products are sorted.
Thread Starter
Joy
(@joyously)
Finally!
Much better sorting capability in the August 7 1.1.0 beta release.