Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 4 of 4

Thread: Use JavaScript to Automatically Fire / Click Add To Cart Button

  1. #1
    aspuser is offline Junior Member
    Join Date
    Nov 2011
    Posts
    2

    Default Use JavaScript to Automatically Fire / Click Add To Cart Button

    In a sub directory I have a micro site with a "buy now" button that links to the actual product page in the main store.

    The idea is that they select the quantity on the micro site and click "buy now". This should then go to the product page, change the quantity and "click" Add to Cart, so that they automatically end up in the Shopping Cart.

    So far I have managed to use JavaScript, in the product description input, to adjust the quantity figure.

    However I have been unable to make the Add to Cart button to fire!!

    Can anyone help?

  2. #2
    fooster is offline Member
    Join Date
    Jan 2007
    Posts
    98

    Default

    I would look to call a webservice addtocart from your micro site with jquery. Just make sure you do a post to the asmx (look at the actionservice.cs file in app code directory)

    This way you can programmatically add to cart and then display a message or redirect to a new page.

    Ben

  3. #3
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Surely an easier way would be just to link to addtocart.aspx ?

    You can add ProductID, VariantID, Price, Qty as (optional) querystring parameters,

    EDIT - here's an example of the addtocart.aspx link :-

    www.3mselect.co.uk/addtocart.aspx?productid=1593&variantid=1625&a mp;quantity=1

    & in its most simple format :-

    www.3mselect.co.uk/addtocart.aspx?productid=1593




    Alternatively - you can build a complete cart externally & then submit it using tableorder_process.aspx which lets you submit multiple products - here are a couple of demos that do just this:-

    http://www.ultrathon.co.uk
    http://www.3mcarcare.co.uk



    Also worth pointing out that on the Ultrathon site - I have the price & availability updated in realtime by a javascript file that is dynamically generated from an xmlpackage.




    TTFN

    BFG
    Last edited by BFG 9000; 11-18-2011 at 12:09 PM.

  4. #4
    aspuser is offline Junior Member
    Join Date
    Nov 2011
    Posts
    2

    Default

    @BFG 9000: Thank you very much. Linking to addtocart.aspx and using query string parameters was just what I needed.