I have added a progressive pricing based on the quantity of each cart item. What I am struggling with, is to reflect the $default_price
from the product (instead the now manually added price) and also to set the layout of the new price like this (default_price has strikethrough):
Image may be NSFW.
Clik here to view.
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price', 20, 1);function add_custom_price( $cart ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; foreach ( $cart->get_cart() as $item ) { $quantity = $item['quantity']; $discount_price = 0.008333333333; $default_price = 4.25; $minimum = 10; $maximum = 100; if( $quantity > $minimum ) { if( $quantity > $maximum ) { $new_price = $default_price - ($discount_price * ($maximum - $minimum)); } else { $new_price = $default_price - ($discount_price * ($quantity - $minimum)); } $item['data']->set_price( '<del>' . $default_price . '</del> <strong>' . $new_price . '</strong>'); } }}
The coded $item['data']->set_price( '<del>' . $default_price . '</del> <strong>' . $new_price . '</strong>');
is wrong, but how do I reflect this so it can accept the html elements?