Replace N/A with custom text

Hi all.

I want to replace the ‘N/A’ next to SKU: in WooCommerce.

I achieved this previously using the meta.php file in themes - pro - woocommerce - single product data.

Since the last update this has been overridden. I have tried doing the same thing again but it is not displaying in the front end for some reason.

I have successfully replaced ‘sku’ with a Spanish translation using my theme editor - functions.php in the dashboard but I need to replace the n/a text highlighted in bold below when no variables are selected:

<?php esc_html_e( 'SKU:', 'woocommerce' ); ?> <?php echo ( $sku = $product->get_sku() ) ? $sku : esc_html__( **'n/a',** 'woocommerce' ); ?>

I’ve left the site details below - the site is in Spanish but you will see all of the edits I have made in functions.php

If there is an solution that allows me to use functions.php in the dashboard theme editor that would be great so it stops overriding the templates when necessary but either or will help. :slight_smile:

Hi J,

Thanks for reaching out.

Since you already replaced it that way. Then I recommend translating n/a the same way. Like this


            case 'SKU':
                $translation = 'Referencia:';
                break;
            case 'SKU:':
                $translation = 'Referencia:';
                break;
            case 'n/a':
                $translation = 'None';
                break;

Hope this helps.

Worked perfectly - thanks for the assistance there! Much appreciated

Glad we could help.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.