我想在prestashop的确认邮件中发送“每箱数量”定制功能。在订购确认邮件中发送产品定制功能
下面是一个例子,如果我想要做
$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1));
foreach(from=$features item=feature)
{
if ($feature.name == "Units per box")
{
$UnitsPerBox = $feature.value|escape:'htmlall':'UTF-8';
}
}
不过,我需要一个PHP文件(PaymentModule.php
),而不是一个TPL文件中做到这一点,这样的代码将无法正常工作。 如果任何人都可以指出我如何实现这一点与PHP的正确方向,将不胜感激。
编辑:
我以前提供的示例代码,这似乎获得阵列内,但是当我运行一些测试代码,这样
$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1);
$UnitsPerBox .= '100';
foreach ($features as $feature)
{
$UnitsPerBox .= '200';
if ($feature->name == 'Units Per Box')
{
$UnitsPerBox .= htmlentities($feature->value, 'ENT_QUOTES', 'UTF-8');
$UnitsPerBox .= $feature->name;
}
else
{
$UnitsPerBox .= $feature->name;
$UnitsPerBox .= htmlentities($feature->name, 'ENT_QUOTES', 'UTF-8');
$UnitsPerBox .= htmlentities($feature->value, 'ENT_QUOTES', 'UTF-8');
}
}
我不返回任何值
得到这个输出:“100200200200200200”
任何帮助将是伟大的,谢谢。
感谢, 安德鲁
编辑:解
明白了到底的工作,感谢您的帮助
$myprod = new Product($product['id_product']);
$features = $myprod->getFrontFeatures(1);
foreach ($features as $feature)
{
foreach ($feature as $key => $value)
{
if($value == "Units per box")
{
$UnitsPerBox = $feature['value'];
}
}
}
你'foreach'循环之前,'的var_dump($功能)',看看哪些对象的数组实际上包含。好像它没有你期望的那样。另外,'$ UnitsPerBox'开始为“100”,并且您在循环中使用'。='运算符来保持附加“200”。你可能只想要'='。 – 2011-05-18 12:51:43
谢谢。数组内部有更多的数组,这是我试图获得的那些数组。 – 2011-05-18 13:47:52