Support » Plugin: YayMail - WooCommerce Email Customizer » Can’t get $email->id in Woocommerce hook

  • Resolved nartoof

    (@nartoof)


    Hi,

    I need to use the woocommerce_email_before_order_table hook to display some informations conditionnally.

    I usually do it like that :

    
    if ( $email->id == 'new_order' )
    {
    //Some action
    }
    

    With your plugin active, it returns :

    Warning: Attempt to read property "id" on string

    How to get the Email type on native Woocommerce hook like ‘woocommerce_email_before_order_table’ ?

    • This topic was modified 4 months, 1 week ago by nartoof.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support Bruce

    (@ninjateamwp)

    Hi @nartoof ,

    Thanks for coming today!

    Let me check this with the dev unit and get back to you as soon as possible.

    Kind regards,
    Bruce

    Rose

    (@rosewp)

    Hi @nartoof,

    Thanks for your patience.
    Would you mind sharing a few details on where do you use that hook?

    All the best,
    Rose

    Thread Starter nartoof

    (@nartoof)

    Hi,

    Thank you for your answer.

    I usually add some informations on the Woocommerce Emails like that :

    function IL_custom_infos_before_table_woocommerce_emails($order, $sent_to_admin, $plain_text, $email)
    {
    	if ( $email->id == 'customer_processing_order' || $email->id == 'customer_completed_order' )
    	{
    		$order_id = $order->get_id();
    
    		$output = '';
    
    		if( metadata_exists('post', $order_id , 'delivery_date') && get_post_meta( $order_id, 'delivery_date', true) != "" )
    		{
    			$output.= 'Date de livraison : <strong>' . date('d/m/Y' , strtotime( get_post_meta( $order_id, 'delivery_date', true ) ) ) . '</strong><br />';
    		}
    		
    		//Etc...
    		
    		echo '<p>' . $output . '</p>';
    	}
    }
    add_action('woocommerce_email_before_order_table', 'IL_custom_infos_before_table_woocommerce_emails',20,4);

    That’s the first time I have to use your plugin and like I said, $email->id does not return expected value.

    Maybe you will answer I can display custom order meta data with a shortcode ?
    But the point is I sometimes need to display some text and the value only if there the value is != ” or if the meta got a specific value…

    Do you have any advice to make the native hook work with your plugin ?

    Thank you.

    Rose

    (@rosewp)

    Hi @nartoof,

    May I know where did they put that code? Is it in the theme’s functions.php file?

    All the best,
    Rose

    Thread Starter nartoof

    (@nartoof)

    In the functions.php from the Child Theme šŸ˜‰

    Harry

    (@harrywpsp)

    Hi @nartoof,

    We have good news for you.
    The fix will be updated in the next release.

    Kind regards,
    Harry

    Thread Starter nartoof

    (@nartoof)

    Hi,

    Thanks you vert much for your help.

    Have a nice day.

    Harry

    (@harrywpsp)

    Hi @nartoof,

    Thanks for replying to us.
    We are glad to help you. Can you spend time reviewing our plugin by following the link below? That could be motivation so we can help you better.
    https://wordpress.org/plugins/yaymail/#reviews

    You have a good day, too.

    Kind regards,
    Harry

    • This reply was modified 4 months ago by Harry.

    Hi @nartoof,

    We have good news for you.
    The new update has been released.
    You can check it now and let me know if it works for you.
    Have a nice day!

    Kind regards,
    Harry

    • This reply was modified 3 months, 4 weeks ago by Harry.
    Thread Starter nartoof

    (@nartoof)

    Hi,

    I did some tests and it’s now working very well.

    Thank’s for the update.

    Have a great day.

    Hi @nartoof,

    Glad to hear that.
    If it’s possible, can you leave the plugin a review? https://wordpress.org/plugins/yaymail/#reviews
    Your review will motivate us to develop more works and have an awesome users like you.

    Kind regards,
    Harry

    • This reply was modified 3 months, 3 weeks ago by Harry.
    Thread Starter nartoof

    (@nartoof)

    Done šŸ™‚

    Hi @nartoof,

    You are always welcome.

    Kind regards,
    Harry

    • This reply was modified 3 months, 3 weeks ago by Harry.
Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.