Précédent   Forum du club des développeurs et IT Pro > PHP > Scripts > E-Commerce > Magento
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 16/04/2012, 11h10   #1
King_T
Membre régulier
 
Avatar de King_T
 
Homme
Développeur Web
Inscription : mai 2006
Messages : 157
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2006
Messages : 157
Points : 89
Points : 89
Par défaut Ajouter une remise a un produit specifique dans le panier

Bonjour,

je galère depuis quelques jours sur ce point, je travail sur un module permettant d’accorder un produit a un prix symbolique (1€) pour l’achat d’un autre produit.
je travail sur un observer à partir de l’event

Citation:
checkout_cart_add_product_complete
et j’ai essayé avec :

Code :
1
2
3
4
5
6
$_cart_products = Mage::getModel("checkout/cart") -> getItems();
 
//foreache...
//if ...
$_cart_product ->setPrice($giftPrice) -> setOriginalCustomPrice($giftPrice) 
-> setCustomPrice($giftPrice) -> save();
j’ai réussi a mettre le produit a 1€, mais le problème est que le produit “cadeau” peut se vendre séparément avec un prix normal.
donc, dans mon cas, si l’utilisateur l’ajoute au panier, le prix sera forcé automatiquement a 1€ . ce qui n’est pas logique.

je crois que la solution est dans:
Code :
1
2
$_cart_product->setDiscountAmount($realPrice-$giftPrice);
$_cart_product->setBaseDiscountAmount($realPrice-$giftPrice);
mais jy arrive pas
merci pour votre aide d’avance
__________________
Dreaming in Digital, Living in Realtime, Thinking in Binary, Talking in IP .... Welcome to our World !!!!
King_T est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/04/2012, 17h31   #2
King_T
Membre régulier
 
Avatar de King_T
 
Homme
Développeur Web
Inscription : mai 2006
Messages : 157
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : mai 2006
Messages : 157
Points : 89
Points : 89
petit update :
quand je fais un
Code :
1
2
Zend_Debug::dump($_cart_products);
die();
Voila ce que j'ai comme sortie :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
        array
          'item_id' => string '449' (length=3)
          'quote_id' => string '22' (length=2)
          'created_at' => string '2012-04-19 14:59:22' (length=19)
          'updated_at' => string '2012-04-19 15:09:22' (length=19)
          'product_id' => string '17' (length=2)
          'store_id' => string '1' (length=1)
          'parent_item_id' => null
          'is_virtual' => boolean false
          'sku' => string 'bb8100' (length=6)
          'name' => string 'BlackBerry 8100 Pearl' (length=21)
          'description' => null
          'applied_rule_ids' => string '' (length=0)
          'additional_data' => null
          'free_shipping' => boolean false
          'is_qty_decimal' => string '0' (length=1)
          'no_discount' => string '0' (length=1)
          'weight' => string '15.2000' (length=7)
          'qty' => int 2
          'price' => string '349.9900' (length=8)
          'base_price' => string '349.9900' (length=8)
          'custom_price' => null
          'discount_percent' => int 0
          'discount_amount' => float 348.99
          'base_discount_amount' => float 348.99
          'tax_percent' => int 0
          'tax_amount' => int 0
          'base_tax_amount' => int 0
          'row_total' => float 699.98
          'base_row_total' => float 699.98
          'row_total_with_discount' => float 350.99
          'row_weight' => float 30.4
          'product_type' => string 'simple' (length=6)
          'base_tax_before_discount' => null
          'tax_before_discount' => null
          'original_custom_price' => null
          'gift_message_id' => null
          'weee_tax_applied' => string 'a:0:{}' (length=6)
          'weee_tax_applied_amount' => int 0
          'weee_tax_applied_row_amount' => int 0
          'base_weee_tax_applied_amount' => int 0
          'base_weee_tax_applied_row_amnt' => null
          'weee_tax_disposition' => int 0
          'weee_tax_row_disposition' => int 0
          'base_weee_tax_disposition' => int 0
          'base_weee_tax_row_disposition' => int 0
          'redirect_url' => null
          'base_cost' => string '29.9900' (length=7)
          'price_incl_tax' => float 349.99
          'base_price_incl_tax' => float 349.99
          'row_total_incl_tax' => float 699.98
          'base_row_total_incl_tax' => float 699.98
          'hidden_tax_amount' => null
          'base_hidden_tax_amount' => null
          'qty_options' => 
            array
              ...
Les Discount sont la :
Code :
1
2
3
4
...
        'discount_amount' => float 348.99
          'base_discount_amount' => float 348.99
...
mais ils ne sont pas pris en considération !!
merci encore pour votre aide !
__________________
Dreaming in Digital, Living in Realtime, Thinking in Binary, Talking in IP .... Welcome to our World !!!!
King_T est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 17h21.


 
 
 
 
Partenaires

Hébergement Web