Created
January 20, 2022 05:06
-
-
Save marcusig/442931da8b049a4a2822c264beca12e5 to your computer and use it in GitHub Desktop.
Add the configuration image to the order received item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display the product thumbnail in order received page | |
*/ | |
function order_received_item_thumbnail_image( $item_name, $item, $is_visible ) { | |
// Targeting order received page only | |
if( ! is_wc_endpoint_url('order-received') ) return $item_name; | |
// Get the WC_Product object (from order item) | |
$product = $item->get_product(); | |
if ( $image = apply_filters( 'woocommerce_order_item_thumbnail', $product->get_image(), $item ) ) { | |
$product_image = '<span>' . $image . '</span>'; | |
$item_name = $product_image . $item_name; | |
} | |
return $item_name; | |
} | |
add_filter( 'woocommerce_order_item_name', 'order_received_item_thumbnail_image', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment