1

I have added code and removed sku's from all product pages (not admin) and all went well. However I realised that if I click on Quick View on any product - the sku's are still there.

Can you please advise how to remove these

Thanks

<?php

function sv_remove_product_page_skus($enabled) {
    if (!is_admin() && is_product()) {
        return false;
    }
    return $enabled;
}
add_filter('wc_product_sku_enabled', 'sv_remove_product_page_skus');
5
  • Please provide more details. For example, please post the code which you have added and give some more details. – user3135691 Jun 10 '20 at 17:58
  • Thanks - the code I added is function sv_remove_product_page_skus( $enabled ) { if ( ! is_admin() && is_product() ) { return false; } return $enabled; } add_filter( 'wc_product_sku_enabled', 'sv_remove_product_page_skus' ); and the SKu's are no longer visible on the product page. However if I click on QUICK VIEW - the SKU's are still there. – victoria Jun 10 '20 at 18:05
  • And what plugin is this? – vancoder Jun 10 '20 at 18:15
  • I added the code in the child theme - not using a plugin Thanks – victoria Jun 10 '20 at 18:16
  • Welcome to WordPress Development. I hope you find the answer you need. Our site is different from most - if you have not done so yet, consider checking out the tour and help center to find out how things work. A quick tip for getting great answers: Many experts are busy people. Help them get to all the facts as soon as possible (without asking follow up questions) and you will get many more answers. Check our guide to asking good questions if you need to. – Matthew Brown aka Lord Matt Jun 11 '20 at 15:53
0

Please give this a try. I've modified your existing code to check whether it's a product or not. Let me know if it works.

function sv_remove_product_page_skus( $enabled ) {
   global $post;
   if ( ! is_admin() && get_post_type( $post->ID ) == 'product'  ) {
      return false; 
   } 
   return $enabled; 
} 
add_filter( 'wc_product_sku_enabled', 'sv_remove_product_page_skus' ); 
1
  • Thanks - sku's still visible in Quick View – victoria Jun 11 '20 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.