I would like to know if I can add custom shortcodes also to include custom fields.
Hi, this is howI created mine, hope this helps. Within woo-custom-emails/admin/class-wcemails-instance.php
Within the function convert_template I added:
$this->find[] = '{order_items}';
$this->replace[] = $this->get_the_order_items();
Then under function get_the_order_items I added:
function get_the_order_items() {
ob_start();
if ( $items = $this->object->get_items() ) {
foreach ( $items as $item ) {
echo "<br>".$item['name']." x ".$item['qty']." ";
}
}
return ob_get_clean();
}
So now I can add {order_items} to the email template which will list the order items & quantity like this:
Wet Paper Towel x 10
Soggey Weatbix x 6
I found this place useful to find the get function ie get_the_order_items().
-
This reply was modified 9 years, 7 months ago by
nicko619.
-
This reply was modified 9 years, 7 months ago by
nicko619.
Hello,
You can use this filters wcemails_find_placeholders & wcemails_replace_placeholders to add your content or replace the content in current placeholders.
Here is the line where you can see the arguments Find Array, Replace Array, Order Object ->
https://github.com/wp3sixty/woo-custom-emails/blob/master/admin/class-wcemails-instance.php#L206
Hello Mehul Kaklotar,
Can you please give an example on how we can implement get_formatted_billing_address as shortcode?
-
This reply was modified 9 years, 5 months ago by
Antonis1982.
Hi,
is it possible to only have the email trigger manually?
meaning that it wont fire on any order status change, but rather when selected in the order actions meta box.
also, i have created my own custom order action, is it possible to hook the email send to that?
thanks
-
This reply was modified 9 years, 5 months ago by
kookookjew.
@azarentis
add_filter( 'wcemails_find_placeholders', 'wcemails_your_theme_find_formatted_billing_address' );
function wcemails_your_theme_find_formatted_billing_address( $find ) {
$find[] = '{formatted_billing_address}';
return $find;
}
add_filter( 'wcemails_replace_placeholders', 'wcemails_your_theme_replace_formatted_billing_address', 10, 2 );
function wcemails_your_theme_replace_formatted_billing_address( $replace, $order ) {
$formatted_billing_address = $order->get_formatted_billing_address();
$replace[] = $formatted_billing_address;
return $replace;
}
@kookookjew
That is a good suggestion to include in the release. I will try to add this feature in to next release.