filters - How to remove SKU's from ALL products in Quick View - already remove from each product page

I have added code and removed sku's from all product pages (not admin) and all went well.However I realised that

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');

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');
Share Improve this question edited Jun 10, 2020 at 20:45 user3135691 1,0359 silver badges15 bronze badges asked Jun 10, 2020 at 17:46 victoriavictoria 111 bronze badge 5
  • Please provide more details. For example, please post the code which you have added and give some more details. – user3135691 Commented Jun 10, 2020 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 Commented Jun 10, 2020 at 18:05
  • And what plugin is this? – vancoder Commented Jun 10, 2020 at 18:15
  • I added the code in the child theme - not using a plugin Thanks – victoria Commented Jun 10, 2020 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 Commented Jun 11, 2020 at 15:53
Add a comment  | 

1 Answer 1

Reset to default 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' ); 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742359164a4429042.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信