When a customer has bought an item, WooCommerce
automatically sends an email on order status 'complete'. I'm trying to add an image and a link of the purchased product to this email template. The email template is stored as the file customer-completed-order.php
.
However, when the test email arrives in my email account, it shows a broken image. I'm not sure what to query to get the permalink for the purchased products, either. I saw this post, which states many (all?) properties for the order object, but not what I'm looking for (I think).
This is the code from my email template:
<?php
$order = $order->get_id();
foreach( $order->get_items() as $item_id => $item ) {
$product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
echo $product->get_image();
}