Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Make my form pick up the sum total of a script

    Hi everyone

    I've built a third party shopping cart, click here if you'd like to see it:


    http://www.carlinart.net/shoppingcart/index.php


    I want to integrate paypal so the aggregate cart amount is passed to paypal.

    From the online guides at paypal I can read:

    "If you wish, you may aggregate your entire shopping cart and pass the total amount into PayPal's Buy Now Button code (that is, you will need to post a single name for the entire cart and the total price of the cart's contents as though it were a purchase of a single item)."

    Is it really the case that you cannot have a price that changes depending on the customers purchases in your shop?

    I've used this code:



    The field

    <input type="hidden" name="amount_1" value="5.00"/>

    is what seems interesting. How can I have the form read the total calculation of my cart, and not depend on, say, a 5 dollar price that's fixed?

    Could I use a $_POST or $_GET variable in some sneaky fashion to have the form pick up on the calculated total?


    I use a MySql database to describe my products. (right now they're only test books. ) If I have to find an alternate solution because the form can't somehow be made to read the total of the shopping cart, I'd choose the second method of passing individual items to payPal.

    I need some help with this, though. It means my script will have to generate details about each product to upload to paypal? I use Dreamweaver and would greatly appreciate an example of this type of script. Here is what my original script for the shopping cart looks like:



    Also, do I need to edit my product details in the database? Right now they look like this:



    Could someone give an example of which details need to be edited and what to?

    I'm new to scripting, so I hope you will bear with me and answer these beginners questions.

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Pass on $total from showCart() and echo it into the input's value?

  • #3
    New Coder
    Join Date
    Apr 2008
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi, thanks for your reply! I tried this and have uploaded the file. Try clicking the paypal button on the form now and you'll see the error paypal generates: "Your shopping cart is empty". It says this whenever I replace the, say, 5 dollar value with anything else that is not a number. Right now it looks like this:

    <div id="apDiv7">
    <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart"/>
    <input type="hidden" name="upload" value="1">
    <input type="hidden" name="business" value="carina2b@hotmail.com"/>
    <input type="hidden" name="item_name_1" value="Grand total"/>
    <input type="hidden" name="amount_1" value="<?php echo $total; ?>"/>
    <input type="submit" value="PayPal">

    </form> </div>


    Have anyone got further suggestions? I appreciate all help I can get!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •