adding product info to homepage
-
I was able to use this code snippet to add product Meta information to shop page https://prnt.sc/vxr535. I would like the information to also show on my homepage which has the blocks best seller, featured products, etc… The original Post is too old to comment on.
/** * Will add information to the shop loop above the "Add to cart" button * This example will use post meta (custom fields) and display them if set * Tutorial: https://www.skyverge.com/blog/add-information-to-woocommerce-shop-page/ **/ function skyverge_shop_display_post_meta() { global $product; // replace the custom field name with your own $tktprice = get_post_meta( $product->id, 'tktprice', true ); $payoutpercent = get_post_meta( $product->id, 'payoutpercent', true ); $tktcount = get_post_meta( $product->id, 'tktcount', true ); $idealnet = get_post_meta( $product->id, 'idealnet', true ); // Add these fields to the shop loop if set if ( ! empty( $tktprice ) ) { echo '<div class="product-meta"><span class="product-meta-title">Player Price:</span> ' . ucwords( $tktprice ) . '</div>'; } if ( ! empty( $payoutpercent ) ) { echo '<div class="product-meta"><span class="product-meta-title">Payout Percent:</span> ' . ucwords( $payoutpercent ) . '</div>'; } if ( ! empty( $tktcount ) ) { echo '<div class="product-meta"><span class="product-meta-title">Ticket Count:</span> ' . $tktcount . '</div>'; } if ( ! empty( $idealnet ) ) { echo '<div class="product-meta"><span class="product-meta-title">Ideal Net:</span> ' . $idealnet . '</div>'; } if ( $product->get_sku() ) { echo '<div class="product-meta">SKU: ' . $product->get_sku() . '</div>'; } } add_action( 'woocommerce_after_shop_loop_item', 'skyverge_shop_display_post_meta', 9 );
The page I need help with: [log in to see the link]
- The topic ‘adding product info to homepage’ is closed to new replies.