I want to add some descriptive text on the promo code field that says "enter your promo code!", so firstly i added a new define to includes/languages/english/modules/order_total/ot_coupon.php
define('CODE_SUBMIT_DEFAULT_TEXT','enter your promo code!');
I then changed line 137 of includes/modules/order_total/ot_coupon.php from
'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),
to
'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)" class="promo-code-box" value="' . CODE_SUBMIT_DEFAULT_TEXT . '" onfocus="if (this.value == \'' . CODE_SUBMIT_DEFAULT_TEXT . '\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'' . CODE_SUBMIT_DEFAULT_TEXT . '\';"'),
followed by changing line 158 from
if ((isset($_POST['dc_redeem_code']) && $_POST['dc_redeem_code'] != '') || (isset($discount_coupon->fields['coupon_code']) && $discount_coupon->fields['coupon_code'] != '')) {
to
if ((isset($_POST['dc_redeem_code']) && $_POST['dc_redeem_code'] != '' && ($_POST['dc_redeem_code'] != CODE_SUBMIT_DEFAULT_TEXT)) || (isset($discount_coupon->fields['coupon_code']) && $discount_coupon->fields['coupon_code'] != '')) {
The problem I have is that when I click the Continue button, checkout does not move to the next step. If I remove the edit from line 158, I get the message stack warning to say that the coupon code is invalid due to the value of CODE_SUBMIT_DEFAULT_TEXT being stored.
Looking at the code, I thought that the if statement at line 158 was what was checking for a blank field, i.e. no coupon code present, and so telling it to ignore the entry if it matched the define would be sufficient. Obviously not.
Any suggestions on what else might be amiss here?
Bookmarks