• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Woocommerce Email with product name ( shortcode )

TIKTIK

Member
Feb 1, 2020
84
26
18
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>' );
}
 
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
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 ..
 
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 !
 
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock