2016-04-05 17 views
0

Payone'u Magento mağazamızla kullanıyoruz. Ayrıca, toplam tutarı belirli bir ödeme yöntemi için çok büyük olduğunda kullanıcılarımızın uyarılarını sepetlerinde göstermek istiyoruz.Magento Payone aktif ödeme yöntemleri nasıl edinilir?

Bu nedenle, her ödeme yöntemi maks sipariş değerine karşılık toplam tutarı kontrol etmek istiyorum.

Ama bir şekilde doğru verilere ulaşamıyorum.

$methods = Mage::helper('payone_core/config')->getConfigPayment($store); 

tüm yöntemlerle bir object->array olsun, ancak korunur:

ben DVD'leri yapılandırma onları elde etmeye çalışmak. Bu yüzden onları sepet modülümde kullanamıyorum.

Payones ödeme yöntemlerini (max_order_value ile tüm aktif yöntemler) almanın temiz bir yolu nedir?

Düzenleme: kod aşağıdaki çalıştı, ama yine de diyor

: Bu ödeme yöntemi Dilim ise

Fatal error: Cannot access protected property Payone_Core_Model_Config_Payment::$methods in /pathToClass/CtaB2c/Helper/Data.php on line 20

bildiğim
class CtaB2c_Helper_Data extends Payone_Core_Helper_Config { 
    public function getConfigPayment($store) { 
     return parent::getConfigPayment($store); 
    } 

    public function showPaymentRestrictions() { 
     $quote = Mage::getSingleton('checkout/session')->getQuote(); 
     $store = $quote->getStoreId(); 
     $total = $quote->getBaseGrandTotal(); 
     $methods = $this->getConfigPayment($store); 
     $methods = $methods->methods; //error occurs here: member has protected access 

     $avaibleMethods = array(); 

     foreach ($methods AS $mid => $method) { 
      $minTotal = $method->minOrderTotal; 
      $maxTotal = $method->maxOrderTotal; 

      if($minTotal <= $total && $maxTotal >= $total) { 
       $avaibleMethods[$mid] = $method->code; 
      } 
     } 

     return $avaibleMethods; 
    } 
} 

da yok yoktur, ama sadece aslında maxOrderTotal'un max_order_total ödeme yöntemlerinden daha büyük olup olmadığını bilmek istiyorum. Ve tabi ki bu ekstra işleve ihtiyacım yok. Fonksiyonumda da parent::getConfigPayment($store)'u arayabilirim. Düzenleme 2 Bu

ben getConfigPayment() aldığım nesnedir: Herhangi bir yöntem herkese açık olmasını

object(Payone_Core_Model_Config_Payment)#<a number> (1) { 
    ["methods":protected]=> 
    array(6) { 
    [<a number>]=> 
    object(Payone_Core_Model_Config_Payment_Method)#<a number> (38) { 
     ["id":protected]=> 
     string(1) "a number" 
     ["scope":protected]=> 
     string(6) "stores" 
     ["scope_id":protected]=> 
     string(1) "<a number>" 
     ["code":protected]=> 
     string(15) "advance_payment" 
     ["name":protected]=> 
     string(8) "Vorkasse" 
     ["sort_order":protected]=> 
     string(1) "<a number>" 
     ["enabled":protected]=> 
     string(1) "<a number>" 
     ["fee_config":protected]=> 
     NULL 
     ["mode":protected]=> 
     string(4) "test" 
     ["use_global":protected]=> 
     string(1) "1" 
     ["mid":protected]=> 
     string(5) "<a number>" 
     ["portalid":protected]=> 
     string(7) "<a number>" 
     ["aid":protected]=> 
     string(5) "<a number>" 
     ["key":protected]=> 
     string(16) "<a key>" 
     ["allowspecific":protected]=> 
     string(1) "0" 
     ["specificcountry":protected]=> 
     array(0) { 
     } 
     ["allowedCountries":protected]=> 
     array(2) { 
     [0]=> 
     string(2) "DE" 
     [1]=> 
     string(2) "AT" 
     } 
     ["request_type":protected]=> 
     string(16) "preauthorization" 
     ["invoice_transmit":protected]=> 
     string(1) "0" 
     ["types":protected]=> 
     NULL 
     ["klarna_config":protected]=> 
     NULL 
     ["klarna_campaign_code":protected]=> 
     NULL 
     ["paypal_express_image":protected]=> 
     NULL 
     ["check_cvc":protected]=> 
     NULL 
     ["check_bankaccount":protected]=> 
     NULL 
     ["bankaccountcheck_type":protected]=> 
     NULL 
     ["message_response_blocked":protected]=> 
     NULL 
     ["sepa_country":protected]=> 
     NULL 
     ["sepa_de_show_bank_data":protected]=> 
     NULL 
     ["sepa_mandate_enabled":protected]=> 
     NULL 
     ["sepa_mandate_download_enabled":protected]=> 
     NULL 
     ["customer_form_data_save":protected]=> 
     NULL 
     ["is_deleted":protected]=> 
     string(1) "0" 
     ["minValidityPeriod":protected]=> 
     string(0) "" 
     ["minOrderTotal":protected]=> 
     string(1) "1" 
     ["maxOrderTotal":protected]=> 
     string(4) "1000" 
     ["parent":protected]=> 
     string(1) "<a number>" 
     ["currency_convert":protected]=> 
     string(1) "0" 
    } 

