Woocommerce Email with product name ( shortcode )

TIKTIK

Member
Feb 1, 2020
57
17
8
I`m using Woocommerce email customizer drag and drop plugin. i want to add shortcode ( with the product name ) to my "order note emails" .. any idea?

I`m trying to use this snipped. but its not working.

if(isset($attr['type']) && $attr['type'] == 'pre-order-item'){
printf( __( "%s%s", 'wc-pre-orders' ), '<b> ' . $order->get_items() as $item ){ echo $item->get_name(); } . '', '</b>' );
}
 

frizzel

Well-known member
Trusted Uploader
Jun 13, 2019
485
253
63
Wherever my imagination takes me
You have an 'as' statement without a 'foreach'. Maybe try this:

PHP:
if(isset($attr['type']) && $attr['type'] == 'pre-order-item'){
$order_items = $order->get_items();
    foreach ($order_items as $item ) {
        printf( __( "%s%s", 'wc-pre-orders' ), '<b> ' . $item->get_name() . '', '</b>' );
    }
}

EDIT: Please note that I've changed $items to $item
 
Last edited:
  • Love
Reactions: TIKTIK

TIKTIK

Member
Feb 1, 2020
57
17
8
You have an 'as' statement without a 'foreach'. Maybe try this:

PHP:
if(isset($attr['type']) && $attr['type'] == 'pre-order-item'){
$order_items = $order->get_items();
    foreach ($order_items as $item ) {
        printf( __( "%s%s", 'wc-pre-orders' ), '<b> ' . $item->get_name() . '', '</b>' );
    }
}
Thank you for your reply !

its not working :(
there is an error in the code that you wrote ..
 

TIKTIK

Member
Feb 1, 2020
57
17
8
You have an 'as' statement without a 'foreach'. Maybe try this:

PHP:
if(isset($attr['type']) && $attr['type'] == 'pre-order-item'){
$order_items = $order->get_items();
    foreach ($order_items as $item ) {
        printf( __( "%s%s", 'wc-pre-orders' ), '<b> ' . $item->get_name() . '', '</b>' );
    }
}

EDIT: Please note that I've changed $items to $item
Now its working llike a charm !!!
@frizzel you saved me !
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu