gpt4 book ai didi

foreach - Smarty 嵌套 for-each 与数组

转载 作者:行者123 更新时间:2023-12-01 21:24:16 25 4
gpt4 key购买 nike

我在智能 for-each 循环方面遇到了一些麻烦 - 这是我的代码:

{* this example will print out all the values of the $custid array *}
{foreach from=$order_info item=amount}
amount: {$amount}<br>
{/foreach}

所以基本上我只是想循环并打印 $order_info 中的“金额” - 问题是,它只是打印整个数组,而不仅仅是“金额”。

这是我从调试控制台获得的数组中减少的项目数量:

{$order_info}   Array (86)
order_id => "13"
is_parent_order => "N"
parent_order_id => "0"
company_id => "0"
user_id => "1"
total => "1077.87"
subtotal => "1049.87"
discount => "0.00"
subtotal_discount => "0.00"
payment_surcharge => "0.00"
shipping_ids => "1"
shipping_cost => "28.00"
timestamp => "1352380055"
status => "O"
notes => ""
details => ""
promotions => Array (0)
promotion_ids => ""
title => ""
firstname => "John"
lastname => "Doe"
company => ""
b_title => ""
b_firstname => "John"
b_lastname => "Doe"
b_address => "44 Main street"
b_address_2 => "test"
b_city => "Boston"
b_county => ""
b_state => "MA"
b_country => "US"
b_zipcode => "02134"
b_phone => ""
s_title => ""
s_firstname => "John"
s_lastname => "Doe"
s_address => "44 Main street"
s_address_2 => "test"
s_city => "Boston"
s_county => ""
s_state => "MA"
s_country => "US"
s_zipcode => "02134"
s_phone => ""
phone => ""
fax => ""
url => ""
email => "joe@burford.co.uk"
payment_id => "3"
tax_exempt => "N"
lang_code => "EN"
ip_address => "62.49.144.33"
repaid => "0"
validation_code => ""
localization_id => "0"
payment_method => Array (15)
payment_id => "3"
usergroup_ids => "0"
position => "30"
status => "A"
template => "check.tpl"
processor_id => "0"
params => ""
a_surcharge => "0.000"
p_surcharge => "0.000"
localization => ""
payment => "Check"
description => "Check payment"
instructions => "Type instructions to pay by visiting ..."
lang_code => "EN"
processor => ""
fields => Array (0)
items => Array (2)
2902390881 => Array (19)
item_id => "2902390881"
order_id => "13"
product_id => "1110"
product_code => "B0002I9OJS"
price => "549.99"
amount => "1"
extra => Array (9)
step => "1"
product_options => Array (0)
unlimited_download => "N"
product => "eMachines T2958 Desktop PC (2.66 GHz ..."
company_id => "0"
is_edp => "N"
edp_shipping => "N"
base_price => "549.99"
stored_price => "N"
product => "eMachines T2958 Desktop PC (2.66 GHz ..."
deleted_product => ""
discount => "0"
company_id => "0"
base_price => "549.99"
original_price => "549.99"
cart_id => "2902390881"
tax_value => "0"
subtotal => "549.99"
display_subtotal => "549.99"
shipped_amount => "0"
shipment_amount => "1"
2278796194 => Array (19)
item_id => "2278796194"
order_id => "13"
product_id => "1120"
product_code => "B00086HZJA"
price => "499.88"
amount => "1"
extra => Array (9)
step => "1"
product_options => Array (0)
unlimited_download => "N"
product => "HP Pavilion a1000n Desktop PC (Intel ..."
company_id => "0"
is_edp => "N"
edp_shipping => "N"
base_price => "499.88"
stored_price => "N"
product => "HP Pavilion a1000n Desktop PC (Intel ..."
deleted_product => ""
discount => "0"
company_id => "0"
base_price => "499.88"
original_price => "499.88"
cart_id => "2278796194"
tax_value => "0"
subtotal => "499.88"
display_subtotal => "499.88"
shipped_amount => "0"
shipment_amount => "1"

所以我真正想做的是从$order_info内的items获取amount - 我尝试了$order_info.items但是这导致网站崩溃。

非常感谢任何想法。

最佳答案

这解决了它:

{foreach from=$order_info.items item=foo} 
{$foo.product_id}
{/foreach}

关于foreach - Smarty 嵌套 for-each 与数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13290352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com