I'd like to hook into the subscription plugin when a new order has been placed which I have done successfully using this action:
woocommerce_checkout_subscription_created
. Inside the function for that action I want to modify the email that goes out to the customer which I have tried to do like so:
<?php
function subscription_created($subscription){
add_action('woocommerce_email_before_order_table','my_offer',20);
$order = $subscription->order;
function my_offer($order){
echo "<h2>Your Trial Offer</h2>";
echo "<p>Your subscription to this product entitles you to a free blah blah blah...</p>";
}
return $var;
}
add_action('woocommerce_checkout_subscription_created','subscription_created');
?>
Like I said, the action for the created subscription fires (I logged the output for $subscription
successfully). The email action isn't working.
I'm guessing this has something to do with scope, but I'm not sure. Any thoughts would be appreciated.