Magento预付款 [英] Magento upfront payment

查看:82
本文介绍了Magento预付款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

For a future project we have been assigned to create a simple concept (inside Magento) that would has to do the following:

客户有能力在不同的运输方式之间进行选择,其中一种是"Ship2Shop",它将产品发送到所选的实体商店,而客户必须去取货. 当客户选择这种"ship2shop"运输方式时,必须在线(通过预定义的付款方式)支付总金额的一定百分比(例如:25%),其余的75%必须通过实体支付顾客去商店时取货.

A customer has the ability to choose between different shipping methods, one of them being "Ship2Shop", which sends the product to a physical store of choice and the customer has to go an pick it up. When a customer selects this "ship2shop" shipping method, a certain percentage (eg: 25%) of the total amount has to be paid online (via a pre-defined payment method) and the remaining 75% has to be paid in the physical store when the customer goes and pick up the products he ordered.

您将如何处理?

我们拥有的想法是修改结帐/订购会话并修改总计"金额(将原件保存在一个会话中).然后,当客户被发送到外部支付处理器时,修改后的总计"将被发送出去.一旦客户在magento平台上退货,我们将通过恢复原始总计的方式并更新已支付的总金额和应付的总金额来修改订单.

Idea that we were having is modify the checkout/order session and modify the "grand total" amount (saving the original in a session ofcourse). When the customer is then sent to the external payment processor the "modified grand total" is sent along. Once the customer returns on the magento platform we would modify the order by restoring the original grand total the way it was and updating the total paid and total due amount.

有人对此有其他想法吗?

Anyone got any other ideas about this?

在收到来自以下Anton S的反馈后,我设法添加了预付款总额".但是我仍然有一个问题 在config.xml中,我在标记中添加了以下内容:

After feedback from Anton S below I managed to add an "advance payment total". However Im still having a problem In the config.xml I have added the following in the tag:

acsystems_advancepayment/total_custom 累计

acsystems_advancepayment/total_custom grand_total

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

I want my advance payment to show AFTER the grand total, for some reason, magento won't do that...

收集方法

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;
    }

推荐答案

请参阅此线程,其中说明了添加总对象的操作

refer to this thread where adding total objects is explained Magento: adding duties/taxes to a quote during review

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

Basically you should add your own total object based on your shipping method selection, then it will also be shown in totals as separate row and you can show this in every e-mail or place where totals are exposed

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;
}

这篇关于Magento预付款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