我希望在订单确认邮件中有更多可见的产品数量。
我添加了
<td style="padding:0.6em 0.4em; font-weight: bold; text-align:center;"><big><big>'.(int)$product['product_quantity'].'</big></big></td>
在mailalerts.php里面
但我想优化它。
我想根据其值更改单元格内的文本颜色。
如果数字为1则应为黄色 如果数字> 1,则应为红色 我找到了这段代码,但我无法在我的文件中使用它,谢谢
$('#mytable tr td').each(function(){
if($(this).text() > 1)$(this).css('background-color','red');
});
感谢
答案 0 :(得分:0)
您可以使用ternary conditional连接内联设置此内容:
<td style="padding:0.6em 0.4em; text-align:center;' . ((int)$product['product_quantity'] == 1 ? "text-color: yellow;" : "text-color: red;") . '"><big><big>'.(int)$product['product_quantity'].'</big></big></td>
希望它有所帮助。