本文整理匯總了PHP中type::getDiscountAmount方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::getDiscountAmount方法的具體用法?PHP type::getDiscountAmount怎麽用?PHP type::getDiscountAmount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::getDiscountAmount方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _calcRowTaxAmount
/**
* Calculate tax for each item
*
* @param type $item
* @param type $rate
* @return Magestore_Customerreward_Model_Total_Quote_Tax
*/
protected function _calcRowTaxAmount($item, $rate)
{
$discount = $item->getDiscountAmount();
$baseDiscount = $item->getBaseDiscountAmount();
$item->setDiscountAmount($discount + $item->getAffiliateplusAmount() + $item->getCustomerrewardAmount());
$item->setBaseDiscountAmount($baseDiscount + $item->getBaseAffiliateplusAmount() + $item->getBaseCustomerrewardAmount());
parent::_calcRowTaxAmount($item, $rate);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
return $this;
}
示例2: _calcRowTaxAmount
/**
* Calculate tax for each item
*
* @param type $item
* @param type $rate
* @return Magestore_Customerreward_Model_Total_Quote_Tax
*/
protected function _calcRowTaxAmount($item, $rate, &$taxGroups = null, $taxId = null, $recalculateRowTotalInclTax = false)
{
$discount = $item->getDiscountAmount();
$baseDiscount = $item->getBaseDiscountAmount();
/* hainh add this for calculating discount base on incl or excl tax price 22-04-2014 */
if (!$this->_discountIncludeTax()) {
$item->setDiscountAmount($discount + $item->getAffiliateplusAmount() + $item->getCustomerrewardAmount());
$item->setBaseDiscountAmount($baseDiscount + $item->getBaseAffiliateplusAmount() + $item->getBaseCustomerrewardAmount());
}
parent::_calcRowTaxAmount($item, $rate, $taxGroups, $taxId, $recalculateRowTotalInclTax);
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
return $this;
}
示例3: _calcRowTaxAmount
/**
* Calculate tax for each item
*
* @param type $item
* @param type $rate
* @return Magestore_Magestore_Model_Total_Quote_Tax
*/
protected function _calcRowTaxAmount($item, $rate)
{
$discount = $item->getDiscountAmount();
$baseDiscount = $item->getBaseDiscountAmount();
if ($item->getIsPriceInclTax()) {
$item->setMagestoreDiscountTax($this->_calculator->calcTaxAmount($item->getMagestoreDiscount(), $rate, false, false));
$item->setMagestoreBaseDiscountTax($this->_calculator->calcTaxAmount($item->getMagestoreBaseDiscount(), $rate, false, false));
}
$item->setDiscountAmount($discount + $item->getMagestoreDiscount() + $item->getMagestoreDiscountTax());
$item->setBaseDiscountAmount($baseDiscount + $item->getMagestoreDiscount() + $item->getMagestoreBaseDiscountTax());
parent::_calcRowTaxAmount($item, $rate);
$afterDiscount = (bool) Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT, $this->_store);
if ($item->getIsPriceInclTax() && $afterDiscount) {
foreach ($this->_hiddenTaxes as $key => $taxInfoItem) {
if (isset($taxInfoItem['item']) && $item->getId() == $taxInfoItem['item']->getId() && $taxInfoItem['value'] >= $item->getMagestoreDiscountTax() && $item->getMagestoreDiscountTax() > 0) {
$this->_hiddenTaxes[$key]['value'] = $taxInfoItem['value'] - $item->getMagestoreDiscountTax();
$this->_hiddenTaxes[$key]['base_value'] = $taxInfoItem['base_value'] - $item->getMagestoreBaseDiscountTax();
break;
}
}
//fix 1.4
if ($item->getHiddenTaxAmount()) {
$item->setHiddenTaxAmount($item->getHiddenTaxAmount() - $item->getMagestoreDiscountTax());
$item->setBaseHiddenTaxAmount($item->getBaseHiddenTaxAmount() - $item->getMagestoreBaseDiscountTax());
}
}
$item->setDiscountAmount($discount);
$item->setBaseDiscountAmount($baseDiscount);
return $this;
}
示例4: getDeliverInvoiceRequest
/**
* Builds request for DeliverInvoice for Invoice and PaymentPlan payment.
* Calls from Magento Capture
*
* @param type $invoice
* @param type $auth
* @param type $sveaOrderId
* @return type
*/
public function getDeliverInvoiceRequest($invoice, $auth, $sveaOrderId)
{
$conf = new SveaMageConfigProvider($auth);
$sveaObject = WebPay::deliverOrder($conf);
$order = $invoice->getOrder();
$countryCode = $order->getBillingAddress()->getCountryId();
$storeId = $order->getStoreId();
$store = Mage::app()->getStore($storeId);
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$taxConfig = Mage::getSingleton('tax/config');
// Add invoiced items
foreach ($invoice->getAllItems() as $item) {
$orderItem = $item->getOrderItem();
if ($orderItem->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
continue;
}
// Default to the item price
$name = $item->getName();
$price = $orderItem->getPrice();
$priceInclTax = $orderItem->getPriceInclTax();
$taxPercent = $orderItem->getTaxPercent();
if (!(int) $taxPercent) {
$taxPercent = false;
}
$parentItem = $orderItem->getParentItem();
if ($parentItem) {
switch ($parentItem->getProductType()) {
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
$price = $parentItem->getPrice();
$priceInclTax = $parentItem->getPriceInclTax();
$taxPercent = $parentItem->getTaxPercent();
break;
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
$taxPercent = $priceInclTax = $price = 0;
$name = '- ' . $name;
break;
}
}
if ($taxPercent === false) {
// If it's a bundle item we have to calculate the tax from
// the including/excluding tax values
$taxPercent = round(100 * ($priceInclTax / $price - 1));
}
switch (get_class($item)) {
case 'Mage_Sales_Model_Quote_Item':
case 'Mage_Sales_Model_Order_Invoice_Item':
case 'Mage_Sales_Model_Order_Creditmemo_Item':
$qty = $item->getQty();
break;
default:
$qty = $item->getQtyOrdered();
break;
}
$orderRow = WebPayItem::orderRow()->setArticleNumber($item->getSku())->setQuantity((int) $qty)->setName($name)->setUnit(Mage::helper('svea_webpay')->__('unit'))->setVatPercent((int) $taxPercent);
if ($taxConfig->priceIncludesTax($storeId)) {
$orderRow->setAmountIncVat((double) $priceInclTax);
} else {
$orderRow->setAmountExVat((double) $price);
}
$sveaObject->addOrderRow($orderRow);
}
$request = $taxCalculationModel->getRateRequest($order->getShippingAddress(), $order->getBillingAddress(), null, $store);
// Add shipping fee
if ($invoice->getShippingAmount() > 0) {
$shippingFee = WebPayItem::shippingFee()->setUnit(Mage::helper('svea_webpay')->__('unit'))->setName($order->getShippingDescription());
// We require shipping tax to be set
$shippingTaxClass = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $storeId);
$rate = $taxCalculationModel->getRate($request->setProductClassId($shippingTaxClass));
$shippingFee->setVatPercent((int) $rate);
if ($taxConfig->shippingPriceIncludesTax($storeId)) {
$shippingFee->setAmountIncVat($invoice->getShippingInclTax());
} else {
$shippingFee->setAmountExVat($invoice->getShippingAmount());
}
$sveaObject->addFee($shippingFee);
}
// Possible discount
$discount = abs($invoice->getDiscountAmount());
if ($discount) {
$discountRow = WebPayItem::fixedDiscount()->setAmountIncVat($discount)->setName(Mage::helper('svea_webpay')->__('discount'))->setUnit(Mage::helper('svea_webpay')->__('unit'));
$sveaObject->addDiscount($discountRow);
}
// Gift card(s)
if (abs($order->getGiftCardsAmount())) {
$giftCardRow = WebPayItem::fixedDiscount()->setAmountIncVat(abs($order->getGiftCardsAmount()))->setUnit(Mage::helper('svea_webpay')->__('unit'));
$sveaObject->addDiscount($giftCardRow);
}
// Invoice fee
$paymentFee = $invoice->getSveaPaymentFeeAmount();
$paymentFeeInclTax = $invoice->getSveaPaymentFeeInclTax();
$invoiced = $invoice->getOrder()->getSveaPaymentFeeInvoiced();
//.........這裏部分代碼省略.........
示例5: getSveaPaymentObject
/**
* Add values and rows to Svea CreateOrder object
*
* Configurable products:
* Calculate prices using the parent price, to take price variations into concern
*
* Simple products:
* Just use their prices as is
*
* Bundle products:
* The main parent product has the price, but the associated products
* need to be transferred on separate 0 amount lines so the invoice is
* verbose enough
*
* Grouped products:
* These are treated the same way as simple products
*
* @param type $order
* @param type $additionalInfo
* @return type Svea CreateOrder object
*/
public function getSveaPaymentObject($order, $additionalInfo = null)
{
//Get Request and billing addres
$svea = $order->getData('svea_payment_request');
$billingAddress = $order->getBillingAddress();
$storeId = $order->getStoreId();
$store = Mage::app()->getStore($storeId);
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$taxConfig = Mage::getSingleton('tax/config');
// Build the rows for request
foreach ($order->getAllItems() as $item) {
if ($item->getProductType() === Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
continue;
}
// Default to the item price
$name = $item->getName();
$price = $item->getPrice();
$priceInclTax = $item->getPriceInclTax();
$taxPercent = $item->getTaxPercent();
if (!(int) $taxPercent) {
$taxPercent = false;
}
$parentItem = $item->getParentItem();
if ($parentItem) {
switch ($parentItem->getProductType()) {
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
$priceInclTax = $parentItem->getPriceInclTax();
$taxPercent = $parentItem->getTaxPercent();
break;
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
$taxPercent = $priceInclTax = $price = 0;
$name = '- ' . $name;
break;
}
}
if ($taxPercent === false) {
if ((double) $price === 0.0) {
if ((double) $priceInclTax === 0.0) {
$taxPercent = 0;
} else {
throw new Mage_Exception("Price is 0 but priceIncTax is not");
}
} else {
// If it's a bundle item we have to calculate the tax from
// the including/excluding tax values
$taxPercent = round(100 * ($priceInclTax / $price - 1));
}
}
$qty = get_class($item) == 'Mage_Sales_Model_Quote_Item' ? $item->getQty() : $item->getQtyOrdered();
$orderRow = WebPayItem::orderRow()->setArticleNumber($item->getSku())->setQuantity((int) $qty)->setName($name)->setUnit(Mage::helper('svea_webpay')->__('unit'))->setVatPercent((int) $taxPercent)->setAmountIncVat((double) $priceInclTax);
$svea->addOrderRow($orderRow);
}
$request = $taxCalculationModel->getRateRequest($order->getShippingAddress(), $order->getBillingAddress(), null, $store);
// Shipping
if ($order->getShippingAmount() > 0) {
$shippingFee = WebPayItem::shippingFee()->setUnit(Mage::helper('svea_webpay')->__('unit'))->setName($order->getShippingDescription());
// We require shipping tax to be set
$shippingTaxClass = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS, $storeId);
$rate = $taxCalculationModel->getRate($request->setProductClassId($shippingTaxClass));
$shippingFee->setVatPercent((int) $rate);
$shippingFee->setAmountIncVat($order->getShippingInclTax());
$svea->addFee($shippingFee);
}
// Discount
$discount = abs($order->getDiscountAmount());
if ($discount > 0) {
$discountRow = WebPayItem::fixedDiscount()->setName(Mage::helper('svea_webpay')->__('discount'))->setUnit(Mage::helper('svea_webpay')->__('unit'))->setAmountIncVat($discount);
$svea->addDiscount($discountRow);
}
// Gift cards
if (abs($order->getGiftCardsAmount()) > 0) {
$giftCardRow = WebPayItem::fixedDiscount()->setUnit(Mage::helper('svea_webpay')->__('unit'))->setAmountIncVat(abs($order->getGiftCardsAmount()));
$svea->addDiscount($giftCardRow);
}
// Invoice fee
$paymentFeeInclTax = $order->getSveaPaymentFeeInclTax();
if ($paymentFeeInclTax > 0) {
$paymentFeeTaxClass = $this->getConfigData('handling_fee_tax_class');
$rate = $taxCalculationModel->getRate($request->setProductClassId($paymentFeeTaxClass));
//.........這裏部分代碼省略.........