Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*Urgent Please* Discount Coupon Code Support #108

Closed
thegreatrat opened this issue Jun 15, 2011 · 8 comments

Comments

@thegreatrat
Copy link

commented Jun 15, 2011

Hi! I'm working on a project where I need to place discount code option in the cart. I didn't find code for coupon code in the latest version of SimpleCart.js.

However, I found an old script from Google Code.

http://code.google.com/p/jscart/wiki/Example

I copied the code for that discount option and pasted it in latest code. Its working well in the cart. But, discount price not showing during the paypal checkout. However, it is showing original total price. Here is the custom SimpleCart.js code. The new discount code is at Line 841. And I want an input for entering URL..... which will be attached during checkout.

Thank you.

/* code removed for brevity */
@ghost

This comment has been minimized.

Copy link
Collaborator

commented Jun 15, 2011

thegreatrat could you narrow down the parts that you updated so I can get a better idea of what changes you made? thanks!

@thegreatrat

This comment has been minimized.

Copy link
Author

commented Jun 15, 2011

Hi! Thanks for your reply!

    /******************************************************
                Cart Update managment
     ******************************************************/

    me.update = function() {
        if( !simpleCart.isLoaded ){
            simpleCart.load();
        }
        if( !simpleCart.pageIsReady ){
            simpleCart.initializeView();
        }
        me.updateTotals();
        me.updateView();
        me.save();
    };

    me.updateTotals = function() {
            
        me.total = 0 ;
        me.quantity  = 0;
        me.each(function(item){ 
            
            if( item.quantity < 1 ){
                item.remove();
            } else if( item.quantity !== null && item.quantity !== "undefined" ){
                me.quantity = parseInt(me.quantity,10)   parseInt(item.quantity,10);
            }
            if( item.price ){
                me.total = parseFloat(me.total)   parseInt(item.quantity,10)*parseFloat(item.price);
            }
            
        });
        me.shippingCost = me.shipping();
        me.taxCost = parseFloat(me.total)*me.taxRate;
        me.finalTotal = me.shippingCost   me.taxCost   me.total - me.couponcode;
    };
    
    me.applydiscount = function() {
        
        var ccode = document.getElementById('ccv').value;
        
        
        if (ccode == "FB007") {
            
                me.couponcode = 7;  
                alert("Discount Successfully Applied!");
        }
        else if (ccode == "PROMO3850") {
            
                me.couponcode = 38.50;  
                alert("Discount Successfully Applied!");
        }
        else if (ccode == "LESS10") {
            
                me.couponcode = 0;  
                alert("Code Expired");
        }           
        else {
            
            me.couponcode = 0;
            alert("Invalid Code!");           
            
        }
        
        document.getElementById('couponcode').innerHTML = "Discount: $"   me.couponcode.toFixed(2)   " <br />";
        me.update();
    }

That's the code which i added.

@ghost

This comment has been minimized.

Copy link
Collaborator

commented Jun 16, 2011

The issue with applying the code in PayPal is that you are sending the prices for items, and PayPal is calculating the total on their end. Thus, any discount would need to be applied there (if this is possible, I can try to work it into future versions).

In the meantime however, I would suggest applying the discount to individual items at the time of checkout. If I get some time this weekend, I will put together some code. Let me know if you have an questions about how to implement it if you feel like taking a crack at it.

@secureip-zz

This comment has been minimized.

Copy link

commented Jan 11, 2012

I have the same problem. To update the price on a product with a %, I make a another page who update the price when I list it. But now, I want to apply a discount in $ over the total price. How can I do that? Thx

@Dudikowski

This comment has been minimized.

Copy link

commented Jan 14, 2012

I found Paycodes.com which is a coupon code alternative for Paypal. It costs 25$ per year to subscribe to the service. I thought it could be worth a try.

Unfortunately I get a "data does not match input character set or default encoding" error when transferring back from their site. There are other issues as well.

I'm just mentioning this service in case someone else might have more input about this alternative.

@artboxmedia

This comment has been minimized.

Copy link

commented Aug 22, 2013

Has anyone got this working as i have tried but had no luck

@pizza-r0b

This comment has been minimized.

Copy link

commented Nov 29, 2013

I came up with a solution here: https://github.com/realseanp/SimpleCart-JS-Promo-Code/tree/master
feel free to expand on it. The basic principle is that the discount is applied to the items in the cart. There are some flaws as well as security vulnerabilities, but the same goes for simple cart js :)

@alicans

This comment has been minimized.

Copy link

commented Oct 24, 2018

I came up with a solution here: https://github.com/realseanp/SimpleCart-JS-Promo-Code/tree/master
feel free to expand on it. The basic principle is that the discount is applied to the items in the cart. There are some flaws as well as security vulnerabilities, but the same goes for simple cart js :)

can you re-upload it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.