Question

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?

Was it helpful?

Solution

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;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top