• Claudio

    (@cl4udio)


    Hi WooTeam!

    I need help to improve a code for make one shortcode for printing SKU variations from a variable product.

    Now, with this code, I only receive the main SKU:

    /* SKU Shortcode */
    function display_woo_sku() {
        if( ! is_admin() && ! is_product() ) return;
    
        global $post;
    
        // Get an instance of the WC_Product Object
        $product = wc_get_product( $post->ID );
        return $product->get_sku();
    }
    add_shortcode( 'woo_sku', 'display_woo_sku' );

    Thanks a lot!

    • This topic was modified 5 years ago by Claudio.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Generate shortcode for printing SKU variations from a variable product’ is closed to new replies.