1

i'm working on grouped products price now total price is calculated as

Total price = product(a) price x product(a) quantity + product(b) price x product() quantity

i want some change in that calculation like this

Total price = product(a) price x product(a) quantity x product(a) Carton + product(b) price x product(b) quantity x product(b) Carton

anyone can tell me where is code or how to do it

3
  • Where in admin are you defining "product(a) Carton"? Is it a product attribute? – bogatyrjov Sep 2 '14 at 12:45
  • YES it is an attribute . i have 3 diffrenet carton size with different price of each carton set for example Quantity per Carton | Price PER Carton | 1-2 | 3-6 | 6+ ______________________________________________ 23 | $30 | $25 | $20 | – Ashvini Marwal Sep 2 '14 at 13:38
  • complete problem is here magento.stackexchange.com/questions/34270/… – Ashvini Marwal Sep 2 '14 at 13:41
0

You can use configurable products to change price depending on product attribute.

In you case you can create a grouped product, which consists of configurable products, each of which has a "Carton" attribute and a different price set depending on the attribute value.

3
  • i have created attributes with carton set with different price but on click add to cart ...system calculate final cost as product price x quantity .. but i need final cost as Quantity per Carton x Price PER Carton X Quantity – Ashvini Marwal Sep 2 '14 at 13:47
  • Are you using a configurable product? – bogatyrjov Sep 2 '14 at 14:33
  • I'm using grouped products with those attributes – Ashvini Marwal Sep 2 '14 at 14:48
0

i override calcRowTotal function and it's working for me

public function calcRowTotal()
    {


        $product = $this->getProduct();
        $product->load($product->getId());
         $QuantityPerCarton_get = $product->getQuantityPerCarton();
         if(!empty($QuantityPerCarton_get)) {
            $QuantityPerCarton  = $QuantityPerCarton_get;
         }
         else {
             $QuantityPerCarton =1;
         }

        $qty        = $this->getTotalQty();
        if ($qty <= 3) 
        {
            $price = $product->getPricePerCorton();
        }
        elseif(3 <  $qty && $qty >= 5) 
        {
            $price = $product->getPricePerCortonSecond();
        }
        elseif(5 <  $qty )  {
            $price = $product->getPricePerCortonThree();
        }
        else  {
            $price = $this->getStore()->roundPrice($this->getCalculationPriceOriginal());
        }
        // Round unit price before multiplying to prevent losing 1 cent on subtotal
       $total      =   $qty * $price *  $QuantityPerCarton;
        $baseTotal  = $this->getStore()->roundPrice($this->getBaseCalculationPriceOriginal()) * $qty * $price  * $QuantityPerCarton;

        $this->setRowTotal($this->getStore()->roundPrice($total));
        $this->setBaseRowTotal($this->getStore()->roundPrice($baseTotal));
        return $this;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.