Skip to content

Instantly share code, notes, and snippets.

@filipecsweb
Last active November 2, 2017 07:17
Show Gist options
  • Save filipecsweb/21b3a9331a1754c29e06 to your computer and use it in GitHub Desktop.
Save filipecsweb/21b3a9331a1754c29e06 to your computer and use it in GitHub Desktop.
Display Simple Product SKU, in WooCommerce loop pages, before item name
<?php
/**
* Display Simple Product SKU, in WooCommerce loop pages, before item name
*
* @return void
*/
function simple_product_sku_before_loop_item_title(){
global $product;
$type = $product->product_type;
$sku = $type == 'simple' ? ' (#' . $product->get_sku() . ')' : '';
echo $sku;
}
add_action('woocommerce_before_shop_loop_item_title', 'simple_product_sku_before_loop_item_title');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment