Skip to content
Advertisement

A non well formed numeric value encountered while using wc_price WooCommerce hook

I have a simple function that used to work that I got online somewhere a few years back. It allows me to manually change the currency conversion rate for EUR (€, Euro).

Problem now is this:

JavaScript

Whereof the notice refers to this line:

JavaScript

This is what I need help fixing.

This is the complete code:

JavaScript

Advertisement

Answer

  • Since WooCommerce 3.2.0 the wc_price filter hook contains 4 params and even 5 from WooCommerce 5.0.0

  • The 2nd param $price, is a string. Hence the error message you get because you are doing calculations with it. The solution is to convert this to a float

So you get:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement