[[!formPromoCode]]
if (!isset($_SESSION['promo_code'])) { $output = $modx->getChunk('formPromoCode'); return $output; } else { $output = 'You\'re using Promo Code: ' . $_SESSION['promo_code']; return $output; }
[[!FormIt? &customValidators=`validateCoupon` &validate=`promo_code:required:minLength=^6^:validateCoupon` &promo_code.vTextRequired=`Please enter a Promo Code.` &promo_code.vTextMinLength=`Promo Code must have at least 6 characters in length.` &submitVar=`promo-code-submit` ]] <form id="coupon-form" action="[[~[[*id]]]]" method="POST"> <!-- [[!+fi.validation_error_message:notempty=`<span class="payment-errors">[[!+fi.validation_error_message]] </span>`]] --> <input type="hidden" name="nospam:blank" value="[[+fi.nospam]]" /> <div class="row"> <div class="large-12 columns"> <div class="row collapse"> [[!+fi.error.promo_code:notempty=`[[!+fi.error.promo_code]]`]] <div class="small-8 columns"> <input type="text" name="promo_code" value="[[!+fi.coupon_code]]" /> </div> <div class="small-4 columns"><input class="button postfix" type="submit" name="promo-code-submit" value="Apply" /></div> </div> </div> </div> </form>
if($value != '123456'){ $validator->addError($key,'Promo Code is invalid.'); //$validator->addError($key, $validator->_getErrorMessage($key, 'vTextAllowedFileEmpty', 'No file data found. Please try again!')); return false; } $_SESSION['promo_code'] = $value; $_SESSION['success'] = 'Success! Your promo code ('.$value.') has been applied.'; return true;
This question has been answered by lagpro. See the first response.
[[!FormIt? &hooks=`redirect` &customValidators=`validateCoupon` &validate=`promo_code:required:minLength=^6^:validateCoupon` &promo_code.vTextRequired=`Please enter a Promo Code.` &promo_code.vTextMinLength=`Promo Code must have at least 6 characters in length.` &submitVar=`promo-code-submit` &redirectTo=`46` ]]