Community Forums 

Main Content

Passing cookie info to Mals Cart

    Apr 26 2012 19:03:29



    Join date : 2009-06-26      Posts : 52

    Here's my quandry.... :)
    User arrives at the homepage of my website and has the option of entering a user passcode. This passcode is stored in a session cookie. Depending on what the passcode is will affect certain elements within the website. One effect is that the passcode will instruct us to donate 20% of any sales to a charity indicated by the passcode (so it could be one of several charities).

    My problem is - how do i pass this information back to myself if the user makes a purchase. The only communication i have is Mal's Shopping Cart so I need to indicate somewhere in the cart the value of the cookie.

    Any ideas? Something easier than my solution below would be a thumbs up!

    Ok - here's was my solution:
    When the cookie is set i 'post' an item to the shopping cart, value 0.00, with a description of "20% donation to COOKIEVALUE on sales value"
    Where COOKIEVALUE is the name of the charity.

    I could generate most of the form using the javascript document.write command but I'm stuck on 2 points...
    1) how do i integrate a variable (COOKIEVALUE) into a string that makes up the product description? I tried: "20% donation to " + COOKIEVALUE + "on sales value" - wasn't surprised that didn't work! but that's what i was trying to aim at.

    2) I want to 'post' the form instantly - that is the user has just entered his passcode on the website, i don't want to make him submit again - the coding should just recognise that the value entered means i need to add a zero value item to the shopping basket and take him directly there.

    Can anyone can point me towards the coding - or come up with a less complex solution?

    Oh - entering a Voucher Code isn't an option... I already use the voucher codes for other promotions and this charity discount would be on top of any voucher they might want to use.

    Also please note - I don't need to do a 20% discount off the shopping cart - they pay the full amount and we will donate the 20% separately - i just need to know which charity we need to send the donation to.

    Apr 26 2012 20:05:39



    Join date : 2008-09-18      Posts : 488

    You could use mtracker. It is used for affliate tracking but will work for your purposes. You would just redirect people who login to an affliate link for their charity. Then Mal's will keep track of the 20% for you when a purchase is made and you don't have to add anything to the cart.

    As part of your login script you can set a cookie on your own domain that you can use to display a message to the customer that 20% of their purchase will be donated to X charity.

    Apr 27 2012 06:28:22



    Join date : 2008-09-18      Posts : 3235

    Why not have an extra field at the checkout that is a mandatory field and the buyer chooses from a dropdown list the charity to send the 20% to?

    Having trouble with a form or need one building?
    Fast turnaround, but I do charge :)

    Mal's Forms / Scripts and the syntax are here.

    Apr 28 2012 13:22:34



    Join date : 2009-06-26      Posts : 52

    Thanks both! - I'm going to check those out.
    Really appreciate the feedback