Product Archive

WooCommerce Display Product Specific Content Under Add To Cart Button On Archive Loop

WooCommerce product specific content from custom metabox showing under add to cart button on archive loop item

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

Do you want to be able to display product specific information under the add to cart button on the product loop item which appears on the product archive page? Maybe you want to let customers know of some important information from the category page before they drill-down to the product page itself. This quick guide shows you how you can generate a custom field for products, then display the data from said custom field under the add to cart button on the loop item.

/**
 * Snippet Name:     WooCommerce Custom Product Metabox For Content Under Add To Cart Button On Loop Item
 * Snippet Author:   ecommercehints.com
 */

add_action ('woocommerce_product_options_advanced', 'ecommercehints_product_data_metabox');
function ecommercehints_product_data_metabox() {
   echo '<div class="options_group">';
   woocommerce_wp_text_input (array (
      'id'                => 'custom_loop_content_under_button',
      'value'             => get_post_meta (get_the_ID(), 'custom_loop_content_under_button', true),
      'label'             => 'Custom Loop Content',
      'description'       => 'Text to appear below the add to cart button on the loop item'
  ));
   echo '</div>';
}

add_action ('woocommerce_process_product_meta', 'ecommercehints_save_field_on_update', 10, 2);
function ecommercehints_save_field_on_update ($id, $post) {
      update_post_meta ($id, 'custom_loop_content_under_button', $_POST['custom_loop_content_under_button']);
}

add_action( 'woocommerce_after_shop_loop_item', 'ecommercehints_woocommerce_after_shop_loop_item' );
function ecommercehints_woocommerce_after_shop_loop_item() {
global $product;
$custom_loop_content_under_button = $product->get_meta ('custom_loop_content_under_button');
echo '<p>'.$custom_loop_content_under_button.'</p>';
};

Snippet Benefits

  • Display product specific content under the Add To Cart button on the product loop.
  • Let customers know information before drilling down to the product page.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER