wordpress - Editing Woocommerce category/subcategory loop -


i'm building custom wp theme woocommerce integration. little background first. theme using foundation 6. have disabled woocommerce styles , layouts. using overriding templates can integrate foundation.

my shop page listing product categories, not individual products. once category selected, list of sub-categories, products.

i'm able put products 4 column rows fine following code:

loop-start.php

<div class="row"> 

archive-product.php

<?php woocommerce_product_loop_start(); ?>              <?php woocommerce_product_subcategories(); ?>              <?php $counter = 1; while ( have_posts() ) : the_post(); ?>                  <?php wc_get_template_part( 'content', 'product' ); ?>              <?php                   if( $counter % 4 == 0 ) : echo '</div><div class="row">'; endif;                  $counter++;                  endwhile; // end of loop. ?>  <?php woocommerce_product_loop_end(); ?> 

loop-end.php

</div> 

content-product.php

<div <?php if($wcp_last_loop) : post_class('medium-3 columns end'); else : post_class('medium-3 columns'); endif; ?>> <?php /**  * woocommerce_before_shop_loop_item hook.  *  * @hooked woocommerce_template_loop_product_link_open - 10  */ do_action( 'woocommerce_before_shop_loop_item' );  /**  * woocommerce_before_shop_loop_item_title hook.  *  * @hooked woocommerce_show_product_loop_sale_flash - 10  * @hooked woocommerce_template_loop_product_thumbnail - 10  */ do_action( 'woocommerce_before_shop_loop_item_title' );  /**  * woocommerce_shop_loop_item_title hook.  *  * @hooked woocommerce_template_loop_product_title - 10  */ do_action( 'woocommerce_shop_loop_item_title' );  /**  * woocommerce_after_shop_loop_item_title hook.  *  * @hooked woocommerce_template_loop_rating - 5  * @hooked woocommerce_template_loop_price - 10  */ do_action( 'woocommerce_after_shop_loop_item_title' );  /**  * woocommerce_after_shop_loop_item hook.  *  * @hooked woocommerce_template_loop_product_link_close - 5  * @hooked woocommerce_template_loop_add_to_cart - 10  */ do_action( 'woocommerce_after_shop_loop_item' ); ?> </div> 

so works great products not categories though. know categories , subcategories being pulled in

<?php woocommerce_product_subcategories(); ?> 

i know have use hook or filter put every 4 categories in row, i'm not versed in wp hooks , filters, struggling find solution. i've been trying read on hooks , filters, hoping find more specific i'm trying do.

any advice appreciated.

so did end finding solution, not sure if best route go worked.

for others may run same issue, here did.

  1. located woocommerce_product_subcategories() in wc-template-functions.php. copy entire function, including check see if exists.

  2. paste functions.php file. rename function, example:

    function new_name_product_subcategories( $args = array() ) { .... } 
  3. look following foreach loop:

        foreach ( $product_categories $category ) {         wc_get_template( 'content-product_cat.php', array(             'category' => $category         ) );     } 

and change to:

        $cat_counter = 1;         foreach ( $product_categories $category ) {             wc_get_template( 'content-product_cat.php', array(                 'category' => $category             ) );             if( $cat_counter % 4 == 0 ) : echo '</div><div class="row">'; endif;             $cat_counter++;         } 
  1. then in archive-product.php file, change:

    <?php woocommerce_product_subcategories(); ?> 

to

<?php new_name_product_subcategories(); ?> 

if find way via wp hooks, post reply, way think of now.

also, didn't go on how added .columns classes individual categories. added in content-product_cat.php file.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -