douluo6626 2014-05-01 20:43
浏览 43
已采纳

注意:未定义的索引:值为

I'm trying to change a payment extension of Opencart 1.6.5.1.

What I want to do is show the option value in the PagSeguro system, this extension makes the connection between Opencart and PagSeguro

The code I want to edit is inside of this:

/*
   * 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)
     );

What I want to edit is this:

        foreach ($this->cart->getProducts() as $product) {
        $options_names = '';

        foreach ($product['option'] as $option) {
             $options_names .= ' / '.$option['name'].;
        }

Then in pagseguro shows like this: Model Name / Product Name / Option Name

but I want to edit like this:

        foreach ($this->cart->getProducts() as $product) {
        $options_names = '';

        foreach ($product['option'] as $option) {
             $options_names .= ' / '.$option['name'].': '.$option['value'];
        }

to show in pagseguro like this: Model Name / Product Name / Option Name: Option Value

But when I do this I get the foLlowing error:

Notice: Undefined index: value in /home/storage/3/ec/a1/portalbigtrails/public_html/store/catalog/controller/payment/pagseguro.php on line 108Notice: Undefined index: value in /home/storage/3/ec/a1/portalbigtrails/public_html/store/catalog/controller/payment/pagseguro.php on line 108

What I'm doing wrong and how can I solve this?

  • 写回答

1条回答 默认 最新

  • drh37116 2014-05-02 00:51
    关注

    there is several types of options, but in almost all i think what do you want isn't this index, if you dump this option var you will find that the 'value' index, is 'option_value' $option['option_value'].

    Didactically, try dump the var, if you are not using a debugger, do:

    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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!