• Resolved sgarmash777

    (@sgarmash777)


    Hi!
    I use the following code to output a custom element from the admin part. I have a checkbox in the admin panel which, if selected, will display text. The code works everywhere but doesn’t work on the wishlist page. Help me to understand)

    Here is the code screen: https://prnt.sc/t4iscu
    Here I call the hook: https://prnt.sc/t4it1j

    Thanks regards, Sergey!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi there Sergey

    The problem is that you’re using global $post, that in the case of the wishlsit page is the Wishlist Page itself

    In our loop, we set global $product, that you should use for this purpose instead
    I cannot assure you that everywhere you placed your hook, global $product is defined, anyway, so here a quick change to your snippet of code

    function display_label_product() {
    	global $post, $product;
    
    	if( $product instanceof WC_Product ) {
    		if ( $product->get_meta( 'super_product', true ) ) {
    			echo 'something..';
    		}
    	} elseif( $post ) {
    		$post_id = $post->ID;
    		if ( get_post_meta( $post_id, 'super_product', true ) ) {
    			echo 'something..';
    		}
    	}
    }
    add_action( 'bages_new_label', 'display_label_product' );
    
    Thread Starter sgarmash777

    (@sgarmash777)

    Thanks, it works!)

    Plugin Author YITHEMES

    (@yithemes)

    You’re welcome!

    We are doing our best to improve our plugins. Our target is to develop and release the best free plugins for WooCommerce, but to achieve this we need your help. Please leave a good review to support us and help our growth ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom text wishlist page’ is closed to new replies.