Php 注意:未定义索引:中的值
我正在尝试更改Opencart 1.6.5.1的付款扩展 我想做的是在PagSeguro系统中显示选项值,这个扩展在Opencart和PagSeguro之间建立连接 我要编辑的代码位于以下内容中:Php 注意:未定义索引:中的值,php,magento,paypal,opencart,Php,Magento,Paypal,Opencart,我正在尝试更改Opencart 1.6.5.1的付款扩展 我想做的是在PagSeguro系统中显示选项值,这个扩展在Opencart和PagSeguro之间建立连接 我要编辑的代码位于以下内容中: /* * Produtos */ foreach ($this->cart->getProducts() as $product) { $options_names = ''; foreach ($product['option'] as $opt
/*
* Produtos
*/
foreach ($this->cart->getProducts() as $product) {
$options_names = '';
foreach ($product['option'] as $option) {
$options_names .= '/'.$option['name'];
}
// limite de 100 caracteres para a descrição do produto
if($mb_substr){
$description = mb_substr($product['model'].' / '.$product['name'].$options_names, 0, 100, 'UTF-8');
}
else{
$description = utf8_encode(substr(utf8_decode($product['model'].' / '.$product['name'].$options_names), 0, 100));
}
$item = Array(
'id' => $product['product_id'],
'description' => $description,
'quantity' => $product['quantity'],
'amount' => $this->currency->format($product['price'], $order_info['currency_code'], false, false)
);
我要编辑的是:
foreach ($this->cart->getProducts() as $product) {
$options_names = '';
foreach ($product['option'] as $option) {
$options_names .= ' / '.$option['name'].;
}
然后在pagseguro的节目中:
型号名称/产品名称/选项名称
但我想这样编辑:
foreach ($this->cart->getProducts() as $product) {
$options_names = '';
foreach ($product['option'] as $option) {
$options_names .= ' / '.$option['name'].': '.$option['value'];
}
要在pagseguro中显示如下内容:
型号名称/产品名称/选项名称:选项值
但当我这样做时,我会得到以下错误:
注意:未定义索引:第108行/home/storage/3/ec/a1/portalbigtrails/public_html/store/catalog/controller/payment/pagseguro.php中的值注意:第108行/home/storage/3/ec/a1/portalbigtrails/public_html/store/catalog/controller/payment/pagseguro.php中的未定义索引:值
我做错了什么以及如何解决这个问题?有几种类型的选项,但在几乎所有我认为你想要的不是这个索引,如果你转储这个选项变量,你会发现“值”索引是“选项值”
$option['option\u value']
按照教学方法,尝试转储var,如果您没有使用调试器,请执行以下操作:
var_dump($option); // this will print in a structured way, all values of this array;
exit; // this prevent the rest of code to be executed;
这意味着foreach循环中的
$选项
数组没有“value”键。在其他php文件中,有这样一个代码:-:
:在opencart商店中,最常见的选项是“大小”,然后值可以是“s,M,L,XL,XXL”,我知道存在“值键,但我不知道为什么这个键听起来好像在这个php文件中不存在