Hi I am using Avada theme I created a child theme, I have woocommerce installed as well. I am having an issue where the sku number for the product won't display on the thumbnail and it wont display on the products page. It does not appear when I look at the item in the cart either. How can I fix this functionality to work in all three areas? The website I am having problem with is

Dani AI

Generated

Short summary and a reliable path forward.

already got two of three places working (cart and the loop). For a future-proof solution avoid accessing product properties directly (for example $product->sku) and use the official getter get_sku() on the WC_Product object instead — that is the supported API. (hooks.wbcomdesigns.com)
The shop loop and single-product templates expose action hooks you can use (woocommerce_after_shop_loop_item_title for archive/thumbnail output and woocommerce_single_product_summary on the single product page), so adding a small function to your child theme (or a snippets plugin) is the cleanest approach. (woocommerce.github.io)

When to add the single-product SKU and how to keep variable SKUs in sync

  • Add a small function hooked into woocommerce_single_product_summary (choose priority 6–25 to place it near the title/price area). Output the SKU with proper escaping (esc_html) so it’s safe and translatable.
  • For variable products, update that element when a variation is selected on the front end using the WooCommerce found_variation JS event — the variation object contains variation.sku, so the displayed SKU can update without a page reload. Example approach: inject a small placeholder element from PHP and use a tiny jQuery handler on found_variation to replace its text. (businessbloomer.com)

Troubleshooting and gotchas

  • If nothing appears on the single product page, the theme (or a page builder) may be using custom templates that skip the standard hooks — check your theme’s woocommerce folder or any content-single-product.php overrides. If so, either add the markup in the overridden template or re-insert the hook in the theme template. Use the child-theme route or a snippets plugin to keep changes upgrade-safe. (woocommerce.com)
  • For the cart/minicart, modern templates use the woocommerce_cart_item_name filter (the cart template applies that filter), so prefer that over older/deprecated filters if you maintain cart output. (woocommerce.github.io)

If needed, provide the exact PHP/JS snippets (child-theme safe, using $product->get_sku() and found_variation) and I’ll post them tailored to Avada and your child theme.

I got it showing up in the cart by adding

add_filter( 'woocommerce_in_cart_product_title', 'add_sku_in_cart', 20, 3);

function add_sku_in_cart( $title, $values, $cart_item_key ) {
  $sku = $values['data']->get_sku();
  return $sku ? $title . sprintf(" (SKU: %s)", $sku) : $title;
}

to my functions.php but still need to figure out the other two.

I fixed the thumbnail not displaying the sku number by adding this code to my themes functions.php file. I just need to figure out how to add code for the products single page and I am good to go!

add_action( 'woocommerce_after_shop_loop_item_title', 'shop_sku' );
function shop_sku(){
global $product;
echo '<span itemprop="productID">SKU: ' . $product->sku . '</span>';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.