• Resolved msamavi

    (@msamavi)


    Hello,

    Can you please advise how to display the label and value using functions.php?

    Thanks and regards
    Majid

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    I would like to know this too. I’ve tried:

    // WooCommerce UPC under product title
    
    add_action( 'woocommerce_single_product_summary', 'dev_designs_show_upc', 10 );
    function dev_designs_show_upc(){
        global $product;
        echo 'UPC: ' . $product->wpm_gtin();
    }

    “wpm_gtin” isn’t the right one for sure, so, what to put here? Is it supported?

    I’m on no way a programmer, just modding the theme for my website.

    Thank you,
    Ronald

    Plugin Author Emanuela Castorina

    (@kreamweb)

    Hi,
    there’s the shortcode

    [wpm_product_gtin]

    You can find how to use it inside a FAQ here:
    https://www.ads-software.com/plugins/product-gtin-ean-upc-isbn-for-woocommerce

    so you can show it simply with a

    <?php echo do_shortcode('[wpm_product_gtin id="123"]'); ?>

    Or it is possible get the meta for example inside the @ronald-van-arkel function:

    add_action( 'woocommerce_single_product_summary', 'dev_designs_show_upc', 10 );
    function dev_designs_show_upc(){
        global $product;
        echo 'UPC: ' . $product->get_meta( '_wpm_gtin_code' );
    }

    Hello Emanuela,

    Thank you for the help. I didn’t know the meta “name” so to say, could not be found in the FAQ (sure looked trough it and also on the forum here).

    This is my final code with with classes added to it:

    // WooCommerce SKU and UPC under product title
    
    add_action( 'woocommerce_single_product_summary', 'dev_designs_show_sku', 10 );
    function dev_designs_show_sku(){
        global $product;
        echo '<div class="sku_under_title">SKU:' . $product->get_sku() . '</div>';
    }
    
    add_action( 'woocommerce_single_product_summary', 'dev_designs_show_upc', 10 );
    function dev_designs_show_upc(){
        global $product;
        echo '<div class="upc_under_title">UPC:' . $product->get_meta( '_wpm_gtin_code' ) . '</div>';
    }

    Again, thank you so much for your help!

    Plugin Author Emanuela Castorina

    (@kreamweb)

    You are welcome!
    I’ll add the custom meta name inside the FAQ!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display the field using functions.php’ is closed to new replies.