[Support request] SKU is not displayed correctly when using variants

Home Forums Support [Support request] SKU is not displayed correctly when using variants

Home Forums Support SKU is not displayed correctly when using variants

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1343349
    Sophia

    Hey!

    We have a webshop for medical products, and there it is very important to show the SKU for all products. As far as I could see, it is not shown by default, so I added this snippet:

    add_action('woocommerce_single_product_summary', 'display_product_sku_and_gtin');
    function display_product_sku_and_gtin() {
        global $product; 
    	if ($product->get_sku()){
    		echo 'Artikelnummer: ' .$product->get_sku();
    	}
    }
    

    This is working great for normal products, but when I have a page with variants (see this one: Link it always just shows the SKU of the main product (FG 001-1-1) instead of the one of the variants (e.g. for 010 it would be FG 001-G-010). Is there a way how I could set it up that for variants it is showing the variants-SKU?

    Thanks in advance!

    #1343508
    David
    Staff
    Customer Support

    Hi there,

    that would require woocommerce development which is out of our scope.
    I did find this stack:

    https://stackoverflow.com/a/60274464

    it explains the method of getting the varient SKU’s and points the Ajax and jQuery methods of updating them.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.