я хочу показать самый последний элемент вверху в $this->cart->contents(); ниже приведены мои функции добавления в корзину и отображения корзины. он отображает содержимое, но я хочу, чтобы элементы отображались как новые, вставленные вверху.
public function show_cart(){
$output='';
foreach ($this->cart->contents() as $items) {
$output .='
'.$items['name'].'
[url=javascript:void(0)][/url] '.$items['qty'].' [url=javascript:void(0)][/url]
'.number_format($items['price']).'
'.number_format($items['subtotal']).'
';
}
return $output;
}
public function add_to_cart(){
$data = array(
'id' => $this->input->post('product_id'),
'name' => $this->input->post('product_name'),
'price' => $this->input->post('product_price'),
'qty' => $this->input->post('qty'),
);
$this->cart->insert($data);
echo $this->show_cart();
}
Подробнее здесь: https://stackoverflow.com/questions/546 ... odeigniter