我正在尝试在WooCommerce订单电子邮件中显示二手优惠券+添加描述。
显示优惠券的工作方式基于:Add Applied Coupon Code in Admin New Order Email Template - WooCommerce
我还尝试了这个:
$coupons = $order->get_items( 'coupon' );
foreach ( $coupons as $item_id => $item ) {
echo "<span class='coupon-name'><b>".$item['name']."</b></span>";
$post = get_post( $item_id );
echo "<p class='coupon-description'>".$post->post_excerpt."</p>";
}
}但却不起作用。有什么想法吗?
发布于 2020-06-24 01:30:23
使用以下内容从“优惠券”订单项目中获取优惠券说明:
// Loop through WC_Order_Item_Coupon Objects
foreach ( $order->get_items( 'coupon' ) as $item ) {
// Get the WC_Coupon Object
$coupon = new WC_Coupon($item->get_code());
// Display coupon description
echo "<p class='coupon-description'>".$coupon->get_description()."</p>";
}https://stackoverflow.com/questions/62540096
复制相似问题