2016-04-07 23 views
0

Yeni bir ödeme yöntemi oluşturuyorum. Bu yeni ödeme yöntemi ile müşteri ürünü, yalnızca sorulan soruya doğru yanıt verirse satın alır. Müşterinin bir cevap seçtiğini nasıl doğrularım? Buna ek olarak, bir müşteri doğruysa daha sonra kontrol etmek için müşteri yanıtı dışında?Radyo butonu nasıl onaylanır?

uygulama/tasarım/kullanıcı arayüzü/baz/default/şablon/custompaymentmethod/form/custompaymentmethod.phtml: Bizim özel bir ödeme yöntemi için özel bir ödeme formunu görüntülemek için kullanılan bir şablon dosya.

<?php 
$question = Mage::getModel('emme_question/question')->getCollection()->getLastItem(); 
$answers = $question->getSelectedAnswersCollection(); 
?> 
<div id="custompaymentmethod-question"> 
    <h4><?php echo $this->escapeHtml($question->getValue()); ?></h4> 
    <ul> 
    <?php foreach ($answers as $answer): ?> 
    <li> 
    <label><?php echo $this->escapeHtml($answer->getValue()) ?></label> 
    <input type="radio" name="my_custom_answer" value="<?php echo $answer->getId() ?>" required> 
    </li> 
    <?php endforeach ?> 
</div> 
<script> 
jQuery(function ($) { 
    $('#co-payment-form').on('change.mm', function() { 
    var is_question_active = ! $('#p_method_custompaymentmethod').is(':checked'); 
    $('#custompaymentmethod-question input').attr('disabled', is_question_active); 
    }) 
}) 
</script> 

app/kod/yerel/Envato/Custompaymentmethod/Model/Paymentmethod.php: doğrulanması ve özel bir ödeme alanlar bilgileri kaydetmek için kullanılan bir model dosyası var. benim zavallı İngilizce

cevap

0

için

<?php 
// app/code/local/Envato/Custompaymentmethod/Model/Paymentmethod.php 
class Envato_Custompaymentmethod_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract { 
    protected $_code = 'custompaymentmethod'; 
    protected $_formBlockType = 'custompaymentmethod/form_custompaymentmethod'; 
    protected $_infoBlockType = 'custompaymentmethod/info_custompaymentmethod'; 

    public function getOrderPlaceRedirectUrl() 
    { 
    return Mage::getUrl('custompaymentmethod/payment/redirect', array('_secure' => false)); 
    } 
} 

Üzgünüm

<?php 
// app/code/local/Envato/Custompaymentmethod/Model/Paymentmethod.php 
class Envato_Custompaymentmethod_Model_Paymentmethod extends Mage_Payment_Model_Method_Abstract { 
    protected $_code = 'custompaymentmethod'; 
    protected $_formBlockType = 'custompaymentmethod/form_custompaymentmethod'; 
    protected $_infoBlockType = 'custompaymentmethod/info_custompaymentmethod'; 

public function validate() 
{ 
    foreach (Mage::getModel('emme_question/question')->load(1)->getSelectedAnswersCollection() as $answer) 
    { 
    if ($answer->getIsCorrect()) 
    { 
     if ($answer->getId() == $_POST['my_custom_answer']) 
     { 
      Mage::getSingleton('core/session')->addSuccess('Risposta esatta'); 
     } else 
      { 
        Mage::throwException('Risposta sbagliata!'); 
      } 
    } 
    } 
} 

    public function getOrderPlaceRedirectUrl() 
    { 
    return Mage::getUrl('custompaymentmethod/payment/redirect', array('_secure' => false)); 
    } 
} 
çözüldü
İlgili konular