Answer the question
In order to leave comments, you need to log in
How to sort products in category by nested custom fields in Woocommerce?
For products there is a custom field Position in Category - " cat_position " created in ACF. It has two nested fields "Category selection" ( cat_position_vybor ) and "Position number" ( cat_position_number ). In the product, it looks like this:
I.e. one product can belong to several categories, which are indicated in the "Category selection". And for each category, its own position is indicated in the "Position Number".
It turns out that for each product, the cat_position field is an array that looks something like this:
$cat_position = (
[0] => Array
(
[cat_position_vybor] => 159
[cat_position_number] => 37
),
[1] => Array
(
[cat_position_vybor] => 160
[cat_position_number] => 37
),
[2] => Array
(
[cat_position_vybor] => 161
[cat_position_number] => 37
),
[3] => Array
(
[cat_position_vybor] => 162
[cat_position_number] => 37
),
...)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question