Help with rewards feature and shopping cart javascript

General ShopSite user discussion

Help with rewards feature and shopping cart javascript

Postby dgray » Thu Jul 16, 2015 10:43 am

Some of my customers forget to use a free reward in their cart, and ask me to adjust their orders after the fact. Which is fine, but time consuming.

So I'm working on some javascript to add to the built-in CheckIt function on the OrderSystem->Shopping Cart page to remind customers if they have unused rewards when they press the Checkout button.

I'm ok with counting the products and rewards already in the cart, from the supplied javascript variables. The only thing I'm missing is an automatic way to detect that I've got a promotion going. Otherwise I'll mistakenly tell them they have a reward due, when there's no promotion running. I just need to know that at least one reward has been earned, hence a promotion is running.

I see that the shopping cart includes some html <table class="program_reward_order"> where it shows the "You have earned a Reward" text. Can you think of a way I can detect the presence of this in my javascript? Or perhaps there's some variable I can access that says a reward has been earned?
dgray
 
Posts: 54
Joined: Fri Sep 08, 2006 9:06 am

Re: Help with rewards feature and shopping cart javascript

Postby ShopSite Lauren » Fri Jul 17, 2015 12:23 pm

You could add something like the following into the CheckIt function.

if ((document.body.innerHTML.toString().indexOf('program_reward_order') > -1) && (document.body.innerHTML.toString().indexOf('- Free Reward') == -1)) {
alert("It contains a reward alert and no rewards have been redeemed");
return false;
}

Note, you would need to make sure that when someone redeems a reward, it says - Free Reward. If you have changed that text to something else, you would need to change my code above to reflect that change.
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: Help with rewards feature and shopping cart javascript

Postby dgray » Sat Jul 18, 2015 3:57 am

That's perfect, just what I was looking for, thanks Lauren!
dgray
 
Posts: 54
Joined: Fri Sep 08, 2006 9:06 am


Return to User Forum

Who is online

Users browsing this forum: No registered users and 86 guests