public function fetchTotals(Mage_Sales_Model_Quote_Address $address) { $amount = $address->getGiftcertAmount(); if ($amount) { $address->addTotal(array('code' => 'giftcert', 'title' => AO::helper('giftcert')->__('Gift Certificate') . ' (' . $address->getGiftcertCode() . ')', 'value' => -$amount, 'output' => true)); } return $this; }
/** * Convert quote address model to order * * @param Mage_Sales_Model_Quote $quote * @return Mage_Sales_Model_Order */ public function addressToOrder(Mage_Sales_Model_Quote_Address $address, $order = null) { if (!$order instanceof Mage_Sales_Model_Order) { $order = $this->toOrder($address->getQuote()); } $order->setWeight($address->getWeight())->setShippingMethod($address->getShippingMethod())->setShippingDescription($address->getShippingDescription())->setShippingRate($address->getShippingRate())->setSubtotal($address->getSubtotal())->setTaxAmount($address->getTaxAmount())->setDiscountAmount($address->getDiscountAmount())->setShippingAmount($address->getShippingAmount())->setGiftcertAmount($address->getGiftcertAmount())->setCustbalanceAmount($address->getCustbalanceAmount())->setGrandTotal($address->getGrandTotal())->setBaseSubtotal($address->getBaseSubtotal())->setBaseTaxAmount($address->getBaseTaxAmount())->setBaseDiscountAmount($address->getBaseDiscountAmount())->setBaseShippingAmount($address->getBaseShippingAmount())->setBaseGiftcertAmount($address->getBaseGiftcertAmount())->setBaseCustbalanceAmount($address->getBaseCustbalanceAmount())->setBaseGrandTotal($address->getBaseGrandTotal()); Mage::dispatchEvent('sales_convert_quote_address_to_order', array('address' => $address, 'order' => $order)); return $order; }
public function collectTotals(Mage_Sales_Model_Quote_Address $address) { $gift = Mage::getResourceModel('sales/giftcert')->getGiftcertByCode($address->getGiftcertCode()); if ($gift) { $address->setGiftcertAmount(min($address->getGrandTotal(), $gift['balance_amount'])); } else { $address->setGiftcertAmount(0); } $address->setGrandTotal($address->getGrandTotal() - $address->getGiftcertAmount()); return $this; }