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