title: How to show custom related products with parent product details
body: <p>I have created three new related product fields what I want to show under single product view.</p>
  <p>Product has variations <code>pa_color</code> with terms <code>red</code>, <code>black</code>, <code>grey</code></p>
  <p>So I created into relations tab new three fields where I can select <code>red products</code>, <code>black products</code> and <code>grey products</code> what should be seen in single product under where was shown upselling products before. But I want it changes if customer selects varation <code>black</code> example then it will show <code>black</code> related products.</p>
  <pre><code>$test = get_post_meta( $post-&gt;ID, '_black_products_ids', true ); // this will take show black related products, but without parent details what I need to show.
  
  //$product = new WC_Product(get_the_ID()); //these was taking related upselling products
  //$related_products = $product-&gt;get_upsells();
  //$related_products_count = count($related_products);
  section class=&quot;beige pt-5 pb-3&quot;&gt;
      &lt;div class=&quot;container-fluid px-0&quot;&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col-md-12&quot;&gt;
                  &lt;h2 class=&quot;mb-4 all-title&quot;&gt;&lt;?php _e('Related products', 'wc'); ?&gt;&lt;/h2&gt;
                  &lt;article&gt;
                      &lt;div class=&quot;row&quot;&gt;
                          &lt;?php 
                          foreach($test as $related_product):
                          //foreach($related_products as $related_product):
                          $post_object = get_post($related_product);
                          setup_postdata($GLOBALS['post'] =&amp; $post_object);
                              wc_get_template_part('single-product-card');
                          endforeach; ?&gt;
                      &lt;/div&gt;
                  &lt;/article&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  <p>My related products card (single-product-card):</p>
  <pre><code>$product_thumbnail = (get_the_post_thumbnail_url()) ? get_the_post_thumbnail_url() : wc_placeholder_img_src();
  $product = wc_get_product( get_the_ID() ); ?&gt;
  
  
  &lt;div class=&quot;col-lg-3 col-md-6 mb-md-3 mb-3 &lt;?php if(is_front_page()) { echo 'pr-0 pl-md-3 pl-0'; }?&gt;&quot;&gt;
      &lt;article class=&quot;product-card h-100 p-3&quot;&gt;
          &lt;a class=&quot;h-100 d-flex flex-column&quot; href=&quot;&lt;?php the_permalink(); ?&gt;&quot; title=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
          &lt;img src=&quot;&lt;?php echo $product_thumbnail; ?&gt;&quot; class=&quot;card-img img-fluid position-relative&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot;&gt;
              &lt;div class=&quot;card-price py-1 px-3&quot;&gt;
                  &lt;p class=&quot;mb-0 &lt;?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?&gt;&quot;&gt;&lt;?php echo $product-&gt;get_price_html(); ?&gt;&lt;/p&gt;
              &lt;/div&gt;
              &lt;div class=&quot;card-header-details pt-3&quot;&gt;
                  &lt;div class=&quot;row&quot;&gt;
                      &lt;div class=&quot;col-md-12 mb-3&quot;&gt;
                          &lt;h3 class=&quot;card-title mb-0&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt;   
                      &lt;/div&gt;
                      &lt;div class=&quot;col-md-12&quot;&gt;
                      &lt;?php if( have_rows('product_info') ): ?&gt;
                          &lt;div class=&quot;product-info&quot;&gt;
                          &lt;?php while( have_rows('product_info') ) : the_row(); ?&gt;
                              &lt;div class=&quot;row&quot;&gt;
                                  &lt;div class=&quot;col-md-3&quot;&gt;
                                      &lt;p class=&quot;mb-0 heading&quot;&gt;&lt;?php the_sub_field('info_heading'); ?&gt;&lt;/p&gt;
                                  &lt;/div&gt;
                                  &lt;div class=&quot;col-md-9&quot;&gt;
                                      &lt;p class=&quot;mb-0 value&quot;&gt;&lt;?php the_sub_field('info_value'); ?&gt;&lt;/p&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;?php endwhile; ?&gt;
                          &lt;/div&gt;
                      &lt;?php endif; ?&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/a&gt;
      &lt;/article&gt;
  &lt;/div&gt;
  </code></pre>
  <p>Missing details: product_info, info_heading, info_value</p>
  <hr />
  <p>Maybe I do all this thing wrong and harder way but I think im close to it.</p>
  <p>I used this topic to create these fields to relation tab under product: <a href="https://stackoverflow.com/questions/45199599/how-to-add-more-custom-field-in-linked-product-of-woocommerce">How to add more custom field in linked product of woocommerce</a></p>