Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2005
    Location
    France
    Posts
    581
    Plugin Contributions
    8

    Default Trying to add help text in Coupon code field

    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?

  2. #2
    Join Date
    Nov 2005
    Location
    France
    Posts
    581
    Plugin Contributions
    8

    Default Re: Coupon code field descriptive text.

    Nobody got any ideas on this?

  3. #3
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Coupon code field descriptive text.

    You could use the HTML5 "placeholder" attribute instead of the old approach of injecting a bunch of javascript which might have a mismatched set of quotation marks thus causing your form to break.
    Most modern browsers support the HTML5 placeholder markup even on non-HTML5 templates, so this should work for most visitors.

    Thus, this:
    'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),

    could become something like this:
    Code:
    'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)" placeholder="' . addslashes(CODE_SUBMIT_DEFAULT_TEXT) . '" '),
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Nov 2005
    Location
    France
    Posts
    581
    Plugin Contributions
    8

    Default Re: Coupon code field descriptive text.

    I did look at "placeholder" DrByte, but when I tried it the text stayed visible on the input field even after entering a coupon code. Whether that was due to an error, or the way "placeholder" works, I don't know.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Trying to add help text in Coupon code field

    Quote Originally Posted by strelitzia View Post
    The problem I have is that when I click the Continue button, checkout does not move to the next step.
    That happens when the generated HTML isn't fully valid ... which is typically caused by mismatched single-quotes or double-quotes (which could be inside your language-constant), or extra/missing < or > symbols. (Or nesting forms inside each other, which I'm pretty sure isn't what you're doing here.)

    Running the page source (right-click, choose View Page Source) through an HTML validator to show you which HTML tags are incorrect is a good starting point.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. v151 Send email to address entered in promo code or coupon field
    By butterballz in forum Managing Customers and Orders
    Replies: 1
    Last Post: 1 Mar 2013, 01:03 AM
  2. Add field to coupon area
    By timhersh in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 1
    Last Post: 17 Aug 2012, 03:58 PM
  3. Replies: 0
    Last Post: 24 Jun 2008, 06:54 PM
  4. Help-trying to add text under header...
    By digidollardays in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 4 May 2007, 09:39 PM
  5. Trying to add coupon code to packing slip
    By lukemcr in forum Managing Customers and Orders
    Replies: 5
    Last Post: 10 Apr 2007, 06:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR