Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'woocommerce_cart_subtotal', 'bbloomer_slash_cart_subtotal_if_discount', 99, 3 );
- function bbloomer_slash_cart_subtotal_if_discount( $cart_subtotal, $compound, $obj ){
- global $woocommerce;
- if ( WC()->cart->total > 0 ) {
- $new_cart_subtotal = wc_price( WC()->cart->subtotal - $woocommerce->cart->get_cart_discount_tax_total() - $woocommerce->cart->get_cart_discount_total() );
- $cart_subtotal = sprintf( '<del>%s</del> <b>%s</b>', $cart_subtotal , $new_cart_subtotal );
- }
- return $cart_subtotal;
- }
- //add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
- function woocommerce_custom_surcharge() {
- global $woocommerce;
- if ( is_admin() && ! defined( 'DOING_AJAX' ) )
- return;
- $percentage = 0.01;
- $surcharge = $woocommerce->cart->cart_contents_total-$woocommerce->cart->get_cart_discount_tax_total();
- $woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
- }
- function prefix_add_discount_line( $cart ) {
- $discount = $cart->subtotal - $cart_discount_tax_total - $cart_discount_total;
- $cart->add_fee( __( 'Down Payment', 'yourtext-domain' ) , -$discount );
- }
- add_action( 'woocommerce_cart_calculate_fees', 'prefix_add_discount_line' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement