I've this code to find the variation id of a variable products based on selected attributes.
$match_attributes = array(
'pa_color' => 'grey',
'pa_base' => 'circular',
'pa_text' => 'no',
'pa_font' => 'kaushan-script'
);
$data_store = WC_Data_Store::load( 'product' );
$variation_id = $data_store->find_matching_product_variation(
new \WC_Product( $myProductId), $match_attributes
);
The $match_attributes is correct but still receive zero $variation_id = 0, there something wrong? There is another way to get the variation id?
Tnx
solved by myself but maybe someone needs to solve the same problem, I write down what have worked for me:
I've manually inserted the "attribute_" prefix, and now all works as expected.