Woocommerce Add to cart function showing error

Viewed 140

I am just using the below code. It was working fine but from today is shows error - "TypeError thrown wc_add_number_precision(): Argument #1 ($value) must be of type float, null given, called in /chroot/home/a23cc473/fdd76f6eaa.nxcli.net/html/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 1955". Here is my code - WC()->cart->add_to_cart( 5 )

Can anyone please advise me why this error is showing

1 Answers

It's related with newest WC core, go and edit wc->includes->wc-core-functions.php row 1918 and replace it with older function: new (not working) :

function wc_add_number_precision( float $value, bool $round = true ) {

old (working one) :

function wc_add_number_precision( $value, $round = true ) {

It's not best fix, but at least is working.

Related