【问题标题】:Notice: Undefined index: value in注意:未定义的索引:值在
【发布时间】:2014-06-18 10:30:21
【问题描述】:

我正在尝试更改 Opencart 1.6.5.1 的付款扩展。

我要做的是在 PagSeguro 系统中显示选项值,这个扩展在 Opencart 和 PagSeguro 之间建立了联系

我要编辑的代码在这个里面:

/*
   * 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 中显示: 型号名称/产品名称/选项名称:选项值

但是当我这样做时,我得到以下错误:

注意:未定义索引:/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 第 108 行

我做错了什么,我该如何解决?

【问题讨论】:

  • 这意味着您的 foreach 循环中的 $option 数组没有“值”键。是什么让你觉得它在那里?
  • 在其他php的文件中有这样的代码:
      - php echo $option['name']; ?>:
     :
  • 在 opencart 商店中,最常见的选项是“大小”,然后值可以是“S、M、L、XL、XXL” 我知道存在“值键但我不知道为什么此 php 文件中不存在此键的声音

标签: php magento paypal opencart


【解决方案1】:

有几种类型的选项,但几乎所有我认为你想要的不是这个索引,如果你转储这个选项 var,你会发现'value'索引是'option_value'$option['option_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;

【讨论】:

    猜你喜欢
    • 2015-06-02
    • 2015-12-01
    • 2013-11-27
    • 2021-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-29
    相关资源
    最近更新 更多