最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Fetch Children of Grouped Products Inside WooCommerce Product Loop

programmeradmin3浏览0评论

I am overriding the WooCommerce archive-product.php in a child theme so I can list single products and grouped products. The loop outputs each product as a single item which is what I want for Simple Products, but not for Grouped Products as the resulting outputs the parent product in a single item, and the child product in a different single item, what I am trying to do is to output the children of a grouped product under the parent only, not as a single item.

I already searched inside WooCommerce Functions but couldn't find any clue on how to fetch the children of a grouped product for each parent.

<?php
   if ( woocommerce_product_loop() ) {
    do_action( 'woocommerce_before_shop_loop' );
    woocommerce_product_loop_start();

    if ( wc_get_loop_prop( 'total' ) ) {
        while ( have_posts() ) {
            the_post();
            do_action( 'woocommerce_shop_loop' );
    ?>
    <div class="list-product-item">
     <?php woocommerce_template_loop_product_title(); ?>
    </div>
 <?php
    }
   }
   woocommerce_product_loop_end();
   do_action( 'woocommerce_after_shop_loop' );
  ?>
发布评论

评论列表(0)

  1. 暂无评论