Last active
October 7, 2020 13:14
-
-
Save jessepearson/701386d8ca5e4c84fc7cdf3d5d5391a3 to your computer and use it in GitHub Desktop.
Adds the product link to low and out of stock emails in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // do not copy this line | |
/** | |
* Adds the product link to low and out of stock emails in WooCommerce | |
* @param string $message Message stating low/out of stock. | |
* @param object $product The product's object the email is for. | |
* @return string The modified email with the link to edit the product. | |
* | |
* @link https://wordpress.org/support/topic/admin-stock-notification-emails/ | |
* @link https://gist.github.com/jessepearson/701386d8ca5e4c84fc7cdf3d5d5391a3 | |
*/ | |
function jp_add_prod_url_to_stock_messages( $message, $product ) { | |
return $message ."<br>\n". get_edit_post_link( $product->get_id() ); | |
} | |
add_filter( 'woocommerce_email_content_low_stock', 'jp_add_prod_url_to_stock_messages', 10, 2 ); | |
add_filter( 'woocommerce_email_content_no_stock', 'jp_add_prod_url_to_stock_messages', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Your code not longer works, $product variable is empty .
woocommerce Version 4.5.2
regards
Salvador