Last active
November 2, 2017 07:17
-
-
Save filipecsweb/21b3a9331a1754c29e06 to your computer and use it in GitHub Desktop.
Display Simple Product SKU, in WooCommerce loop pages, before item name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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