12 / 12
Aug 2017

Is there a way to SELECTIVELY show a coupon code only on specific Add to Cart or Buy It Now buttons? I don't like having the coupon code window showing normally because customers think there should be a discount. I just want to be able to create a special webpage that I direct mailing list customers to that allows them to enter a coupon code, but I don't want to show this to the general public.

  • created

    Feb '11
  • last reply

    Aug '17
  • 11

    replies

  • 2.3k

    views

  • 5

    users

  • 11

    links

You can hard-code a discount code into Add to Cart buttons by adding &discount_code=YOURCODEHERE to the button URL, like so:



<a href="https://www.e-junkie.com/ecom/gb.php?c=cart&i=XXXXX&cl=48961&ejc=2&discount1code=YOURCODEHERE&custom=76" target="ej_ejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"><img src="http://www.e-junkie.com/ej/ej1add_to_cart.gif" border="0" alt="Add to Cart"/></a>



For Buy Now buttons, you'd need to use &on0=Promotion&os0=YOURCODEHERE instead:



<a href="1https://www.e-junkie.com/ecom/gb.php?i=XXXXXX&c=single&cl=48961&on0=Promotion&os0=YOURCODEHERE1" target="ejejcsingle"><img src="http://www.e-junkie.com/ej/x-click-butcc.gif" border="0" alt="Buy Now"/></a>



To hide the Discount Code field in the cart, you'd need to add this to your View Cart code on every page, just before the "// -->" line in the standard View Cart code you obtained from Seller Admin:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#dscnt_cd").remove();

jQuery('input[name="discount_code"]').remove();

jQuery("#discount2").remove();

}

Thank you for these inputs. This looks like just what I need.



I will definitely try them out later this week when I have some time.

E-junkieguru:



I pasted this code that you provided on my View Cart page, just before the "// -->" line in the standard View Cart code, as you directed:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#dscnt_cd").remove();

jQuery('input[name="discount_code"]').remove();

jQuery("#discount2").remove();

}



It worked just as expected, preventing the coupon code box from being displayed - NICE!



UNFORTUNATELY, THERE IS A BAD SIDE EFFECT OF THIS CODE. When I click the "Remove" box and "Update Cart" I don't get the Cart is Empty page. Instead, Firefox gives me a blank page with this long URL:



https://www.e-junkie.com/ecom/gb.php?rc=&rct=&remove3array[0]=1&ci_id_array[0]=26942708&sub_item_id_array[0]=26942708&item_number_array[0]=201985&quantity_array[0]=1&cart_item_price_array[0]=&total_item_price_array[0]=99&to_country=US&zipcode=75019&shtx_calc_done=true&cart_total=99&min_cart_item_total=0.00&cart_error_code=0&page_ln=en&shtx_calc_needed=true



I also tried Internet Explorer 8 and it does nothing when I click "Update Cart". It doesn't remove the checked item from the cart.



I would leave up my www.hoa-resources.com site for you to see this directly but I don't want to lose a sale.



I'm confident I used your exact code because I cut & pasted rather than trying to type the exact syntax. This View Cart code change is the ONLY change I made to my webpage file.



Any suggestions?

Aha, it appears that completely removing the text field for entering a discount code causes that problem, but we can still use a different approach to simply hide that field without actually removing it from the page structure, which seems to fix the problem:



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#dscnt_cd").remove();

jQuery('input[name="discount_code"]').attr("style", "display:none;");

jQuery("#discount2").remove();

}

E-junkieGuru:



This works just fine!



This is the only edit that I really need to make. My standard page has the discount code box hidden so prospective customers don't think they are missing out on some obscure discount.



Meanwhile, I have a special order page that I can email to promo customers that shows the box so they can enter a discount code.



THANKS!

I like this approach - I too hate the coupon code box - but I do have a group of customers that I would like to offer a coupon code - can you email me your special order page so i can see how you handle this



info@bunkbedking.com



thanks



denis

I'd rather not email you, but you can view my standard order page at www.HOA-Resources.com1. Select "Order Now."



All I did was set up a discount/coupon code in the e-Junkie admin section. This shows the discount code box. Next, I added the following code to hide the discount code box, as directed by the E-junkieGuru. (You need to add this to your View Cart code on every page, just before the "// -->" line in the standard View Cart code you obtained from Seller Admin):



function EJEJC_config() {

EJEJC_POSTCALL=true;

}

function EJEJC_shown() {

jQuery("#dscnt_cd").remove();

jQuery('input[name="discount_code"]').attr("style", "display:none;");

jQuery("#discount2").remove();

}



The special order page is identical to my original order page. It doesn't have the above code to hide the box, so it shows. This page has a private URL that I email to customers for promotions.

3 years later

This is an older post but I noticed that this method doesn't seem to work on mobile device.

Yes, our cart customization code only works on the overlay-style cart that displays "inside" your own page. On mobile devices, the cart works in "fallback" mode by displaying in a popup window/tab to make best use of the available screen size and support touchscreen pan/zoom pinch/swipe gestures, but this version of the cart cannot be customized beyond displaying your uploaded custom logo/header image.

2 years later

Hello. It's been 3 years since this last response. However, I'm very keen to do this same thing. I'd like to display the cart, across all computers, browsers and devices, and hide the discount box. However, I'd also like to either have a hidden page WITH the discount box, or the ability to generate a link with discount codes in it: ?product=MyBook&DiscountCode1=FreeBook&DiscountCode2=FreeShipping

Can someone direct me to the options to do this? I know there's a new mobile friendly cart which I haven't yet used. I want to use the best version of the cart and checkout, but without the discount box.

Thanks!

The Discount Code box only appears in the cart when the buyer's order is actually eligible for some discount(s) you have created.

Our new cart (currently concluding beta testing) cannot be customized, but if you're using our classic cart, you can use the cart customization approach above to hide the Discount Code field and label.

Note that classic cart customization code is page-specific, so you'd need to add the customization code on every page where you have cart buttons, and it only works when the cart displays as an overlay within your page, so it would have no effect when the cart displays in "fallback" mode using a separate window/tab, such as when the buyer is using a mobile device or has Javascript disabled in their browser.

This help page explains how to create a purchase link that includes a discount code: