• Resolved Jenny

    (@miss-newyork)


    Hi there,

    I am working on a little project for my mom, a sort of personal recipe database that is able to display the cost of a recipe as well. I haven’t been able to find a plugin that is able to do that so I thought I try and add it to this one 😉

    I have added the additional information of “cost” to the ingredients taxonomy, it’s saving and displaying correctly, so far so good.
    However I have no experience with doing maths in PHP so I seem to be a bit stuck there. I was hoping to do a basic “amount * base cost” calculation, but it doesn’t seem to be as straight forward.
    For example: a recipe calls for 40 g of butter, the cost is 0,0056 € per gramm, so it should say 0,0056 * 40 = 0,22 €, but every single calculation ends up being ‘0’.
    This is what I am using for the calculation:

    $price = get_term_meta( $term->term_id, ‘cost’, true ) * $ingredient[‘amount’];

    I’d appreciate any help on this!
    Thanks,
    Jenny

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Adding cost to ingredients’ is closed to new replies.