【发布时间】:2020-11-30 23:08:53
【问题描述】:
我想在订单汇总和结账时显示高于正常价格的产品折扣。
我正在使用“WooCommerce: Display Product Discount in Order Summary @ Checkout”。但这显示在左侧(在正常价格之前)。
我希望它显示在顶部。所以我想显示高于正常价格的折扣。
/**
* @snippet WooCommerce: Display Product Discount in Order Summary @ Checkout, Cart
* @author Sandesh Jangam
* @donate $7 https://www.paypal.me/SandeshJangam/7
*/
add_filter( 'woocommerce_cart_item_subtotal', 'ts_show_product_discount_order_summary', 10, 3 );
function ts_show_product_discount_order_summary( $total, $cart_item, $cart_item_key ) {
//Get product object
$_product = $cart_item['data'];
//Check if sale price is not empty
if( '' !== $_product->get_sale_price() ) {
//Get regular price of all quantities
$regular_price = $_product->get_regular_price() * $cart_item['quantity'];
//Prepend the crossed out regular price to actual price
$total = '<span style="text-decoration: line-through; opacity: 0.5; padding-right: 5px;">' . wc_price( $regular_price ) . '</span>' . $total;
}
// Return the html
return $total;
}
【问题讨论】:
-
这是添加 CSS、显示块与内联的问题
-
谢谢。那么,我该怎么做呢?
-
显示你的页面链接。
标签: php css wordpress woocommerce checkout