Showing more Product Meta info on Woocommerce product page

I’m currently working on a woocommerce webshop using 40k+ affiliate products.
Below the add to cart button woocommerce automaticly shows SKU, Category and Tags. however i would like to add more info provided in the Product meta such as size, color and brand.

I’ve messed around with the Meta.php however no luck so far.
I’ve tried adding several variables eg:

Read More

existing:

 $cat_count = sizeof( get_the_terms( $post->ID, 'product_cat' ) );

i added:

 $col_count = sizeof( get_the_terms( $post->ID, 'product_col' ) );

in the div class “product_meta” it states the following:

<?php echo $product->get_categories( ', ', '<span class="posted_in">' . _n( 'Category:', 'Categories:', $cat_count, 'woocommerce' ) . ' ', '</span>' ); ?>

added:

<?php echo $product->get_colors( ', ', '<span class="posted_in">' . _n( 'Color:', 'Colors:', $col_count, 'woocommerce' ) . ' ', '</span>' ); ?>

however no succes. not an experienced coder so excuse me if i did somethin completely idiotic.

With kind regards,

Rudy

Related posts

1 comment

  1. For example you can use product attributes in WooCommerce:

    1. Open ‘Products’ section on Admin Dashboard
    2. Open ‘Attributes’ subsection
    3. Create required attributes (e.g. Color) and save this
    4. Go to product editing page
    5. Open ‘Attributes’ tab and set attribute(s) value(s)
    6. Save product

    After that you need override WooCommerce template file (…/wp-content/plugins/woocommerce/templates/single-product/meta.php)

    Copy this code in meta.php:

    $attributes = $product->get_attributes();
    
    foreach ( $attributes as $attribute ) {
    
        print_r( wc_attribute_label( $attribute[ 'name' ] ) . ': ' );
        print_r( array_shift( wc_get_product_terms( $product->id, $attribute[ 'name' ] ) );
    
    }
    

    More about adding information to WC Shop Pages here:

    https://www.skyverge.com/blog/add-information-to-woocommerce-shop-page/

Comments are closed.