yatinmistry / yii-shop

Automatically exported from code.google.com/p/yii-shop
0 stars 0 forks source link

calculating of variations price is totaly wrong #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.add variation to product
2.add product to cart
3.

What is the expected output? What do you see instead?
I always see the same result of firts variation in the database

Please provide any additional information below.
The function "getPrice" in Product model is wrong.According to the code you 
always choose first product's variation but it must depend on product so in my 
opionion it must be smt like:

public function getPrice($variations = null, $amount = 1,$product_id) {
        $price = (float) $this->price;
        if($variations&&isset($variations)&&count($variations)>0)
        {
            foreach($variations as $key => $variation) {
                $pr_variation = ProductVariation::model()->find(' product_id=:prid AND specification_id=:spid ', array(
                                                                          ':prid'=>$product_id, 
                                                                          ':spid'=>$key,
                                                                        ));     
                $price += $pr_variation->price_adjustion*$variation[0];
            }

        }
        (float) $price *= $amount;

        return $price;
    }

Original issue reported on code.google.com by mustafah...@gmail.com on 7 Jul 2011 at 11:20