Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Last active October 7, 2020 13:14
Show Gist options
  • Save jessepearson/701386d8ca5e4c84fc7cdf3d5d5391a3 to your computer and use it in GitHub Desktop.
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
<?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 );
@caballe
Copy link

caballe commented Oct 7, 2020

Hi,

Your code not longer works, $product variable is empty .
woocommerce Version 4.5.2

regards
Salvador

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment