最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin0浏览0评论

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' ); 
发布评论

评论列表(0)

  1. 暂无评论