php - CodeIgniter Shopping Cart Class: How to retrieve independent values on an array? -


so have controller using codeigniter's shopping cart class on e-commerce website.

it's working fine. loads class, adds products cart, goes checkout , completes transaction. need retrieve information (such product name, id, price) when user @ checkout send mixpanel (which analytics tool).

i've added checkout controller code:

// sends subscription information mixpanel $this->mixpanel_wrapper->people_set($aluno[0]->aluno_id, array(         '$first_name'    =>    $student[0]->student_first_name,         '$last_name'     =>    $student[0]->student_last_name,         '$email'         =>    $student[0]->student_email,         )); $this->mixpanel_wrapper->identify($student[0]->student_id); $this->mixpanel_wrapper->track_something('added cart',  array ($this->cart->contents())); // ends mixpanel 

it works. in dashboard see specific user activated event "added cart". in properties of event see (the "property" number added automatically mixpanel:

property: 0 {"ee55c5260c7d5fe7fe9bc73b0e0cc82c":{"name":"product 1","price":"99.00","qty":"1","rowid":"ee55c5260c7d5fe7fe9bc73b0e0cc82c","id":"8","subtotal":99,"options":{"category":"business","teacher":"la gracia","image":"cozinhando.png","type":"course","description":"montar uma apresentação é como cozinhar. se você faz um “catadão” e coloca tudo na panela, sem ordem ou critério, sai uma gororoba. uma experiência saborosa exige cuidado e atenção na seleção e preparo dos ingredientes. nesse curso, aprenda"}},"1bebb39e8f44062ff10639f452ea8f8f":{"name":"product 2","price":"59.00","qty":"1","rowid":"1bebb39e8f44062ff10639f452ea8f8f","id":"7","subtotal":59,"options":{"category":"creativity","teacher":"pedro maciel guimarães","image":"cover_almodovar.png","type":"course","description":"conheça evolução das obras de almodóvar por duas matrizes únicas: imitação e o intercâmbio de gêneros. passando por suas comédias e dramas, veremos como almodóvar pensou e produziu seus diversos trabalhos, desde suas primeiras referências"}}} 

there 2 items on cart. "product 1" , "product 2". in fact should see this:

property: 0 name: product 1 price: 99.00 qty: 1 id: 8  property: 1 name: product 2 price: 59.00 qty: 1 id: 7 

what mixpanel needs convert array 1 set new user:

$this->mixpanel_wrapper->people_set($aluno[0]->aluno_id, array(     '$first_name'       => $aluno[0]->aluno_primeiro_nome,     '$last_name'        => $aluno[0]->aluno_sobrenome,     '$email'            => $aluno[0]->aluno_email, ));  

anybody knows how can retrieve specific data ci's shopping cart class? this:

$this->mixpanel_wrapper->track_something('user logged in', array(     'name'             => $this->cart->contents->name,     'product id'       => $this->cart->contents->id,     'price'            => $this->cart->contents->price,     'quantity'         => $this->cart->contents->qty, ));  

i think might simple, i'm stucked here (again).

it not different when display cart. loop through cart array, $this->cart->contents(), , handle each item.

foreach ($this->cart->contents() $item) {     $this->mixpanel_wrapper->track_something('user logged in', array(         'name'             => $item['name'],         'product id'       => $item['id'],         'price'            => $item['price'],         'quantity'         => $item['qty'],     )); } 

otherwise, loop through cart , create new array mixpanel can handle.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -