Created
October 9, 2012 14:00
-
-
Save deniscsz/3858998 to your computer and use it in GitHub Desktop.
Calculando que os produtos terão custo de envio de 3 em 3 unidades.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* calculates total value from quote | |
* | |
* @return int|float | |
*/ | |
public function getShippingPrice() { | |
/** | |
* get quote items | |
*/ | |
$items = Mage::getSingleton('checkout/cart')->getItems(); | |
$sumTotal = 0; | |
$sumMax = 0; | |
$control = 3; | |
if($items){ | |
foreach ($items as $item){ | |
/** | |
* calculate price by items | |
*/ | |
$priceByItem = $this->calculate($item); | |
if($sumMax < $priceByItem) { | |
$sumMax = $priceByItem; | |
} | |
if($control%3 == 2) { | |
$sumTotal += $sumMax; | |
$sumMax = 0; | |
} | |
$control += 1; | |
} | |
} | |
return $sumTotal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment