2017-08-09 1 views
0

Je veux mettre à jour la quantité d'un panier. J'ai beaucoup google mais je ne pouvais pas le faire.comment mettre à jour la quantité de chariot dans CodeIgniter?

Nombre maximal de pages que je ne veux pas afficher. Exactement la solution que je ne reçois pas. J'espère que je vais arriver ici. Aidez-moi s'il vous plaît à le faire. Voici ma Voir page.

**<table class="table table-hover table-bordered table-striped snipcart-details "> <thead> 
       <tr> 
        <th style="color:#FF0033; font-weight:bolder; text-align:center;" >Delete Cart</th> 
        <th style="color:#FF0033; font-weight:bolder; text-align:center;" >Product Name</th> 
        <th style="color:#FF0033; font-weight:bolder; text-align:center;" >Image</th> 
        <th style="color:#FF0033; font-weight:bolder; text-align:center;" >Price</th> 
        <th style="color:#FF0033; font-weight:bolder; text-align:center;" >Quantity</th>      
        <th colspan="2" style="color:#FF0033; font-weight:bolder; text-align:center;" >Total</th> 
       </tr> 
       </thead> 
       <tbody>     
       <?php foreach ($this->cart->contents() as $items) { ?> 
       <tr>      
        <td style="color:#000000; font-weight:bolder; text-align:center;" > 
        <a href="#" class="remove_cart" title="delete" row_id="<?php echo $items['rowid']; ?>" rel="1"> 
        <i class="fa fa-times fa-2x" style="color:red;" aria-hidden="true"></i> </a></td> 
        <td style="color:#000000; font-weight:bolder; text-align:center;" ><?php echo $items['name']; ?></td> 
        <td align="center"><img src="<?php echo base_url('resource/allproduct/'.$items['productImage']);?>" height="50px;" /></td></td> 
        <td style="color:#000000; font-weight:bolder; text-align:center;"><?php echo $items['price']; ?></td> 
        <td align="center"><input type="number" name="qty" id="qty" value="<?php echo $items['qty']; ?>"></td>    
      <td colspan="2" style="color:#000000; font-weight:bolder; text-align:center;">TK <?php echo $this->cart->format_number($items['subtotal']); ?></td> 
       </tr> 
       <?php } ?> 
      </tbody>     
      <tbody> 
       <tr>      
        <th scope="row"><a href=""> <input type="button" name="submit" value="Update" class="button" /> </a></th> 
        <td align="center"><a href="<?php echo site_url('home'); ?>"> <input type="button" name="submit" value="Continue Shopping" class="button" /></a></td> 
        <td colspan="3" class="button" align="center" >  
            <?php if(!empty($userid)){?> 
            <a href="<?php echo site_url("checkout"); ?>"><input class="button" type="submit" value="Place Order"></a> 
            <?php } else {?> 
            <a href="<?php echo site_url("login"); ?>"><input class="button" type="submit" value="Place Order"></a>          
            <?php }?>              
        </td> 
        <td align="center" style="color:#000000;" > <h4>Grand Total</h4> </td> 
        <td style="font-size:24px; font-weight:800; color:green;">TK <?php echo $this->cart->format_number($this->cart->total()); ?></td>   
       </tr> 
      </tbody> 
     </table>** 

Et voici controleur.

public function index() 
{ 
    $data['basicinfo']   = $this->M_cloud->basicall('basic_info'); 
    $where      = array('status' => 1); 
    $data['categoryinfo']  = $this->M_cloud->categoryinfo('item_manage', $where); 
    $data['rows']    = count($this->cart->contents());  
    $data['userid']    = $this->session->userdata('user_id');  
    $data['subcategoryinfo'] = $this->M_cloud->findAll2('sub_category', array('status' => 1));  
    $data['menuinformation'] = $this->M_cloud->findReport('our_service', array('serviceType'=> 2), 'menuname asc'); 
    $data['menuservice']  = $this->M_cloud->findReport('our_service', array('serviceType'=> 1), 'menuname asc');  
    $data['socialmedia']  = $this->M_cloud->findAll('social_tbl', 'name asc'); 
    $data['newsinfo']   = $this->M_cloud->findAll('news_table', 'newstitle DESC'); 
    $this->load->view('cartPage', $data);  
} 

    public function buy() 
{ 
    $proId = $this->input->post('proId'); 
    $Qty = $this->input->post('Qty'); 
    $prosize = $this->input->post('prosize');  
    $result = $this->M_cloud->find('product_manage', array('proid' => $proId));  
    $data2 = array(
       'id'     => $proId, 
       'qty'     => $Qty, 
       'name'     => $result->proName, 
       'price'     => $result->price, 
       'prosize'    => $prosize, 
       'productImage'   => $result->proimg1, 
       'product_code'   => $result->procode     
      ); 
    $this->cart->insert($data2);   
    redirect('cart'); 
} 

public function deleteCartItem() { 
    $row_id    = $this->input->post('row_id'); 
    $data = array(
     'rowid' => $row_id, 
     'qty'  => 0 
    ); 
    $this->cart->update($data); 
} 

S'il vous plaît aidez-moi comment mettre à jour la quantité de panier. Merci d'avance.

Répondre

0

Pour mettre à jour panier Article:

function updateCartItem(){ 
     $data=array(
      'rowid'=>$this->input->post('rowid',TRUE), 
      'qty'=> $this->input->post('quantity',TRUE) 
      ); 

       if ($this->cart->update($data)) { 
       echo "Success";   
       }else{ 
        echo "Faliure"; 
       } 

} 

Pour supprimer l'élément du panier:

function deleteCartItem(){ 
$row_id = $this->input->post('row_id',TRUE); 
    if ($rowid) { 
      return $this->cart->remove($rowid); 
     } 
} 
+0

Où est l'action de la page vue? – Sumonto

+0

je peux vous aider avec des erreurs pas avec la fonctionnalité que vous avez pour concevoir votre propre page de panier –

+0

Je veux dire comment appeler en action le contrôle ?? c'est tout ou rien d'autre que je devrais appeler ???? S'il vous plaît laissez-moi savoir – Sumonto