0
사전 정의 된 질문 풀에서 무작위 질문에 대한 정답이 결제로 유효한 질문/답변을 기반으로 결제 방법을 만들고 있습니다.맞춤 결제 방법 모듈
// 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!');
}
}
코드를 작성하는 데 도움이 되었습니까?