1
所以我有这个控制器在电子商务网站上使用CodeIgniter的购物车类。CodeIgniter购物车类:如何检索数组上的独立值?
它工作正常。它加载课程,将产品添加到购物车,结帐并完成交易。但是,当用户在结帐时,我需要检索一些信息(例如产品名称,ID,价格)以将其发送到Mixpanel
(这是一个分析工具)。
我已经添加到我的结账控制器验证码:
// Sends subscription information to 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 to cart', array ($this->cart->contents()));
// Ends mixpanel
它的工作原理。在我的仪表板中,我看到特定用户激活了“添加到购物车”事件。但在这个事件中,我看到这样的事情的性质(即“属性”号自动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 a evolução das obras de Almodóvar por duas matrizes únicas: a 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"}}}
有2项关于这个车的“产品1”和“产品2”。但事实上,我应该看到这样的事情:
Property: 0
Name: Product 1
Price: 99.00
Qty: 1
ID: 8
Property: 1
Name: Product 2
Price: 59.00
Qty: 1
ID: 7
什么Mixpanel需要的是,我把它转换成一个数组像这样设置一个新的用户:
$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,
));
任何人都知道我该怎么找回SP来自CI的购物车类的特殊数据?这样的事情:
$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,
));
我认为这可能非常简单,但我被困在这里(再次)。
解决了这个问题。谢谢! – grpaiva