Magento预付款

时间:2011-09-16 10:59:00

标签: magento-1.5 magento

对于未来的项目,我们被指派创建一个简单的概念(在Magento内部),必须执行以下操作:

客户可以选择不同的运输方式,其中一种是" Ship2Shop",它将产品发送到选择的实体店,客户必须选择它起来。 当客户选择这个" ship2shop"运输方式,必须在线支付总金额的一定百分比(例如:25%)(通过预定义的支付方式),当客户去取货时,必须在实体店中支付剩余的75%他订购的产品。

你会怎么做?

我们的想法是修改结账/订单会话并修改"总计"金额(在会话中保存原件)。然后,当客户被发送到外部支付处理器时,修改了总计"发送。一旦客户在magento平台上返回,我们将通过恢复原始总计的方式来修改订单,并更新总付款和总到期金额。

有人对此有任何其他想法吗?

修改 在得到Anton S的反馈后,我设法增加了预付款总额"。但是我仍然有问题 在config.xml中,我在标记中添加了以下内容:

                                                           acsystems_advancepayment / total_custom                     累计                                            

我希望我的预付款显示在总计之后,出于某种原因,magento不会这样做......

EDIT2:收集方法

public function collect(Mage_Sales_Model_Quote_Address $address)
    {
        parent::collect($address);

        $quote = $address->getQuote();
        $advancePaymentAmount = 0;
        $baseAdvancePaymentAmount = 0;

        $items = $address->getAllItems();
        if (!count($items)) {
            $address->setAdvancePaymentAmount($advancePaymentAmount);
            $address->setBaseAdvancePaymentAmount($baseAdvancePaymentAmount);
            return $this;
        }

        $address->setBaseAdvancePayment($address->getGrandTotal()*(0.25));
        $address->setAdvancePayment($address->getGrandTotal()*(0.25));
        $address->setAdvancePaymentAmount($address->getGrandTotal()*(0.25));
        $address->setBaseAdvancePaymentAmount($address->getGrandTotal()*(0.25));
        $address->setGrandTotal($address->getGrandTotal() - $address->getAdvancePaymentAmount());
        $address->setBaseGrandTotal($address->getBaseGrandTotal()-$address->getBaseAdvancePaymentAmount());

        return $this;
    }

2 个答案:

答案 0 :(得分:2)

请参阅此线程,其中解释了添加总对象Magento: adding duties/taxes to a quote during review

基本上,您应该根据您的送货方式选择添加自己的总对象,然后它也会以总计的形式显示为单独的行,您可以在每个电子邮件或总计曝光的地方显示此内容

public function collect(Mage_Sales_Model_Quote_Address $address)
{

    //this is for the loop that you are in when totals are collected 
    parent::collect($address);

    $quote = $address->getQuote();

    //variables for your own object context
    $advancePaymentAmount = 0;
    $baseAdvancePaymentAmount = 0;

    $items = $address->getAllItems();
    if (!count($items)) {
        $address->setAdvancePaymentAmount($advancePaymentAmount);
        $address->setBaseAdvancePaymentAmount($baseAdvancePaymentAmount);
        return $this;
    }

    //calculated based on other total object and don't edit other totals inside your own as your calculations would be always false and so would be next total object in the cycle and so on
    $baseAdvancePaymentAmount = $address->getBaseGrandTotal()*(0.25);
    $advancePaymentAmount = $address->getQuote()->getStore()->convertPrice($baseAdvancePaymentAmount, false);

    //this is just for your own object context
    $address->setBaseAdvancePaymentAmount($baseAdvancePaymentAmount);
    $address->setAdvancePaymentAmount($advancePaymentAmount);

    /* 
     * this is for the loop that you are in when totals are collected and 
     * those are set to 0 for each totals collecting cycle 
     */

    $this->_setBaseAmount($baseAdvancePaymentAmount);
    $this->_setAmount($advancePaymentAmount);

    return $this;
}

答案 1 :(得分:-2)

另一种选择是更改付款模块中的“grand_total”,这样就不会改变会话..