2

Magento 中是否可能出现以下情况?

分层定价和批量折扣将适用于同一订单。我想要总价超过 200 美元的 4% 折扣。但是,分层定价的产品价格将不被视为批量折扣规则。

例如我有 4 个产品

product 1 price = 10  and having tier price = $8 for 5+ products
product 2 price = 10
product 3 price = 100
product 4 price = 140

所以如果我点了喜欢

product 1 qty-6  price = $48
priduct 2 qty-1  price = 10
priduct 3 qty-1  price = 100
priduct 4 qty-1  price = 140

我们对产品 1 应用分级定价,该产品不符合批量定价的条件。但是,剩余金额仍然有资格进行批量定价。这意味着 4% 的折扣将适用于 $250 (10 + 100 + 140)。

我需要减去在购物车中应用了等级价格的产品总数,并且需要根据我的购物车规则检查剩余的产品总数以获得折扣。

谁能指导我如何实现这一目标?

4

1 回答 1

0
public static function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo,
            $rulePrice = false, $wId = null, $gId = null, $productId = null)
    {
        Varien_Profiler::start('__PRODUCT_CALCULATE_PRICE__');
        if ($wId instanceof Mage_Core_Model_Store) {
            $sId = $wId->getId();
            $wId = $wId->getWebsiteId();
        } else {
            $sId = Mage::app()->getWebsite($wId)->getDefaultGroup()->getDefaultStoreId();
        }

        $finalPrice = $basePrice;
        if ($gId instanceof Mage_Customer_Model_Group) {
            $gId = $gId->getId();
        }

        $finalPrice = self::calculateSpecialPrice($finalPrice, $specialPrice,          $specialPriceFrom, $specialPriceTo, $sId);

        if ($rulePrice === false) {
            $storeTimestamp = Mage::app()->getLocale()->storeTimeStamp($sId);
            $rulePrice = Mage::getResourceModel('catalogrule/rule')
                ->getRulePrice($storeTimestamp, $wId, $gId, $productId);
        }

        if ($rulePrice !== null && $rulePrice !== false) {
            $finalPrice = min($finalPrice, $rulePrice);
        }

        $finalPrice = max($finalPrice, 0);
        Varien_Profiler::stop('__PRODUCT_CALCULATE_PRICE__');
        return $finalPrice;
    }

在 Mage_Catalog_Model_Product_Type_Price 中有

 if ($rulePrice === false) {
            $storeTimestamp = Mage::app()->getLocale()->storeTimeStamp($sId);
            $rulePrice = Mage::getResourceModel('catalogrule/rule')
                ->getRulePrice($storeTimestamp, $wId, $gId, $productId);
        }

因此,在 $rulePrice == false 检查产品数量以及是否有任何批量定价适用,如果是,那么

if ($rulePrice === false) {
            $storeTimestamp = Mage::app()->getLocale()->storeTimeStamp($sId);
            $flag = $this->someCheckFunction()  // This function you will have to write
            if($flag == 1) {

            $rulePrice = Mage::getResourceModel('catalogrule/rule')
                ->getRulePrice($storeTimestamp, $wId, $gId, $productId);
           }
        }
于 2013-04-12T02:06:07.497 回答