我有一个带有一些PHP逻辑的刀片模板,如下所示:
<?php
$prevCatCode = null;
$catStyleCode = null;
$isSameCatCode = false;
?>
<h2>Products</h2>
<table class="productsTable" style="width:100%">
<thead>
<tr>
<th>Code</th>
<th>Qty</th>
<th>Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
@foreach($draftOrderProducts as $key => $draftOrderProduct)
<?php
$catStyleCode = $draftOrderProduct['cat_style_code'];
if ($prevCatCode !== null && $prevCatCode == $catStyleCode) {
$isSameCatCode = true;
} else {
$isSameCatCode = false;
}
$prevCatCode = $catStyleCode;
if (!$isSameCatCode || $key == 0) { ?>
<tr><td colspan="4"><b>{{ $catStyleCode }}</b> (Retail Price: {{ $draftOrderProduct['retail_price'] }})</td></tr>;
<?php } ?>
<tr>
<td>{{ $draftOrderProduct['code'] }}</td>
<td>{{ $draftOrderProduct['products_quantity'] }}</td>
<td>{{ money_format("%(#10n", $draftOrderProduct['products_price']) }} (Retail: {{money_format("%(#10n", $draftOrderProduct['retail_price'])}})</td>
<td>{{ money_format("%(#10n", $draftOrderProduct['final_price']) }}</td>
</tr>
@endforeach
我想知道我是否正在此刀片文件中正确使用PHP标记。知道那里有什么问题吗?
$data
会传递给模板,并具有$data['draftOrderProducts'] = $draftOrderProducts;