Is there a way to create a single line text field for entering the coupon code? This would be especially useful when only one code is allowed. Also the text under the input box could change depending if you could have more than one coupon code.
Thanks,
Sam
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | single_line.png | 7.43 KB | bellagio |
Comments
Comment #1
ryangroe commentedI believe this could be done with javascript. I can help you with that over the weekend.
Comment #2
sam_RiteTimeDirect commentedgreat
Comment #3
TwistedLincoln commentedI too am interested in such a feature!
Comment #4
ryangroe commentedHere is the javascript:
$(document).ready(function()
{
$(".discount-codes-wrapper").each(function()
{
var wrapper = $(this);
wrapper.find("textarea").attr("rows", 1).css("height", "1em");
wrapper.find(".grippie").hide();
});
});
The way I have my site setup is to add a template.php file to my theme (must be phptemplate theme) with the contents:
<?php
drupal_add_js(drupal_get_path("theme", $GLOBALS["theme_key"]) . "/main.js", "module");
Then add a main.js to my theme with the javascript contents above.
Comment #5
sam_RiteTimeDirect commentedThanks a lot. I will take a crack at it.
Sam
Comment #6
gooddesignusa commentedthanks came in useful. just added this to my page.tpl.php file
Comment #7
ryangroe commentedSam and TwistedLincoln, can you confirm this works for you?
Comment #8
gooddesignusa commentedThe real way would be to have an area in the module for how big the text-area should be. But that really isn't a big deal since this jquery can easily do it. Maybe something to add at the bottom of the to do list.
Comment #9
ryangroe commentedYa, my solution is crude. I will add a global module config section at some point and allow for size changes there.
Comment #10
TwistedLincoln commentedIt does work for me, but doesn't seem to expand the box as needed if you need to add more than one coupon.
Maybe it would be better to have a simple input box (one line, one item), and add the ability for the module to apply coupons separately one at a time. Then have a "remove" link next to the description of each applied code so the user could remove coupons individually if desired.
Comment #11
ryangroe commentedTo make the box user-resizable remove " wrapper.find(".grippie").hide();".
I considered the multiple box idea before but I thought it too difficult for the users of my site. We could revisit it sometime in the future.
Comment #12
ferrangil commentedSubscribing!
A simple value on the settings page would be great for selecting 1 (ie single line) or 5 (ie text area).
Comment #13
RachelNY commentedSubscribing ... would also like to see this on a settings page ...
Comment #14
chrisjohnson commentedcheers using the javascript i got the coupon bar to sick
Comment #15
agilpwc commentedwhat would be the javascript code to hide the text area? I don't use codes on my site, so wanted to get rid of text box in the pane.
Comment #16
Zalatar commented#uc_discounts-pane { display: none; }
Put this in you sites theme style.css file. This will hide the discounts pane on the checkout page.
Z
Comment #17
ezra-g commentedYou could also achieve this server-side with a form alter to change the field from a textarea to a textfield.
Comment #18
tanjerine commentedi just had to implement this one, so i'm posting how i did it (please feel free to correct me if there's a better way of doing this):
first did an alter form (custom module using hook_form_alter):
then altered the uc_discounts.js file (~line 38) since this checks the value of the discount and applies it:
~S
Comment #19
bellagio commented@tanjerine
Could you kindly explain where to put the first code? :)
Comment #20
tanjerine commentedhi bellagio,
I created a custom module with that code:
note: my module's name is alter module page and the file that contains this is alter_modules_page.module
Hope this helps,
~S
Comment #21
bellagio commentedMy knowledge is too short to implement your solution. Sounds like I need to make a module to make this function work. :(
Figuring out how module works is hard enough for me.
I am scratching my head.. but thank you for replying.
Comment #22
jrust commentedComment #20 is definitely the best way to go, no javascript needed. See the example form module if you need help creating a simple module with the code from #20.
Comment #23
bellagio commentednow i have a single line coupon code. Thank you!
This is how i made custom module (for newbies like me).
Make new folder named 'alter_modules_page' under sites/all/modules
copy code from #20 and save it as alter_modules_page.module.
'alter_modules_page' module is not listed under admin/sitebuilding/module because there is no alter_modules_page.info file in the module folder.
create simple .info file like
Then save this as alter_modules_page.info in the alter_modules_page folder
Your new module will be listed under 'Other' in admin/sitebuilding/module. Enable it then you will see single line code(screenshot attached) during the checkout page.
Comment #25
panigrc commentedThank you very much for that.
Comment #26
squarecandy commented#18 works great for me - I had figured out changing the textarea to textfield on the form, but the js part was confounding me. Thanks tanjerine!