Sort and display products by custom field or Meta - WooCommerce Organizing and displaying products is an important storage function that makes an important component of the user experience. The ability to sort the product list in the order of priority agreed to visitors to select the appropriate product quickly, continue transactions.
Sort and display WooCommerce products with two types: Default / Custom. custom WooCommerce product taxonomy is usually done using hooks.
Sorting and displaying product catalogs by custom fields / by other post meta value helps customers browse WooCommerce website with you a lot. This option adds a useful way to organize inventory so customers discover products they have not previously seen.
Today, I will first describe the custom field and then highlight how to add this WooCommerce sorting option to the product page.
Add custom fields to the Woo commercial product
You conveniently add custom fields to all WooCommerce products by entering them with custom fields set as post meta. This agrees you to set meta post for all products.
Once completed, you will now be able to add values based on text and numbers as post meta information. Customers now arrange products by using this value.
WooC Commercial Products Sort and display by custom fields
WooTheme is very useful in terms of layout. However, it does not mention the meta value interface. This metal value is used to set up the sort filter using both numbers and text.
To show the concept, I will add two sorting options: Sort by position, Sort by points.
See more: How to create a Landing Page
How will the product display?
On the product page, this option is now added to the sort filter drop-down menu.
The following code snippet shows the location, point of sale at the website. Using this function, you can display any custom field on your website by passing meta values.
Now whenever you select sort option, the corresponding sort argument will be used. Screen shot showing sorting options: active location.
Similarly, when arranging for a Point of Sale, the output will be:
Now if you try to do this at the Edit product screen, the product screen requires setting a value for the custom field.
Sort default WooCommerce products
To enable default WooCommerce product sorting, simply visit WooCommerce Settings> Product Tab.
At the drop-down list, you see the default sorting option available that focuses on price parameters, popularity.
To view this sorting parameter in action, visit the Products page. Click the Sort products tab, select the desired parameters. The results on the page will change to reflect your selection.
If you want to apply custom layers or want to change the order of parameter menu arrangements, you do so by going to Products> Advanced and then on the Order Menu option. Behind the scenes, this action uses the WooCommerce _catalog_orderby hook.
Add custom sorting options for WooCommerce products
If you think the available sorting parameters are not enough for the purpose you want, you can add your own sorting option displayed in the drop down list. For this, add the following code to functions.php.
Save the file, reload the page to see the Woo WooCraft Commercial Product Sorting option at the drop down list.
For this article, I discussed how to organize and display WooCommerce products by custom fields as well as post meta. The example is very simple to implement and is extended to include any number of sorting options. If you have any questions, leave a comment below.