前臺商品詳情都可以正常顯示屬性信息,但是打印訂單和后臺訂單查詢,都無法顯示屬性。
請幫忙解決。
___________________________________________________________________
order.php代碼
$goods_attr[] = explode(' ', trim($row['goods_attr'])); //將商品屬性拆分為一個數組
$goods_list[] = $row;
}
$attr = array();
$arr = array();
foreach ($goods_attr AS $index => $array_val)
{
foreach ($array_val AS $value)
{
$arr = explode(':', $value);//以 : 號將屬性拆開
$attr[$index][] = @array('name' => $arr[0], 'value' => $arr[1]);
}
}
$smarty->assign('goods_attr', $attr);
$smarty->assign('goods_list', $goods_list);
————————————————————————————————————————————
{
/* 取得訂單商品 */
$goods_list = order_goods($order_id);
foreach ($goods_list AS $key => $goods)
{
/* 計算屬性數 */
$attr = $goods['goods_attr'];
if ($attr == '')
{
$goods_list[$key]['rows'] = 1;
}
else
{
$goods_list[$key]['rows'] = count(explode(chr(13), $attr));
}
}
$smarty->assign('goods_list', $goods_list);
————————————————————————————————————————————
order_pritn.html代碼
<td><!-- 商品屬性 -->
<!-- {foreach key=key from=$goods_attr[$key] item=attr} -->
<!-- {if $attr.name} --> {$goods.attr_name}:{$goods.attr_value} <!-- {/if} -->
<!-- {/foreach} --> </td>
新聞熱點
疑難解答