Jump to content

Need some help with a commerce problem


lostnvegas

Recommended Posts

Hey everyone. I am making a site for my brother's band and having some trouble with the checkout to paypal. Unfortunately in layout I missed a pretty important variable, the size on shirts. I am trying to add it in as a drop down option just before submitting to paypal but I can't get it to show up on paypal and thus will have no idea what size they are ordering. The site is pretty basic and primitive but I really need this info on the checkout. Here is a link to the temporary site where i'm trying to get this to work:

http://www.theblack44s.com/t/index3.php

and this is what is up and running now:

http://www.theblack44s.com/Merchant%20pages/apparel/index3.php

this is the code i'm working on in cart.php:

<?php
require "dbconcart.php";
session_start();

//session_destroy();


$page = 'index.php';


$value2 = $_POST['size'];

//add to cart function
if (isset($_GET['add'])) {
                                        $quantity = mysql_query('SELECT id, quantity, imageurl FROM apparel WHERE id='.mysql_real_escape_string((int)$_GET['add']));
                                        while ($quantity_row = mysql_fetch_assoc($quantity)) {
                                                if ($quantity_row['quantity']!=$_SESSION['cart_'.(int)$_GET['add']]) {
                                                        $_SESSION['cart_'.(int)$_GET['add']]+='1';
													}
											}
                                          header('Location: '.$page);        
                                        }

//remove from cart
if (isset($_GET['remove'])) {
        $_SESSION['cart_'.(int)$_GET['remove']]--;
        header('Location: '.$page);
}

//delete from cart
if (isset($_GET['delete'])) {
        $_SESSION['cart_'.(int)$_GET['delete']]='0';
        header('Location: '.$page);
                 
}

                  
// products
function products() {
        $get = mysql_query('SELECT id, name, item_number, description, price, shipping FROM apparel WHERE quantity > 0 ORDER BY id DESC');
        if (mysql_num_rows($get)==0) {
                        echo "There are no products to display!";
        }
        else {
                while ($get_row = mysql_fetch_assoc($get)) {
                        echo $get_row['name'].'<br />';
					echo $get_row['item_number'].'<br />';
					echo $get_row['description'].'<br />';
					echo 'Price: '.number_format($get_row['price'], 2).'<br />';
					echo 'Shipping: '.number_format($get_row['shipping'], 2);
					echo '<a href="cart.php?add='.$get_row['id'].'">Add to cart</a></p>';                                        
                }
        }
        
}


//paypal function
function paypal_items() {
        $num = 0;
        foreach($_SESSION as $name => $value) {
                if ($value!=0) {
                        if (substr($name, 0, 5)=='cart_') {
                                $id = substr($name, 5, strlen($name)-5);
                                $get = mysql_query('SELECT id, name, item_number, price, shipping FROM apparel WHERE id='.mysql_real_escape_string((int)$id));
                                while ($get_row = mysql_fetch_assoc($get)) {
                                        $num++;
                                        echo '<input type="hidden" name="item_number_'.$num.'" value="'.$get_row['item_number'].'">';
                                        echo '<input type="hidden" name="item_name_'.$num.'" value="'.$get_row['name'].'">';
                                        echo '<input type="hidden" name="size_" value="$_POST'.$value2.']">';

									echo '<input type="hidden" name="amount_'.$num.'" value="'.$get_row['price'].'">';
                                        echo '<input type="hidden" name="shipping_'.$num.'" value="'.$get_row['shipping'].'">';
                                        echo '<input type="hidden" name="shipping2_'.$num.'" value="'.$get_row['shipping'].'">';
                                        echo '<input type="hidden" name="quantity_'.$num.'" value="'.$value.'">';


                                }
                        }
            
                           }
                           
       }
}



//cart function
function cart() {
        foreach($_SESSION as $name => $value) {
                if ($value>0) {
                  if (substr($name, 0, 5)=='cart_') {
                          $id = substr($name, 5, (strlen($name)-5)); 
                        $get = mysql_query('SELECT id, name, price, imageurl FROM apparel WHERE id='.mysql_real_escape_string((int)$id));
                        while ($get_row = mysql_fetch_assoc($get)) {
                                $sub = $get_row['price']*$value;
                                echo $get_row['name'].' x '.$value.' @ $'.number_format($get_row['price'], 2).' = $'.number_format($sub, 2).'<br />';
							?>
<html>
<body>

<form action="size.php"  method="post" name="size">
  <label>Size
  <select name="size">
    <option selected="selected">Select</option>
    <option value="youth">Youth (for the brats)</option>
    <option value="small">Small (petite)</option>
    <option value="medium">Medium (average)</option>
    <option value="large">Large (healthy)</option>
    <option value="xlarge">X Large (large)</option>
    <option value="xxlarge">XX Large (full figured</option>
    <option value="xxxlarge">XXX Large (huge)</option>
    <option value="xxxxlarge">XXXXLarge (DAMN!!)</option>
  </select>
  <input type="hidden" name="size" value="selected" />
  <input type="hidden" name="size" value="submit()" />
  </label>
</form>

</body>
</html>


<?php


echo '<a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[delete]</a><br />';             
																                                
                                }
                        }
                        $total += $sub;        
                }        
        }
        
        //cart totals and paypal function
        if ($total==0) {
                echo "Your cart is empty.";
        }
        else {
                
                                echo '<p><b>Total: $ '.number_format($total, 2).'</b></p>';
                                ?>
                                <p>
                <form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post">
                <input type="hidden" name="cmd" value="_cart">
                <input type="hidden" name="upload" value="1">
                <input type="hidden" name="business" value="webmaster@theblack44s.com">
                <?php paypal_items(); ?>
                <input type="hidden" name="currency_code" value="USD">
                <input type="hidden" name="amount" value="<?php echo $total; ?>">
			<input type="hidden" name="size" value="<?php echo $value2; ?>">
                <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but03.gif" target="_blank" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
                </form>
                </p>
               <?php
        }
}

?>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.