Comments Davide Golzi started the conversationOctober 28, 2020 at 5:26pmHi, i'm interested to create a shortcode able to display bundles that contains a specific product.Can you help me write the query to retrive the bundle product id giving the must contained product id? 767Janilyn repliedOctober 29, 2020 at 10:45amHi Davide, Thank you for contacting WPClever Support Forum. We’ve received your ticket and assigned one of our developers to help you with that. He’ll be looking into your question and responding with specific instructions as soon as possible. Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back. Best regards.Janilyn T. - WPClever Support Agent 1,226Dustin repliedOctober 30, 2020 at 7:57amHi Davide,Please try this function: function woosb_get_bundles( $product_id, $per_page = 500, $offset = 0 ) { $bundles = array(); $product_id_str = $product_id . '/'; $query_args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $per_page, 'offset' => $offset, 'tax_query' => array( array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => array( 'woosb' ), 'operator' => 'IN', ) ), 'meta_query' => array( array( 'key' => 'woosb_ids', 'value' => $product_id_str, 'compare' => 'LIKE', ) ) ); $query = new WP_Query( $query_args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); $_product = wc_get_product( get_the_ID() ); if ( ! $_product ) { continue; } $bundles[] = $_product; } wp_reset_query(); } return ! empty( $bundles ) ? $bundles : false; }Best regards,Dustin Sign in to reply ...
Hi, i'm interested to create a shortcode able to display bundles that contains a specific product.
Can you help me write the query to retrive the bundle product id giving the must contained product id?
Hi Davide,
Thank you for contacting WPClever Support Forum.
We’ve received your ticket and assigned one of our developers to help you with that.
He’ll be looking into your question and responding with specific instructions as soon as possible.
Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.
Best regards.
Janilyn T. - WPClever Support Agent
Hi Davide,
Please try this function:
Best regards,
Dustin