Support

Account

Home Forums General Issues Automatic Calculation price per kilo Reply To: Automatic Calculation price per kilo

  • Ok, found, the code is:

    global $product;

    $price = $product->get_price();

    $weight = $product->get_weight();

    $id = $product->get_id();

    $value = number_format( 1000 * $price / $weight, 2 );

    update_field(‘price_per_kilo’, $value, $id); // this code updates data for this field

    the_field(‘price_per_kilo’, $product->$id ); //show price per kilo