mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
13 lines
434 B
Text
13 lines
434 B
Text
function filter_woocommerce_cart_subtotal( $subtotal, $compound, $cart ) {
|
|
// Rounds a float
|
|
$round_num = round( $cart->subtotal / 0.05 ) * 0.05;
|
|
|
|
// Format a number with grouped thousands
|
|
$number_format = number_format( $round_num, 2 );
|
|
|
|
// Subtotal
|
|
$subtotal = wc_price( $number_format );
|
|
|
|
return $subtotal;
|
|
}
|
|
add_filter( 'woocommerce_cart_subtotal', 'filter_woocommerce_cart_subtotal', 10, 3 );
|