📜  在结帐时添加图像拇指 woo - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:41.109000             🧑  作者: Mango

代码示例1
/**
* @snippet       WooCommerce Show Product Image @ Order-Pay Page
*/

add_filter( 'woocommerce_order_item_name', 'ts_product_image_on_order_pay', 10, 3 );

function ts_product_image_on_order_pay( $name, $item, $extra ) {

/* Return if not checkout page */

if ( ! is_checkout() ) {

return $name;

}

$product_id = $item->get_product_id();

/* Get product object */

$_product = wc_get_product( $product_id );

/* Get product thumbnail */

$thumbnail = $_product->get_image();

/* Add wrapper to image and add some css */

$image = '
' . $thumbnail . '
'; /* Prepend image to name and return it */ return $image . $name; }