• Resolved Azragh

    (@azragh)


    Hello, we have the problem with a customer’s shop that we cannot round off the prices in combination with your plugin. We have implemented the following function:

    
    add_filter( 'woocommerce_calculated_total', 'my_custom_roundoff' );
    function my_custom_roundoff( $total ) {
      $round_num = round($total / 0.05) * 0.05;
      $total = number_format($round_num, 2); // this is required for showing zero in the last decimal
      return $total;
    }

    If now on the checkout page a payment method is selected where charges apply, all payment methods disappear, except for Paypal and invoice. After the disappearance, Paypal is selected.

    If we deactivate the plugin (or don’t round the total), everything works. Now we would be extremely grateful for an appropriate update or assistance.

    Thank you =)

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    Hi,

    What’s your plugin setup? to which payment methods are added and how do you count the fee? I’m guessing, that you add a fee that is based on the total price and then you change it with rounding? Anything in the console throwing an error?

    You might as well check to add a later priority to the filter add_filter( 'woocommerce_calculated_total', 'my_custom_roundoff', 1001 );

    If not, could you spin up a tastewp.com site or another sandbox with simple WooCommerce and my plugin installed, reproduce the error (with Code Snippets) and invite me? I’ll have a look.

    P.S. I would guess that adding the rounding as a fee (+ or -) would be a better way to achieve a rounded price (and more clear from the accounting view).

    Best regards,
    Karolina

    Thread Starter Azragh

    (@azragh)

    Plugin Setup: Invoice Gateway For WooCommerce, Refer A Friend für WooCommerce,
    Search By SKU, VarkTech Pricing Deals, WooCommerce Google Analytics Integration, WooCommerce Google Feed Manager, WooCommerce PayPal Payments, WooCommerce UPC, EAN, and ISBN and WooCommerce wallee.

    Available Payment methods are Twint, Credit Card, PostFinance Card, PostFinance E-Finance, PayPal and Invoice. Yes our client charges a 2.4% fee on the total amount of the cart (but only for credit- and debit cards, Mastercard and PayPal). Console shows no errors or warnings. Later Priority added, but didn’t work.

    We tried to configure the plugin on the old shop of same client. There we get the error even without the rounding stuff (benke.ch/webalt). On this site we left it active as it’s only there for referencing old content atm so you could at least watch the behaviour.

    However, since the error on the new page exists only with the rounding function, and the customer would agree with rounding the fees alone, your suggestion would be a good solution.

    Can this be set in the plugin, or is there a special function for this?

    Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    Hi @azragh I think you could use this filter for this: https://github.com/vyskoczilova/woocommerce-payforpayment#filter-woocommerce_pay4pay_current_gateway_id_amount

    My fingers are crossed!
    Karolina

    Thread Starter Azragh

    (@azragh)

    Thanks for leading into the right direction!

    We got it to work with this one:

    
    function my_pay4pay_amount( $amount, $calculation_base, $current_payment_gateway, $taxable, $include_taxes, $tax_class ) {
      $round_num = round($amount / 0.05) * 0.05;
      $amount = number_format($round_num, 2);
      return $amount;
    }
    add_filter( "woocommerce_pay4pay_wallee_1_amount", 'my_pay4pay_amount' , 10 , 6 );
    add_filter( "woocommerce_pay4pay_ppcp-gateway_amount", 'my_pay4pay_amount' , 10 , 6 );
    

    The problem was caused by the plugin “wallee”, which registered his own names for credit card payments – “walle_1” replaces “cod” and so on.

    Plugin Author Karolina Vyskocilova

    (@vyskoczilova)

    Hi @azragh,

    I’m glad that you sorted it out ?? If you like my help and the plugin, I would really appreciate a review (and eventually a donation for development if it saves you money and time).

    Have a nice weekend!
    Karolina

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with rounding / calulated total filter’ is closed to new replies.