A
A
Ainur Shakirov2016-02-17 15:05:01
CMS
Ainur Shakirov, 2016-02-17 15:05:01

How to "fix" sorting by name in woocomerce?

Made by this method: 365-progress.ru/tehnologii/web/svoya-sortirovka-to...
But, the problem is that our goods are numbered. And outputs it like this:

Товар №1
Товар №10
Товар №11
Товар №12
...
Товар №18
Товар №19
Товар №2
Товар №20
Товар №21
...
Товар №28
Товар №29
Товар №3
...

And it is necessary that it be 1 2 3 ..
Could you tell me where the sorting function itself is, or how to solve this problem?
If sorting is done immediately using an sql query, then how to edit it correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Usov, 2016-02-25
@Paul_Inglsmit

The problem is that the names are sorted as strings, so in fact everything is correct) BUT you need to sort as numbers.
Hypothetically, this should work:

$args['meta_key'] => 'имя_мета_поля', 
$args['orderby'] => 'meta_value_num', 
$args['order'] => 'ASC'

Perhaps you need to start another field, where you drive in pure numbers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question