• Resolved karenelated

    (@karenelated)


    Hi

    Please help me remove the decimal places from the price next to the shopping cart.

    thanks
    Karen

    • This topic was modified 4 years, 10 months ago by karenelated.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi! You’ll need a small code snippet to accomplish this. I don’t know your particular settings (otherwise I could simplify this), but this should cover all scenarios:

    
    add_filter( 'woocommerce_cart_contents_total', 'woocommerce_cart_contents_total_no_decimals', 10, 1 );
    function woocommerce_cart_contents_total_no_decimals( $total ) {
    	$settings = get_option('wpmenucart');
    	if (isset($settings['total_price_type']) && $settings['total_price_type'] == 'subtotal') {
    		if ( WC()->cart->display_prices_including_tax() ) {
    			$amount = WC()->cart->get_subtotal() + WC()->cart->get_subtotal_tax();
    		} else {
    			$amount = WC()->cart->get_subtotal();
    		}
    	} else {
    		if ( WC()->cart->display_prices_including_tax() ) {
    			$amount = WC()->cart->get_cart_contents_total() + WC()->cart->get_fee_tax() + WC()->cart->get_cart_contents_tax();
    		} else {
    			$amount = WC()->cart->get_cart_contents_total();
    		}
    	}
    	return wc_price( $amount, array( 'decimals' => 0 ) );
    }
    

    If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters

Viewing 1 replies (of 1 total)
  • The topic ‘Remove decimals from price on WP shopping cart’ is closed to new replies.