D
D
Dr Zhmurge2021-09-20 19:08:24
WordPress
Dr Zhmurge, 2021-09-20 19:08:24

How to access attributes as meta fields?

In Woocommerce, product attributes are taxonomies and. But in the meta fields, they are serialized in the _product_attributes field.
As an example:

[_product_attributes] => Array
        (
            [0] => a:10:{s:18:"pa_gabarity-v-sh-g";a:6:{s:4:"name";s:18:"pa_gabarity-v-sh-g";s:5:"value";s:0:"";s:8:"position";i:1;s:10:"is_visible";i:1;s:12:"is_variation";i:1;s:11:"is_taxonomy";i:1;}s:10:"pa_ottenok";a:6:{s:4:"name";s:10:"pa_ottenok";s:5:"value";s:0:"";s:8:"position";i:2;s:10:"is_visible";i:1;s:12:"is_variation";i:1;s:11:"is_taxonomy";i:1;}}}
        )

The task is to use attributes in meta_query . How can I do that?
$args['meta_query'][] = array(
          'relation' => 'AND',
          array(
            'key' => '_product_attributes',
            'value' => как то их тут ищем,
            'type'    => 'numeric',
            'compare' => 'BETWEEN'
          )
        );

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question