• Resolved nititek

    (@nititek)


    Hi,
    Thanks for the plugin… works really well for me. I need a small info. When the user inputs the address, the plugin does calculate the fee well. I just want to roundn off the fee to the nearest integer so the user sees a rounded off price. Eg when the price calculated is 170.12, I want to display 170. Is there a way to do this ? I did try the adding filter method in the functions.php. Am I doing something wrong ?

    add_filter( ‘dbf_calculated_fee’, ‘my_dbf_calculated_fee_callback’, 1, 15 );

    function my_dbf_calculated_fee_callback( $calculatedFee, $kiloMeters, $divider, $price ) {

    return round($calculatedFee);
    }

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gaylord Focker

    (@webdata)

    Hi,

    Try:

    function my_dbf_calculated_fee_callback( $calculatedFee, $kiloMeters, $divider, $price ) {
       return round($calculatedFee);
    }
    add_filter( ‘dbf_calculated_fee’, ‘my_dbf_calculated_fee_callback’, 10, 4 );

    Kim

    Thread Starter nititek

    (@nititek)

    Hi Kim, Thanks for your response. Still doesnt work and it shows decimals… I used exactly your code.
    I cleared cache, I also used a default theme.

    Could you help me out pls ?

    Thanks

    Plugin Author Gaylord Focker

    (@webdata)

    Are you using taxes for the fee? You can either disable taxes for the fee completely, or change settings at the WooCommerce to show taxes separately at the checkout. Otherwise taxes will be added to on top of the rounded fee. E.g. rounded fee 10.00 + tax 2.40 = 12.40.

    Kim

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rounding off Fee’ is closed to new replies.