自定义付款方式模块

我正在根据问题/答案创建付款方法,其中来自预定义问题池的随机问题的正确答案作为付款有效。自定义付款方式模块

// 1) Here I take the question with ID = 1 cycle and the possible answers 

foreach (Mage :: getModel ('emme_question/question') -> load (1) -> getSelectedAnswersCollection() as $ answer) {

// 2) for each control response if it is the correct one and if it has the same ID as the one chosen by the user

     if ($ answer-> getIsCorrect() && ($ answer-> getId() == $ _POST ['my_custom_answer'])) {

// 3) if so show a success message to the user

        Mage :: getSingleton (core/session ') -> addSuccess (' Correct answer ');

        // You should be able to go to the next step

     } Else {

// 4) in the event unleashed an exception to stop the negative checkout (and returning the user to the homepage)

         Mage :: ThrowException ('Wrong answer!');

     }

}

你帮忙完成了代码?

回答:

我解决

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!');

}

}

}

}

以上是 自定义付款方式模块 的全部内容, 来源链接: utcz.com/qa/258715.html

回到顶部