how to add validation before submit payment? - prestashop 1.7
Below is payment hook :
public function hookPaymentOptions($params)
{
if (!$this->active) {
return;
}
{
if (!$this->active) {
return;
}
$newOption = new PaymentOption();
$paymentForm = $this->fetch('module:'.$this->name.'/views/templates/hook/payment.tpl');
$newOption->setCallToActionText($this->trans(' PAY ', array(), 'Modules.MyModule.Shop'))
->setModuleName($this->name) /* must add*/
->setForm($paymentForm)
->setAdditionalInformation($paymentForm)
->setAction($this->context->link->getModuleLink($this->name, 'xyz',array("confirmation"=>"1"), true));
return [$newOption];
}
$paymentForm = $this->fetch('module:'.$this->name.'/views/templates/hook/payment.tpl');
$newOption->setCallToActionText($this->trans(' PAY ', array(), 'Modules.MyModule.Shop'))
->setModuleName($this->name) /* must add*/
->setForm($paymentForm)
->setAdditionalInformation($paymentForm)
->setAction($this->context->link->getModuleLink($this->name, 'xyz',array("confirmation"=>"1"), true));
return [$newOption];
}
Validation Process add in js or tpl file
Validation Process add in js or tpl file
<script type="text/javascript">
$( document ).ready(function() {
$( document ).ready(function() {
$('#payment-confirmation > .ps-shown-by-js > button').click(function(e) {
var myPaymentMethodSelected = $('.payment-options').find("input[data-module-name='xyz']").is(':checked');
if (myPaymentMethodSelected)
{
//Validation Process
}
});
if (myPaymentMethodSelected)
{
//Validation Process
}
});
});
</script>
</script>
Comments
Post a Comment