Support Icon
NEW JAVASCRIPT CODE | PayPal Discount Code

Dec 11 '11

By: Richard Guidry
Coding: JavaScript
Project: PayPal Discount Code

JavaScript PayPal 'Discount Code' for Wojo Groups SimpleCart.js

A working script that will apply (In this Case) a 10% Discount on all cart items after the user/customer clicks the 'Checkout' button.

I used and modified's "Web Page Password Protect" for entering the discount code. Please visit on items/instructions of its uses.

Find this Line in the simpleCart.js (Version = '2.2.2')

form.appendChild( me.createHiddenElement( "amount_" + counter, item.price ) );

And Modify it to This

form.appendChild( me.createHiddenElement( "amount_" + counter, this.currencyStringForPaypalCheckout( (item.price)* discount ) ) );


I should also mention that for the Discount Code Entry Page; I used ''Web Page Password Protect'' from


A few notes:

Pay close attention to the ''cart.php'' and the ''cart_discount.php'' files; in particular the cart.php file's include statement:

<?php include("/home/uswsc3/public_html/discount_example/cart_discount.php"); ?>

To find your relevant path (like the one above) use the following syntax:

Will continue to redirect to ''cart_discount.php'' page until the correct ''Discount Code'' is entered.

Once the correct ''Discount Code'' is entered however, the redirect no longer exist and the ''cart.php'' page is loaded. This is where the 10% Discount cookie is set.

The code uses two (cookies) to operate.

''discount'' cookie sets the 10% (.9) Discount.

''verify'' verifies the discount was set to .9

All cookies (including the simpleCart cookies) have been set to 1 day (24 Hours).

-Richard Guidry / U.S. Website Creations
View Working Example  Download Example (Zip)
SimpleCart JavaScript Discount Code PayPal Discount Code SimpleCart.js


(Your E-Mail Address Will NOT Be Shared or Published)

Follow Me On Google

U.S. Website Creations

By building a website with HTML, CSS, JavaScript, and PHP, just about anything is possible. Browse this site for examples of the type of Website Development I can do for you...


Website Development, PhP and/or JavaScript Programming, eCommerce Web Development, MySQL Database Development, SEO Services, Full-Service Web Hosting, and Web Consultant are all here.


Wings Over Colorado, LLC. | Stacys Got Greek | Central Gun Exchange, LLC. | and many more...

U.S. Website Creations Text
Powered by Awesome