Support

Account

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

  • Hi!

    For example

    1. Create an ACF field (price_per_kilo) for Product.

    2. In Woo template use something like this

    
    global $product;
    
    $price = $product->get_price();
    
    $weight = $product->get_weight();
    
    $id = $product->get_id();
    
    $value = 1000 * $price / $weight;
    
    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