D
D
Dmitry2016-09-20 08:32:45
PHP
Dmitry, 2016-09-20 08:32:45

Why is woocommerce only returning the integer part of the size?

Hello everyone,
let's say I have a product with a width of 5.75 and a height of 15.45 and the following function:

$product = new WC_Product($id);

public function get_sizes($product) {
  $w_size = floatval($product->get_width());
  $h_size = floatval($product->get_height());

  $w_M = intval($w_size);
  $h_M = intval($h_size);
  $w_CM = $w_size - intval($w_size);
  $h_CM = $h_size - intval($h_size);

  return array($w_M, $h_M, $w_CM, $h_CM); 
}

But for some reason $product->get_width() and get_height() only return 5 and 15.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question