0

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

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

你会怎么做?

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

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

编辑: 在下面安东 S 的反馈后,我设法添加了“预付款总额”。但是我仍然有问题在 config.xml 我在标签中添加了以下内容:

acsystems_advancepayment/total_custom grand_total

我希望我的预付款显示在总计之后,由于某种原因,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;
    }
4

2 回答 2

2

请参阅此线程,其中解释了添加总对象Magento:在审核期间向报价添加关税/税

基本上,您应该根据您的运输方式选择添加自己的总计对象,然后它也将作为单独的行显示在总计中,您可以在每封电子邮件或显示总计的地方显示它

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;
}
于 2011-09-16T11:34:20.013 回答
-2

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

于 2011-09-16T11:01:58.213 回答