Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $stylist_id = filter_input ( INPUT_POST, 'stylist_id', FILTER_SANITIZE_STRING);
- $face_id = filter_input ( INPUT_POST, 'face_id', FILTER_SANITIZE_STRING);
- $gender_id = filter_input ( INPUT_POST, 'gender_id', FILTER_SANITIZE_NUMBER_INT);
- $skin_id = filter_input ( INPUT_POST, 'skin_id', FILTER_SANITIZE_STRING);
- $hair_id = filter_input ( INPUT_POST, 'hair_id', FILTER_SANITIZE_STRING);
- $args = array(
- 'post_type' => 'product',
- 'meta_query' => array(
- 'relation' => 'AND',
- array(
- 'meta_key' => 'stylist',
- 'meta_value' => $stylist_id,
- 'compare' => '=',
- ),
- array(
- 'meta_key' => 'face_shape',
- 'meta_value' => $face_id,
- 'compare' => '=',
- ),
- array(
- 'meta_key' => 'skin_tone',
- 'meta_value' => $skin_id,
- 'compare' => '=',
- ),
- array(
- 'meta_key' => 'hair_colour',
- 'meta_value' => $hair_id,
- 'compare' => '=',
- ),
- ),
- 'tax_query' => array(
- array(
- 'taxonomy' => 'product_cat',
- 'field' => 'id',
- 'terms' => $gender_id,
- ),
- ),
- );
- $products = get_posts($args);
- var_dump($products); // Returns an array of products, but some products don't have the correct hair_colour or skin_tone etc...
Advertisement
Add Comment
Please, Sign In to add comment