简体   繁体   中英

Woocommerce email template: Add Product Variation Weight to email

I would like to add the Product weight to each variable listed in a order but I'm stumbling through the php of Woocommerce, hence my appeal here.

I've customized WooCommerce to be a quote request system rather than an ordering system, and I want the variable unit weight (each variation of each industrial product has different weight) noted on the admin-new-order for each item so its highly visible for the individual putting together the customized quote including the customized intl shipping required for that individual order (as a lot of the industrial parts are very heavy and shipping, costly).

I have figured out that adding code to email-order-items.php is the way to go. But I don't know the code to pull the weight from the standard weight input field and display it as 'X kg per unit' after the variation information.

Notes: I have setup email templates under my child theme. I have weak experience with .php - hence this email to learn, but enough to add some snippets to functions.php so far

Cheers A

Hello you need to check in code there is many solution available for get code. if you have order it and item id then you get all the things from product object so plz try it so you get solution.

can you plz show in screen short so understood more.

Thanks

It took a while with my novice php skills, but here is the answer I have in place for the solution to my question:

if ( $item_meta->meta ) { echo '
' . nl2br( $_product->get_weight( 'weight') ) . " kg per unit" .''; }

This outputs the line 'x kg per unit' under the product variation output line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM