• Hi
    In the invoice.php template of the plugin WooCommerce PDF Invoices & Packing Slips there are lines of code to display the quantity and the product price like below:

    <td class="quantity"><?php echo $item['quantity']; ?></td>
    <td class="price"><?php echo $item['order_price']; ?></td>

    However, I am using the Variable product options with Attributes to show two prices for a product.

    If the quantity is more than 1, the code <?php echo $item['order_price']; ?> will display the SUM price.

    Now, I would like to display the price (quantity as 1) beside the quantity.

    I am trying to do the math like this:
    price = order_price / quantity

    The code will look like this

    <td class=”quantity”><?php echo $item[‘quantity’]; ?> x <?php echo intdiv($item[‘order_price’], $item[‘quantity’]); ?> </td>

    <td class=”price”><?php echo $item[‘order_price’]; ?></td>

    But, I don’t know the PHP background so can’t make it work/correct.

    Could you please help?

    Thank you for your time
    Uyen

    • This topic was modified 2 years, 5 months ago by catuyen.
    • This topic was modified 2 years, 5 months ago by catuyen.
    • This topic was modified 2 years, 5 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to complete this math?’ is closed to new replies.