I want to show only the first 5 digits of the composed SKU for products, here's the context:
Main product SKU: 12345 Variation SKU: 67890
SKU showed on product page: 12345-67890
I want to show only the first (main product) SKU number:
this is what I tried:
$sku = $product->get_sku();
$skunodash = substr($sku, 0, 5);
<span class="sku_wrapper"><?php esc_html_e( 'SKU :', 'woocommerce' ); ?> <span class="sku"><?php echo $skunodash ? $sku: esc_html__( 'N/A', 'woocommerce' ); ?></span></span>
I have also tried:
$skunodash = explode("-", $sku)
But nothing works, and just shows the whole SKU no matter what.
What am I doing wrong?
Thans in advance.