I'm working with the WooCommerce email-order-items.php
and email-order-details.php
template files. I'm trying to create some sort of 'if statement' that would replace item subtotal, total, and subtotal values with "TBD" (to be determined) if the value is equal to zero and then leave everything else as normal if the values are either negative or positive.
I've been trying to replace these lines in: wp-contents/themes/mytheme/woocommerce/emails/
'email-order-items.php': <?php echo $total['value']; ?>
'email-order-items.php': <?php echo $order->get_formatted_line_subtotal( $item ); ?>
For item subtotal
if($itemsubtotal == 0) {
$itemsubtotal = "TBD";
}
For total
if($total == 0) {
$total = "TBD";
}
For subtotal
if($subtotal == 0) {
$subtotal = "TBD";
}
EDIT Change this line
<td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
TO
<?php if($total['value'] != 0){ ?> <td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td> <?php } else { ?> <td class="td" style="text-align:left; <?php if ( $i === 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo "TBD"; ?></td> <?php } ?>
Similarly for other variables it can be done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.