2012-04-30 15 views
1

このチュートリアル(http://www.magentocommerce.com/wiki/5_-_modules_and_development/payment/create-payment-method-module)でお支払い方法を作成する手順に従っています。 )すべて正常に動作しますが、私は追加の機能が必要です。Magentoの発送方法に請求金額を追加する方法

  • お支払い方法が選択されている場合、合計6%の追加料金が加算されます。

私もこのモジュールを使用します - http://www.magentocommerce.com/magento-connect/payment-method-charge-4050.htmlしかし、私は2つの条件が必要です。だから私は新しい支払い方法を作成しました。

  • 第一支払方法 - 6%のチャージ
  • 第二支払方法 - 2%の手数料事前に

感謝。

答えて

1

おそらくあなたは自分が必要とされている何をすべきか、オブザーバを作成したいとしてより多く:

あなたはしかし、ここで、にフックするための適切な観測イベントを見て回る必要がありますは、例えば、観察方法であります

  • http://www.candesprojects.com/magento/add-payment-method-handling-cost/
  • :この記事からの引用

    public function updateShippingAmount($observer) 
    { 
        $MyPaymentMethod = Mage::getSingleton('namespace/mypaymentmethod'); 
    
        $order = $observer->getEvent()->getOrder(); 
        $payment = $order->getPayment()->getData(); 
    
        if($payment['method'] == $MyPaymentMethod->getCode()) 
        { 
         $shipping_amount = $order->getShippingAmount(); 
         $order->setShippingAmount($shipping_amount + $MyPaymentMethod->getPostHandlingCost()); 
        } 
    } 
    

    オブザーバを作成する方法について

もっと読み:

1

最近、私は同じ要件を持っていると私はイベントオブザーバメソッドを実装することで固定。あなたがイベントを実装することにより、任意の条件のいずれかの配送方法への追加送料を追加することができます実際に
sales_quote_collect_totals_before
と(ただしダミーコード)オブザーバモデル法と呼ばれるようになっています

public function salesQuoteCollectTotalsBefore(Varien_Event_Observer $observer) 
    { 
     /**@var Mage_Sales_Model_Quote $quote */ 
     $quote = $observer->getQuote(); 
     $someConditions = true; //this can be any condition based on your requirements 
     $newHandlingFee = 15; 
     $store = Mage::app()>getStore($quote>getStoreId()); 
     $carriers = Mage::getStoreConfig('carriers', $store); 
     foreach ($carriers as $carrierCode => $carrierConfig) { 
      if($carrierCode == 'fedex'){ 
       if($someConditions){ 
        Mage::log('Handling Fee(Before):' . $store->getConfig("carriers/{$carrierCode}/handling_fee"), null, 'shipping-price.log'); 
        $store->setConfig("carriers/{$carrierCode}/handling_type", 'F'); #F - Fixed, P - Percentage     
        $store->setConfig("carriers/{$carrierCode}/handling_fee", $newHandlingFee); 

        ###If you want to set the price instead of handling fee you can simply use as: 
        #$store->setConfig("carriers/{$carrierCode}/price", $newPrice); 

        Mage::log('Handling Fee(After):' . $store->getConfig("carriers/{$carrierCode}/handling_fee"), null, 'shipping-price.log'); 
       } 
      } 
     } 
    } 
+0

あなたはどんな側 - に気づくくださいこのような方法でストアの設定値を設定することで、 – pspahn

関連する問題