cevap

0

Hep payone_core/config sınıfı YourNameSpace_Module_Helper_Payone ThePayOneNamespace_Payone_Core_Config uzatır uzatmak ve temelde alabilirsiniz

class YourNameSpace_Module_Helper_Payone extends ThePayOneNamespace_Payone_Core_Config 

    public function someProtectedParentMethod() 
    { 
     return parent::someProtectedParentMethod(); 
    } 
} 

Yukarıdakiler korunan herhangi bir yöntemi kullanmanıza ve daha sonra verdiğiniz verileri almanıza izin verecektir.

+0

Bu işe yaramıyor. Bir çocuk sınıfı olarak değerlere erişemiyorum. Ama nesneyi kontrol etmem gerekecek - sanırım bu bir model ve bundan kurtulmalı mıyım? – Jurik

+0

Yukarıdaki çözüm, normalde erişemeyeceğiniz üst sınıftan korunan yöntemlere erişmenizi sağlar. Sınıfınızın genel bir işlevinin içinde, korunan ve verilerini alan bir ana yöntemi kapatabilirsiniz. Bu işe yaramıyor, ne çalışmadığından emin değilim, ancak ana korunan bir sınıf tarafından ebeveyn korumalı yöntemlere erişmek mümkün olmaktadır. –

+0

Özür dilerim, doğru sınıfı kullanmamaya karar verdim. Ama neyse - sanırım yanlış yol bu olurdu. Düzenlememi görebildiğiniz gibi, bütün bir model geri döndü ve tüm değerler için getter ve setter var. – Jurik

0

Bu, Magones'ın Payones Ödeme yöntemleri hakkında bilgi alma yoludur. Denetleyicinizde bir yerde setPaymentRestrictionNoticeMessage()'u aramanız gerekir.

class YourModule_Helper_Data extends Mage_Core_Helper_Abstract { 
    /** 
    * Returns array of methods that will not work with current max order value. 
    * @return array 
    */ 
    public function getPaymentsWithRestrictions() { 
     $quote = Mage::getSingleton('checkout/session')->getQuote(); 
     $store = $quote->getStoreId(); 
     $total = $quote->getBaseGrandTotal(); 

     /** 
     * @var Payone_Core_Model_Config_Payment $model 
     */ 
     $model = Mage::helper('payone_core/config')->getConfigPayment($store); 
     $methods = $model->getMethods(); 

     $restrictedMethods = array(); 

     foreach ($methods AS $mid => $method) { 
      /** 
      * @var Payone_Core_Model_Config_Payment_Method $method 
      */ 
      $minTotal = $method->getMinOrderTotal(); 
      $maxTotal = $method->getMaxOrderTotal(); 
      $isEnabled = $method->getEnabled(); 

      if($isEnabled && ($minTotal > $total || $maxTotal < $total)) { 
       $restrictedMethods[$mid] = $method; 
      } 
     } 

     return $restrictedMethods; 
    } 

    /** 
    * Sets notification message with information about payment methods 
    * that will not work. 
    */ 
    public function setPaymentRestrictionNoticeMessage() { 
     $restrictedMethodModels = $this->getPaymentsWithRestrictions(); 

     $restrictedMethods = array(); 

     foreach ($restrictedMethodModels AS $methodModel) { 
      /** 
      * @var Payone_Core_Model_Config_Payment_Method $methodModel 
      */ 
      $restrictedMethods[] = $methodModel->getName(); 
     } 

     Mage::getSingleton('core/session')->addNotice(
      Mage::helper('checkout')->__(
       'Your order value is too high for following payment methods: ' . implode(', ', $restrictedMethods) 
      ) 
     ); 
    } 
} 
+0

Cevap bu mu diyor? – Harry

+0

@Harry bu benim için ne işe yarıyor. Ama hala Magento'nun doğru yolu olup olmadığını bilmiyorum. En azından Payones yöntemlerini kullanıyorum. – Jurik

0

Fonksiyonunuzda Payone yapılandırma alın: Payone_Core_Model_Config_Payment yılında

$payoneConfig = Mage::helper('payone_core/config')->getConfigPayment($storeId); 

Eğer $payoneConfig arayabilirler tüm yöntemleri, örneğin bulabilirsiniz getAvailableMethods(). Daha fazla işlevsellik eklemek isterseniz, Payone_Core_Model_Config_Payment'un üzerine Magento yolunu yazın.

İlgili konular