как отсортировать данные корзины в порядке возрастания или убывания в codeigniter - PullRequest
0 голосов
/ 14 февраля 2019

я хочу показать самый последний элемент вверху в $ this-> cart-> contents ();ниже мой добавить в корзину и показать функции корзины.его содержимое отображается, но я хочу, чтобы элементы отображались как новые, вставленные сверху.

public function show_cart(){
    $output='';
    foreach ($this->cart->contents() as $items) {

        $output .='
            <tr>
                <td>'.$items['name'].'</td>
                <td><a href="javascript:void(0)" id="'.$items['rowid'].'"qty="'.$items['qty'].'" class="minus"></a> <span class="c_qunt qty" id="qty">'.$items['qty'].'</span> <a href="javascript:void(0)" id="'.$items['rowid'].'"qty="'.$items['qty'].'" class="plus"></a></td>
                <td>'.number_format($items['price']).'</td>
                <td>'.number_format($items['subtotal']).'</td>
                <td>
                    <span style="font-size:40px; color:red" id="'.$items['rowid'].'" class="remove"></span>
                </td>
            </tr>
        ';
    }
    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();
   }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...