How to complete this math?
-
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 / quantityThe 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
- The topic ‘How to complete this math?’ is closed to new replies.