Welcome Guest, Not a member yet? Register   Sign In
cart class : Problem name with space
#1

[eluser]ludo31[/eluser]
Hello ;
I create a project in shopping shoes and My problem is I can add in cart all shoes except one with reference ID is 82 :

at the final the result is like this : remark there are already 2 shoes in pictures :

photo 1

and When I try for example : the shoes 85 :

http://hpics.li/9dcca51

except the shoes : 82

so the code :
in view file I send some values :

Code:
<h3> Panier </h3>
                    
  &lt;?php  
   $segments = array('shop','add',$r['libelle_genre'],$r['libelle_style'],$r['id'],
       $r['prix'] ,$r['nom'],$r['quantite'] );
        ?&gt;
    
            
                    
                    &lt;?php //echo var_dump($segments); exit ;?&gt;
            
            
                    <a href="&lt;?php echo site_url($segments); ?&gt;">
              
              
                         &lt;?php  echo img('image/supplement/cart_add.png');?&gt;
              
              
                      </a>
    
  
    
    
    </div>

with : &lt;?php echo var_dump($segments); exit ;?&gt;

http://hpics.li/ee82214

that is to say that the value has been send !!
and in my function shop add :


Code:
public function add() {

        /* on intercepete la quantitedisponible exemple 12 */

      
        
        $quantif = $this->uri->segment(8);
        
    


        /* parametre de la class cart
         * mettre en options la quantite disponible
         */



        $data = array(
            'id' => $this->uri->segment(5),
            'qty' => 1,
            'price' => $this->uri->segment(6),
            'name' => $this->uri->segment(7),
            'options' => array('quantite' => $quantif)
        );

        
        
         //var_dump($data); exit ;
      
        
      


          /* insertion dans la cart */
        $this->cart->insert($data);


        /* redirection vers la vue panier.php */

        redirect('shop/panier');
    }








and with
Code:
&lt;?php var_dump($data); exit ;?&gt;

we have :




Code:
array
  'id' => string '82' (length=2)
  'qty' => int 1
  'price' => string '125000.00' (length=9)
  'name' => string 'adidas zero' (length=13)
  'options' =>
    array
      'quantite' => string '2' (length=1)

remark the name of the shoes is :

Code:
'name' => string 'adidas zero' (length=13)

and in view file redirect('shop/panier');



Code:
<div id="total_article">
    
      &lt;?php echo $this->cart->total_items(); ?&gt; Articles
    
    
     </div>
  
      &lt;?php if($this->cart->contents()):?&gt;
  
   <table>
  
    <theader class="entete">
    
     <tr>
      
      <th>R&eacute;f&eacute;rence</th>
      <th>Articles</th>
      <th>Prix</th>
      <th>Quantit&eacute;</th>
      <th>Total</th>
      <th>A jour</th>
      <th>Annuler</th>
     </tr>
    
    
    
    </theader>
                
                
                &lt;?php //var_dump($this->cart->contents()); exit ; ?&gt;
    
    &lt;?php foreach($this->cart->contents() as $art):?&gt;
                
                
              
    
    &lt;?php echo form_open('shop/update');?&gt;
    
    &lt;input type="hidden" name="rowid" id="rowid"
    value ="&lt;?php echo $art['rowid']; ?&gt;"/&gt;
    
    &lt;?php if($this->cart->has_options($art['rowid'])==TRUE):?&gt;
    
    
    &lt;?php foreach($this->cart->product_options($art['rowid']) as $item=>$valeur):?&gt;
  
    
       &lt;input type="hidden" name="quantite" id="quantite"
    value ="&lt;?php echo $valeur['quantite'] ; ?&gt;"/&gt;
    
     &lt;?php endforeach ;?&gt;
    
    
    
    
    
    <tbody class="corps">
    
      <tr>
    
    
       <td>&lt;?php echo $art['id'];?&gt;</td>
      <td>&lt;?php echo $art['name']?&gt;</td>
      <td>&lt;?php echo $art['price']?&gt;</td>
      <td>
      
      
      
      &lt;!-- ici option pour l'utilisateur de chosir la quantite qu'il veut --&gt;
      
    
      
      
      
        
        
        &lt;?php
        
        echo form_dropdown('quantity', range(1, $valeur), set_value('quantity', '0'));
        
        ?&gt;
      </td>
      
      
      
      
      
      <td>&lt;?php echo $art['price']*$art['qty']?&gt;</td>
      
      
      <td>
      &lt;input type="submit" value="A jour"/&gt;
      
      </td>
      
      
      <td>
      
      <a href="&lt;?php echo site_url('shop/delete/'.$art['rowid']);?&gt;">
        
        X
      
      </a>
      
      </td>
      
          
     </tr>
    
    
    
    </tbody>
    
    
    
    
    
    &lt;?php endif;?&gt;
  
   &lt;?php  echo form_close();?&gt;
  
   &lt;?php endforeach;?&gt;
  
   </table>
  
   <tfooter class="piedtable">
  
  
     <div id="total">&lt;?php echo $this->cart->total();?&gt; Ariary</div>
    
     <div id="empty">
    
       <a href="&lt;?php echo site_url('shop/emptyCart');?&gt;">
      
       Vider Panier
      
  &lt;!-- <img src="&lt;?php //echo base_url();?&gt;image/supplement/cart_remove.png" alt="Vider Panier"/> --&gt;
         &lt;?php echo img('image/supplement/cart_remove.png'); ?&gt;      
      
       </a>
      
      
       </div>
      
    
        &lt;?php else:?&gt;
      <p>Aucun article dans le panier</p>
      &lt;?php endif;?&gt;
  
  </tfooter>
  
  
    
  
  
    
  
  </div>
  <div class="clear"></div>

and when I write :

Code:
&lt;?php //var_dump($this->cart->contents()); exit ; ?&gt;

it adds all shoes with name is without space except the shoes 82 !!
I compare the difference between the shoes 82 an the rest and the only difference is its name (82) has space

thanks !!
#2

[eluser]Matalina[/eluser]
I'm not 100% on what you are saying as I only skimmed the issue: But if it's spaces you are having an issue with product names this article will help you out I think:

http://darrenonthe.net/2011/05/03/cant-a...art-class/

#3

[eluser]Stoney[/eluser]
Code:
$data = array(
            'id' => $this->uri->segment(5),
            'qty' => 1,
            'price' => $this->uri->segment(6),
            'name' => $this->uri->segment(7),
            'options' => array('quantite' => $quantif)
        );

You don't need to transfer name in the URL if you know the ID simply write a model function to get the name from the DB, and if you put the price in the URL it could be a security issue...


#4

[eluser]ludo31[/eluser]
Thnaks for the link , mya be I try the last sotution catch the data via model !!
thanks




Theme © iAndrew 2016 - Forum software by © MyBB