I have a big time trying to either convert a string into a integer or multiply two integers. I can’t convert the string into integer because it’s resulting me into a boolean (when I’m using var_dump). I can convert the other integer in string, but I’m unable to multiply it.
I have this:
<? $fees=$commerce->cart->get_total();
$payfee = str_replace(' €', '', $fees);
$payfee = str_replace(',','', $payfee); //this is the string
$fee = 0.025;
$paypal = $payfee * $fee; //this thing is not working
?>
I tried converting the payfee in integer, but still can’t make it work. I did something like this before and worked well, but not this time.
Any help will be appreciated.
P.S Thank you to the whole stackoverflow.com community which helped me many times before.
First of all, the problem here is that the
get_total()function responds with a string.The correct way to fix this string would be a simple example such as
However, according to the Woo Commerce API Documentation you should be able to use
$commerce->cart->totalto get a float of the number, so a solution that might also work (again, I know nothing about WooCommerce), would be the following:Edit
According to your latest data dump, the problem is that you’re using
where you should be using
as
->get_total()receives a string, and->totalreceives a float.