Current location: Hot Scripts Forums » Programming Languages » PHP » Adding session values into Paypal form


Adding session values into Paypal form

Reply
  #1 (permalink)  
Old 05-02-09, 12:38 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Adding session values into Paypal form

I am trying to blend 2 different shopping carts scripts into one script ( neither one was totally what i wanted to start with, and had totally different functionality ), and am stumped on adding the carts session values for the items into a Paypal form.

The basic cart getting and displaying the items....

PHP Code:


function showCart() {
    global 
$db;
    
$cart $_SESSION['cart'];
    
$zipcode $_SESSION['zipcode'];
    if (
$cart) {
        
$items explode(',',$cart);
        
$contents = array();
        foreach (
$items as $item) {
            
$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1;
        }
        
$output[] = '<form action="cart.php?action=update" method="post" id="cart">';
        
$output[] = '<table class="producttable">';
    
$output[] = '<tr>';
    
$output[] = '<td class="productinfo" width="30%">Product</td>';
    
$output[] = '<td class="productinfo" width="10%">Price</td>';
    
$output[] = '<td class="productinfo" width="10%">Shipping</td>';
    
$output[] = '<td class="productinfo" width="10%">Remove Item</td>';
    
$output[] = '<td class="productinfo" width="5%">Qty.</td>';
              
$output[] = '<td class="productinfo" width="10%">Total</td>';  
    
$output[] = '</tr>';

        foreach (
$contents as $id=>$qty) {
            
$sql 'SELECT * FROM product_details WHERE id = '.$id;
            
$result $db->query($sql);
            
$row $result->fetch();
            
extract($row);

    
$output[] = '<tr>';
    
$output[] = '<td class="productinfo">'.$part.' <br/> '.$name.'<br />Shipping Weight: '.$weight.' lbs.<br/>
Package Dimensions:<br/> '
.$length.'" x '.$width.'" x '.$height.'"</td>';
    
$output[] = '<td class="productinfo">$ '.$price.'</td>';
$service '03';
$length $length;
$width $width;
$height $height;
$weight $weight;
$dest_zip $zipcode;

$rate ups($dest_zip,$service,$weight,$length,$width,$height);

$rate number_format$rate2'.'',' );
    
$output[] = '<td class="productinfo">$ '.$rate.' ea</td>';
    
$output[] = '<td class="productinfo"><a href="cart.php?action=delete&id='.$id.'">Remove</a></td>';
    
$output[] = '<td class="productinfo"><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';
              
$product_rate $price $rate;
              
$product_price = ( float ) $product_rate * ( int ) $qty;
              
$product_price number_format$product_price2'.'',' );
              
$output[] = '<td class="productinfo">$' $product_price '</td>';  
              
$total_price += ( float ) $product_price;
              
$total_price number_format$total_price2'.'',' );
    
$output[] = '</tr>';
    }


    
$output[] = '<tr>';
    
$output[] = '<td colspan="6" class="producttotal">Total Product + Shipping: <strong>$'.$total_price.'</strong><br/><br/></td>';
    
$output[] = '</tr></table>'
and the Paypal form ...

PHP Code:

$output[] = '<input type="hidden" name="cmd" value="_cart">
  <input type="hidden" name="business" value="paypalemailaddress">
  <input type="hidden" name="upload" value="1">
  <input type="hidden" name="currency_code" value="USD">'
;
     
$output[] = '
    <INPUT TYPE="hidden" NAME="item_name" VALUE="'
.$SESSION[name].'">
    <INPUT TYPE="hidden" NAME="item_number" VALUE="'
.$_SESSION[$part].'">
    <INPUT TYPE="hidden" NAME="amount" VALUE="'
.$_SESSION[$price].'">
    <INPUT TYPE="hidden" NAME="shipping" VALUE="'
.$_SESSION[$rate].'">
    <INPUT TYPE="hidden" NAME="total_'
.$i.'" VALUE="'.$_SESSION[$total_price].'">';
     
$output[] = '<input name="submit" type="submit" value="Click Here To Pay Via PayPal.com">
</FORM>'

Any suggestions are appreciated. Can post additional information if needed.
Reply With Quote
  #2 (permalink)  
Old 05-02-09, 03:03 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
OK, i got the values into the form, just need to get Paypal to lpay nice with it now.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Multi script PayPal add to cart order form Tito1 JavaScript 5 02-23-09 04:21 AM
ajax checking and onsubmit issue follower JavaScript 4 10-12-08 03:45 PM
Session Security (Continued from post below) nova912 PHP 1 09-05-06 09:29 AM


All times are GMT -5. The time now is 08:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.