Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Posts
    331
    Plugin Contributions
    0

    help question How to - Split the Discounts/Coupons Code field into two fields

    Greetings,

    Using ZC 1.5.4

    I'm interested in splitting the Discounts/Coupons Redemption Code field on the payment page into two fields, something like Enter Blue Code, Enter Green Code. Then, after the payment is submitted, simply concatenate them back together before the code is verified.

    It's really just about appearance. Why you may ask, well...we are thinking of doing a mix and match promo game of codes on cards that will be mailed out to customer in their orders of a period of time. If a customer gets two of the correct codes, then they can use them to receive a discount. Yes, they can simply enter them together in one field, but again, it's the appearance we are going for!

    Thanks
    Experience is what you get when you don’t get what you want…

  2. #2
    Join Date
    Dec 2007
    Location
    Acton, California
    Posts
    706
    Plugin Contributions
    9

    Default Re: How to - Split the Discounts/Coupons Code field into two fields

    Quote Originally Posted by kwright View Post
    Greetings,

    Using ZC 1.5.4

    I'm interested in splitting the Discounts/Coupons Redemption Code field on the payment page into two fields, something like Enter Blue Code, Enter Green Code. Then, after the payment is submitted, simply concatenate them back together before the code is verified.

    It's really just about appearance. Why you may ask, well...we are thinking of doing a mix and match promo game of codes on cards that will be mailed out to customer in their orders of a period of time. If a customer gets two of the correct codes, then they can use them to receive a discount. Yes, they can simply enter them together in one field, but again, it's the appearance we are going for!

    Thanks
    You would have to edit modules/order_total/ot_coupon.php to create two input fields and tests, then combine for final testing... ideally, creating a new ot_coupon named for this edit, that way you could turn one on or off depending and what sale program you are running.
    Dave
    Working on a new project... MySite..

  3. #3
    Join Date
    Nov 2004
    Posts
    331
    Plugin Contributions
    0

    Default Re: How to - Split the Discounts/Coupons Code field into two fields

    Quote Originally Posted by davewest View Post
    You would have to edit modules/order_total/ot_coupon.php to create two input fields and tests, then combine for final testing... ideally, creating a new ot_coupon named for this edit, that way you could turn one on or off depending and what sale program you are running.
    Thanks davewest,

    The issue I found when adding a new input field in ot_coupon.php is that the code that renders the fields (tpl_checkout_payment_default.php) will also create a new <fieldset> for that added field. So you get two Discount Coupon boxes on the payment page, one for the original coupon code, the other for the new field. Unlike the credit card code, which creates only one <fieldset>, followed by all of the form elements for that <fieldset>.

    Think I'll look at that code!
    Experience is what you get when you don’t get what you want…

  4. #4
    Join Date
    Dec 2007
    Location
    Acton, California
    Posts
    706
    Plugin Contributions
    9

    Default Re: How to - Split the Discounts/Coupons Code field into two fields

    Quote Originally Posted by kwright View Post
    Thanks davewest,

    The issue I found when adding a new input field in ot_coupon.php is that the code that renders the fields (tpl_checkout_payment_default.php) will also create a new <fieldset> for that added field. So you get two Discount Coupon boxes on the payment page, one for the original coupon code, the other for the new field. Unlike the credit card code, which creates only one <fieldset>, followed by all of the form elements for that <fieldset>.

    Think I'll look at that code!
    I don't have a ZC154 page with me, so guess 155 maybe close... around line 138 you would add another input field after the 'field' =>
    Code:
    zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '"') . '<br />' . zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),
    I would re-code the jscript to test both fields so it does not leave unless both are full or empty.. you could use the jscript to combine...or around line 159 you need to combine and test...

    I'm out in the Mojave playing in the dirt, so can't give you much more...
    Dave
    Working on a new project... MySite..

  5. #5
    Join Date
    Nov 2004
    Posts
    331
    Plugin Contributions
    0

    Default Re: How to - Split the Discounts/Coupons Code field into two fields

    Quote Originally Posted by davewest View Post
    I don't have a ZC154 page with me, so guess 155 maybe close... around line 138 you would add another input field after the 'field' =>
    Code:
    zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '"') . '<br />' . zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),
    I would re-code the jscript to test both fields so it does not leave unless both are full or empty.. you could use the jscript to combine...or around line 159 you need to combine and test...

    I'm out in the Mojave playing in the dirt, so can't give you much more...
    Woot, use to love riding out in Mojave, Red Rocks and Jawbone too!

    Thanks for the suggestions. 1.5.4 is a bit different than 1.5.5 in this area. I was able to move all of the <fieldset> data that only needed to be displayed once outside of the for loop. Added the extra field to the fields array, works great! I can now use this same method for the Your Store Gift Cards mod and add a CVV field, which our gift cards use.

    Enjoy!
    Experience is what you get when you don’t get what you want…

  6. #6
    Join Date
    Dec 2007
    Location
    Acton, California
    Posts
    706
    Plugin Contributions
    9

    Default Re: How to - Split the Discounts/Coupons Code field into two fields

    Quote Originally Posted by kwright View Post
    Woot, use to love riding out in Mojave, Red Rocks and Jawbone too!

    Thanks for the suggestions. 1.5.4 is a bit different than 1.5.5 in this area. I was able to move all of the <fieldset> data that only needed to be displayed once outside of the for loop. Added the extra field to the fields array, works great! I can now use this same method for the Your Store Gift Cards mod and add a CVV field, which our gift cards use.

    Enjoy!
    OK.. turns out the location of where the code change is works the same for both 154 and 155... so, this is super simple without error or testing of any kind, just like its working without the split...

    in ot_coupon.php find line
    Code:
    'field' => zen_draw_input_field('dc_redeem_code', '', 'id="disc-' . $this->code . '" onkeyup="submitFunction(0,0)"'),
    Change to
    Code:
    'field' => zen_draw_input_field('green_redeem_code', '', 'id="disc-' . $this->code . '"') . '<label>Enter Green code above and Red code below.</lable>' . zen_draw_input_field('red_redeem_code', '', 'id="disc2-' . $this->code . '" onkeyup="submitFunction(0,0)"') . zen_draw_hidden_field('dc_redeem_code'),
    then in includes/modules/pages/checkout_payment/jscript_main.php
    find
    Code:
    function submitFunction($gv,$total) { 
      if ($gv >=$total) { 
        submitter = 1; 
      } 
    }
    change to
    Code:
    function submitFunction($gv,$total) { 
      if ($gv >=$total) { 
        submitter = 1;     
      } 
        var red = $(":input[name=red_redeem_code]").val(); 
        var green = $(":input[name=green_redeem_code]").val(); 
        $(":input[name=dc_redeem_code]").val(green+red); 
    }
    So what's going on here..

    in ot_coupon.php we changed the one input to a name of green_redeem_code and added a label to enplane what to do, added another input with a name of red_redeem_code and a hidden input field with the old name so its as if it was a single field as before.

    In the script side we didn't do any testing! We just got the two fields and combined them into one and forced it into the hidden field in the coupon side... This leaves the coupon code to act as it would with only one field. I left the on key up in one field, which is excessive.

    After toying around with the coupons, I see very little feed back to a user for entering the wrong code... I would change that process to make it more user friendly..
    Dave
    Working on a new project... MySite..

 

 

Similar Threads

  1. how to change this two osc code into zc code?
    By sunrise99 in forum General Questions
    Replies: 3
    Last Post: 21 Nov 2011, 05:30 AM
  2. How to remove the zip code field?
    By trickobrien in forum General Questions
    Replies: 1
    Last Post: 23 Jul 2010, 01:12 PM
  3. split cc into two emails
    By Sunabac in forum General Questions
    Replies: 9
    Last Post: 7 Jan 2007, 08:44 PM
  4. Replies: 4
    Last Post: 18 Nov 2006, 05:51 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