How do I define a WooCommerce action using WordPress Custom Fields?

160
December 11, 2019, at 10:40 PM

Consider:

I am looking to hide woocommerce product page meta (SKU, categories and tags) but for specific products only.

I am defining which pages need this meta data hidden by adding to them a '1' within a wordpress custom field I've added called 'hide_product_meta'.

Here is the code I have put together, but it is applying to products globally instead of only the products I define with the custom field:

/** WooCommerce hide product page meta - hide_product_meta **/
function hide_product_page_meta() {
        global $post;
        $product_id = $post->ID;
        $HideProductMetaValue =  get_post_meta($product_id,'hide_product_meta',true);
        if (strpos(!$HideProductMetaValue, '1') === true) {
        return remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
        }
}       
add_action('woocommerce_single_product_summary','hide_product_page_meta');

What do I need to tweak in the code for this to work?

Rent Charter Buses Company
READ ALSO
Uploading files to remote file server (PHP)

Uploading files to remote file server (PHP)

There seems to be similar questions to this on here, but I have not found my situation exactly so I thought I'd try and ask

124
Sending PHP Post request with Complex Array in JSON

Sending PHP Post request with Complex Array in JSON

I'm trying to send the following body using CURL, but I'm not getting an error in returnI tried sending the same using POSTMAN and it worked fine

138
why can't I access session in tree view using php?

why can't I access session in tree view using php?

I'm having a tree view and a login system

127
session_regenerate_id() doesn't create session on multiple requests

session_regenerate_id() doesn't create session on multiple requests

We are regenerating session on each request in our applicationWhen I click on menu for each request it creates new session and session file in \tmp folder

153