PressTigers

Sorting For Alphanumeric Titles Of WooCommerce Products

WooCommerce products sorting plugin generally allows alphabetical product sorting. This plugin will sort the WooCommerce products on the basis of alpha numeric product title. For instance, if we have three products having titles: A1, A2 and A10, then MySQL traditional sorting will sort these products based on their alphanumeric pattern i.e; A1, A10 and then A2. Our Client’s project need was to show them on the basis of numeric values in their titles means like 1,2,….,10 so the required order will become A1, A2, A10.

To meet this requirement, our PressTiger implemented the following steps:

  • When WooCommerce plugin is activated, it will fetch all the WooCommerce products, parse their titles and retrieve numeric values from it, and save them in WordPress database. This will make sure that no old product is left out of this custom sorting process.
  • When a new product is added, or any old product is updated, by using WordPress hooks it will do the necessary parsing and retrieve numeric values and will save/update these values in the database. This will make sure that sorting is in complete synchronization with the admin panel updates.
  • When products are displayed at Front-end, this plugin will hook into WooCommerce through actions and it filters and alters the sorting criteria without modifying the core code or WooCommerce plugin.

User Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Get in Touch