The Product Meta Column within a picklist serves as a valuable repository of enriched product information. It assists the store packers by providing them with clear and organized information about the products they need to pack. The WebToffee’s, WooCommerce Picklists plugin helps to add a new product meta column to a picklist and sort it based on the added product meta column. Sorting the picklist becomes easier when we use the product meta column.
Follow the below steps to add a new product meta column to a picklist and sort it based on the added product meta column.
Step 1: Add a new product meta column using the custom code provided.
Step 2: Sort the picklist either in ascending or descending order.
Adding product meta column
Adding a product meta column involves two steps:
- Create a new column for product meta.
- Add product meta to the newly created column.
Creating a new column for product meta
To create a new product meta column, add the code mentioned below to the active child themes functions.php file. If the current theme doesn’t have a functions.php file, then utilize one of the code snippet plugins available in WordPress.
- To know more about how to add a custom code snippet using a third-party plugin refer to this article.
Example
Let’s consider a scenario to create a product meta column named ‘weight’.
- To create a product meta column named ‘weight’, add the custom code below to the active child theme’s functions.php file.
To change the product meta column name from ‘weight’ to any other desired name, follow the below steps:
- In the code below, replace ‘weight’ with the desired column name.
- Now add the updated code to the active child themes functions.php file.
The following image is an example of a picklist with a new product meta column ’WEIGHT‘ added to it.
Adding product meta to the newly created column
To add product meta to the newly created column, use the custom code mentioned below.
Example
Let’s take a scenario of adding a product meta ‘weight’ to the newly created column.
- To add the product meta ‘weight’ to the newly created column, add the code mentioned below to the active child theme’s functions.php file.
- If the current theme doesn’t have a functions.php file, then utilize any of the code snippet plugins available in WordPress.
To add any other product meta to the column other than ‘weight’, follow the below steps:
- In the code below, replace the meta key ‘_weight’ with the desired product meta key and the variable ‘weight’ with the desired product meta.
- Now add the updated code to the active child themes functions.php file.
The following image is an example of a picklist with a product meta ’weight’ added to the product meta column.
WooCommerce Picklist with an added product meta column(WEIGHT)
Sorting picklist based on the product meta column
Sorting in ascending order
To sort a picklist in ascending order, use the code mentioned below.
Example
Here let’s take an example of sorting ‘weight’ in the product meta column in ascending order.
- To sort ‘weight’ in ascending order, add the below-mentioned code to the active child themes functions.php file.
- If the current theme doesn’t have a functions.php file, then utilize any of the code snippet plugins available in WordPress.
To sort any other product meta other than ‘weight’ in ascending order, follow the below steps:
- Replace the variable ‘weight‘ in the custom code with the desired product meta.
- Then add the updated custom code to the active child theme’s functions.php file.
The following image shows an example of a picklist grouped by order and categories and then sorted in ascending order with respect to the added product meta ‘WEIGHT‘.
Sorting in descending order
To sort a picklist in descending order, add the custom code snippet mentioned below to your WordPress site.
Example
Here let’s take an example of sorting ‘weight’ in the product meta column in descending order.
- To sort ‘weight’ in descending order, add the below-mentioned code to the active child themes functions.php file.
- If the current theme doesn’t have a functions.php file, then use any of the code snippet plugins available in WordPress.
To sort any other product meta other than ‘weight’ in descending order, follow the below steps:
- Replace the variable ‘weight‘ in the custom code with the desired product meta.
- Then add the updated custom code to the active child theme’s functions.php file.
The following image shows an example of a picklist grouped by order and categories and then sorted in descending order with respect to the added product meta ‘WEIGHT‘.