Skip Navigation

[Resolved] Product View ordering by custom field no longer working

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View of Products that should be ordered by a custom field on the Products post, but the order of posts does not seem to be correct based on the custom field value.

Solution: Our developers have issued a patch for this problem in Views 3.5.1 / Blocks 1.5.1, and the issue will be solved in the next release of the plugins. To solve the problem in Views 3.5.1 / Blocks 1.5.1, you have two options: - Create a Query Filter based on this custom field, where the field value is not empty or not equal to a blank value. - Apply the patch to the Toolset Views plugin or the Toolset Blocks plugin as described in the comments below.

The issue will be addressed in the next release of Views/Blocks, and the workarounds mentioned here will no longer be required once the plugins are updated.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 8 replies, has 2 voices.

Last updated by Christian Cox 1 month ago.

Assigned support staff: Christian Cox.

Author
Posts
#2039011
Capture4.PNG
Capture3.png
Capture2.png
Capture.png

I am trying to: order listings by last name (which is a custom field, specifically set for this purpose).. capture.png

Link to a page where the issue can be seen: hidden link (capture2.png)

I expected to see: ordered by last name (capture4.png). Capture3.png shows my test site which is not yet updated to the newer version of toolset views which is causing the issue.

Instead, I got: some sort of random order.

#2039107

One small extra update. I've now switched the view to order by post title... which works, so you won't see the error that was captured in the screen shots.

#2039813

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Hi, I'll be glad to help figure this out. Is it possible to update the test site to use the latest versions of the Toolset plugins, so we can replicate the problem and run additional tests to determine the cause? If that's okay with you, please provide login credentials to the test site where I can log in and see the issue occurring. I'll take a closer look and run some tests, disabling other plugins and so forth to help isolate the cause of the problem.

#2041303

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Screen Shot 2021-05-03 at 10.30.27 AM.png

Okay I believe I have a temporary fix for this issue in place on Test. I have edited the View here:
hidden link

I added a Query Filter based on the Last Name (Ordering) field, such that the field is not equal to an empty string. This adds the field to the meta query and seems to fix the ordering issue. Screenshot attached showing the modification.

This filter should not be necessary. I've set up a similar View of Products in my local environment and was able to replicate the same problem, so I suspect this is a bug in the current software. I am escalating to my 2nd tier support team for additional investigation, and I'll let you know what I find out.

FYI I bumped up the memory allocation in the Test environment by adding this code to wp-config.php, because I ran into some fatal errors related to memory during testing:

define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Feel free to remove that code or adjust as needed.

#2041403

Thanks! I've moved your fix onto my live site, and am happy with that solution. Of course if its a bug, and 2nd tier support provides another fix, so much the better.

Jesse

#2041479

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Okay good to hear the fix works on the live site. I will keep you posted here and let you know when this workaround has been patched in an upcoming release, or if there is any other information to share from the 2nd tier/developers.

#2042421

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Our developers have created a patch file for this issue. I've tested in my local environment and it seems to solve the problem without requiring the workaround I already described. You can download an archive containing the patch file here:
https://drive.google.com/file/d/1Z8qOFnPDe8FLfK3lzmn0f-btuftAmQRv/view?usp=sharing

To apply the patch, unzip it and upload the file it contains to replace the file with the same name in your Toolset Views plugin:

\wp-content\plugins\wp-views\application\models\WooCommerce\WcQuery.php

For those who use Toolset Blocks instead of Toolset Views, the file should be replaced in the Blocks plugin instead:
\wp-content\plugins\toolset-blocks\application\models\WooCommerce\WcQuery.php

Please apply the patch and let me know if the issue is not resolved.

#2042509

My issue is resolved now. Thank you!

#2058005

Christian Cox
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Hello, just a quick update to let you know our team is in the process of pushing out updates to several Toolset plugins including Blocks and Views. Once the updates are fully deployed, you will be able to use the automatic update feature in wp-admin > Plugins > Add new > Commercial tab > Toolset Installer panel to update automatically. You may need to click "Check for updates" to refresh the plugin list. The new versions of the plugins include the fix for this issue, so after updating to Views 3.5.2 / Blocks 1.5.2, you should no longer need the patch. Thanks for the report and for your patience while we worked to resolve this sorting problem.