2011-09-16 172 views
0

對於未來的項目,我們已分配給創造一個簡單的概念(內Magento的),它應該具有執行以下操作: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; 
    } 
+0

那麼這是做什麼$ address-> setAdvancePayment($ calculatedAmount); ? –

+0

如果我沒有設置,那麼我的「預付款」行不會顯示在購物車概覽/檢查結帳中。 (我猜這是相同的 - > setData(「advance_payment」) – Kenny

+0

確定你的問題是baseAmount和金額在你的收藏期間不會被清除,如果它連續被多次調用,那就是什麼paretn :: collect($地址);正在做你的方法的頂部。但是你必須確保你的calculateAmount總是從0開始計算 –

回答

2

指這個線程,其中添加的總目標是解釋Magento: adding duties/taxes to a quote during review

基本上你應該根據你的送貨方式選擇添加自己的總目標,那麼它也將在總數爲單獨一行顯示,你可以在合計暴露每一個e-mail或地方顯示此

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

謝謝,會看看它,並標記爲答案,如果這真的是我們正在尋找的解決方案, 提前致謝! – Kenny

+0

我成功將「預付款」總額添加到了quote_address,訂單和發票。還有一些事情正在困擾着我,我會給你發一條消息;)[編輯:似乎不能傳達你的信息:D]查看問題文章瞭解更多信息。 – Kenny

+0

每個總對象都有順序,你可以在你的system.xml中應用它,並且Grand Total有點硬編碼爲該行的最後一個,請參閱此條件的總計塊 –

-2

另一種方法是改變「grand_total」付款模塊中,這樣的會議不會改變..

+0

我們也考慮過這個問題,但是當客戶被引用到外部支付處理器(例如總計100美元)並且他在支付後返回到Magento平臺時,它將驗證支付的金額是否等於保存在客戶會話(按順序)。 – Kenny

+0

你不能在那裏編輯支票嗎? – ChrisH

+0

這是討厭的,如果你需要實現,然後實現自己的總目標是改變其他總計會毀了計算非常快 –