סל קניות -שיציגו את המחיר של המבצע +המחיר הרגיל
Wed Jun 26 2024 10:09:02 GMT+0000 (Coordinated Universal Time)
Saved by
@odesign
add_filter('woocommerce_get_price_html', 'custom_sale_price_html', 10, 2);
function custom_sale_price_html($price, $product) {
if ($product->is_on_sale()) {
$regular_price = wc_get_price_to_display($product, array('price' => $product->get_regular_price()));
$sale_price = wc_get_price_to_display($product, array('price' => $product->get_sale_price()));
$price = '<del>' . wc_price($regular_price) . '</del> <ins>' . wc_price($sale_price) . '</ins>';
}
return $price;
}
או את הקוד הזה
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'];
/**
* @var $_product WC_Product
*/
$regular_price = $_product->get_regular_price() * $cart_item['quantity'];
$_price = $_product->get_price() * $cart_item['quantity'];
//Check if sale price is not empty
if ( $_product->is_on_sale( 'view' ) && $regular_price>0 && $regular_price>$_price ) {
//Get regular price of all quantities
//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;
}
content_copyCOPY
Comments