WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
get_post_meta - woocomerce products (2 posts)

  1. damian.smith
    Member
    Posted 1 year ago #

    Hey guys! I have the below code in my themes functions.php which creates a new tab on the product page.

    The only issue is, is that the get_post_meta is not working. I have added it to the products custom fields and this code normally works on standard wordpress posts. But not with a woocommerce post/product.

    Any ideas? :(

    add_action( 'woocommerce_product_tabs', 'sb_woocommerce_new_tab', 40 );
    add_action( 'woocommerce_product_tab_panels', 'sb_woocommerce_new_panel', 40 );
    function sb_woocommerce_new_tab() {
     echo '<li><a href="#tab-new">' . __('Technical Documents', 'woocommerce') . '</a></li>';
    }
    function sb_woocommerce_new_panel() {
     echo '<div class="panel" id="tab-new">
     <h2>Technical Docs</h2>'; ?>
    
    <p>
    <?php echo get_post_meta($post->ID, 'rel_cat', true); ?>
    </p>
    
    <?php
     echo '</div>';
    }

    http://wordpress.org/extend/plugins/woocommerce/

  2. bheadrick
    Member
    Posted 1 year ago #

    you probably need to add this at the top of your sb_woocommerce_new_panel function:

    global $post;

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.