Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Porn site quanity problem (Appropriate for all)
Old 12-20-2008, 06:06 PM Porn site quanity problem (Appropriate for all)
Banned

Posts: 13
Trades: 0
Ok, so I am working on adult dvd rental business and there is something wrong with it, when a dvd is added to the cart and the order is not finished it is subtracting the item from the quanity, thus making it subtract if the order is not finished, how do I fix this?


PHP Code:
<?php session_start();
include(
"codelibrary/inc/variables.php");
include(
"codelibrary/inc/functions.php");
@
extract ($_REQUEST);
if(
$_REQUEST['shipping']=='ship')
{
 
executeQuery("update tbl_admin set shipping_price='".$_REQUEST['price']."'");
}
$session_id=session_id();
$Pro_ID $_REQUEST[ProductID];
if(
$_REQUEST['type'])
{        
  
$ty=$_REQUEST['type'];
 }
if(
$_REQUEST[ProductID])
 {
    
$loc='';
    
$sql=mysql_query("select location from tbl_tempcart where session_id='$session_id' and product_id='$Pro_ID'");
    while(
$li=mysql_fetch_array($sql)){
    
$loc=$loc.','.$li['location'];
    }
      
$loc=substr($loc,1);
     if(
$loc){
     
//echo "select id from tbl_product_location where product_id='$Pro_ID' and id not in ($loc) and ifnull(rented,0)=0";
     
$sql=executeQuery("select id from tbl_product_location where product_id='$Pro_ID' and id not in ($loc) and ifnull(rented,0)=0");
     
$lo=mysql_fetch_array($sql);
     
$los=$lo['id'];
     }else{
     
$los=-1;
     }
     if(
$_REQUEST['type']=='rent')
     {
      
//echo "select tbl_product.*,tbl_product_location.id as location from tbl_product inner join tbl_product_location on (tbl_product.id=tbl_product_location.product_id and tbl_product_location.dvd_for='Rent') where tbl_product.id='$Pro_ID' and ifnull(rented,0)=0";
    
$ProductQueryRow=mysql_query("select tbl_product.*,tbl_product_location.id as location from tbl_product inner join tbl_product_location on (tbl_product.id=tbl_product_location.product_id and tbl_product_location.dvd_for='Rent') where tbl_product.id='$Pro_ID' and ifnull(rented,0)=0");
    
$ProductResultNums mysql_fetch_array($ProductQueryRow);
    
$price $ProductResultNums[rent_price];
    if(
$los==-1){
     
$location $ProductResultNums['location'];
    
    }else{
    
$location=$los;
        }
    
executeQuery("update tbl_product_location set rented=1 where id='$location' and (dvd_for='Rent')");   
    }
    else if(
$_REQUEST['type']=='buy')
    {
    
$ProductQueryRow=mysql_query("select tbl_product.*,tbl_product_location.id as location from tbl_product inner join tbl_product_location on (tbl_product.id=tbl_product_location.product_id and tbl_product_location.dvd_for='Buy') where tbl_product.id='$Pro_ID' and ifnull(rented,0)=0");
    
$ProductResultNums mysql_fetch_array($ProductQueryRow);
    
//$qty = $ProductResultNums[product_quantity];
    
$price $ProductResultNums[buy_price];
        if(
$los==-1){
        
$location $ProductResultNums[location];
        }else{
        
$location=$los;
        }
          
executeQuery("update tbl_product_location set rented=1 where id='$location' and (dvd_for='Buy')");   
       }
    else if(
$_REQUEST['type']=='Used')
    {
    
    
$ProductQueryRow=mysql_query("select tbl_product.*,tbl_product_location.id as location from tbl_product inner join tbl_product_location on (tbl_product.id=tbl_product_location.product_id and tbl_product_location.dvd_for='Buy') where tbl_product.id='$Pro_ID' and ifnull(rented,0)=0");
    
$ProductResultNums mysql_fetch_array($ProductQueryRow);
    
//$qty = $ProductResultNums[product_quantity];
    
$price $ProductResultNums[used_price];
        if(
$los==-1){
        
$location $ProductResultNums[location];
        }else{
        
$location=$los;
        }
    }
    if(
$location){
    
mysql_query("insert into tbl_tempcart  set session_id='$session_id',price='$price',product_id='$Pro_ID',type='$ty',location='$location',ptype='Gay' OR ptype='Straight'");
    }else if(
$location==''){
    
$_SESSION['sess_msg']='Sorry, This Item is not available in stock';
    }
}
    if(
$_REQUEST[action]==del)
    {
        
$sql_l=executeQuery("select *from tbl_tempcart where id='".$_REQUEST[temp_id]."'");
         while(
$ll=mysql_fetch_array($sql_l))
        {  
           
$location_id=$ll['location'];
             if(
$ll['type']=='buy')
           {
//plus 1 was 0
           
executeQuery("update tbl_product_location set rented=+1 where id='$location_id' and (dvd_for='Buy')");   
            
mysql_query("delete  from tbl_tempcart where id='".$_REQUEST[temp_id]."' and ptype='Gay' OR ptype='Straight'");
            
$msg "Product Delete Successfully";
          }
          else  if(
$ll['type']=='rent')
          {    
//plus 1 was 0
          
executeQuery("update tbl_product_location set rented=+1 where id='$location_id' and (dvd_for='Rent')");   
          
mysql_query("delete  from tbl_tempcart where id='".$_REQUEST[temp_id]."'");
          
$msg "Product Delete Successfully";
          }
        }
       
    }

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><?php echo SITE_TITLE?></title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-image: url(images/page_bg.gif);
}
-->
</style>
<link href="codelibrary/css/style.css" rel="stylesheet" type="text/css">
<script>
function shipping(value)
 {
       window.location.href='g_cart.php?price='+value+"&shipping=ship"; 
    //document.getElementById('ship1').innerHTML=value;
 }
</script>
</head>

<body style="padding-top:5px; ">
<table width="987" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top" bgcolor="#FFFFFF" >
    <?php include("st_header.inc.php");?>
     </td>
  </tr>
  <tr>
    <td align="center" valign="top" bgcolor="#FFFFFF" style="padding-top:15px; padding-bottom:15px; "><table width="99%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="188" align="left" valign="top">
        <?php include("st_left.inc.php");?>
        </td>
        <td width="1" align="left" valign="top" bgcolor="#59727a"><img src="images/spacer.gif" width="1" height="1"></td>
        <td align="center" valign="top">
        <table width="590"  border="1" cellpadding="0" cellspacing="0">
          
            <tr>
            <td align="center" valign="top" style="padding-top:10px; ">
            
                    <table width="577"   border="0" align="center" cellpadding="0" cellspacing="0">
                              <tr>
                                <td align="left" bgcolor="#59727a" class="white_txt2" style="padding-left:10px; padding-top:10px; padding-bottom:10px; ">&nbsp;Shopping Cart</td>
                              </tr>
                              <tr>
                                  <td align="center" class="grey_txt"><font color="#FF0000"><?php echo $_SESSION['sess_msg'];$_SESSION['sess_msg']='';?></font></td>
                              </tr>
                              <tr>
                                  <td>
                                    <table width="556" border="0" align="center" bordercolor="#EBEDE3">
                                      <?php $sql=mysql_query("select *,count(id) as qty from tbl_tempcart where session_id='$session_id' and ptype='Gay' OR ptype='Straight' group by product_id order by id desc");
        if(
mysql_num_rows($sql)){?>
                                      <tr>
                                        <td width="141" align="center" class="black_txt" ><strong>DVD Image</strong></td>
                                        <td width="105" align="center" class="black_txt"><strong>Title</strong></td>
                                        <td width="122" align="center" class="black_txt"><strong>Remove</strong></td>
                                        <!--<td width="146" align="center" class="black_txt">Product Quantity</td>-->
                                        <td width="46" align="center" class="black_txt"><strong>Type</strong></td>
                                        <td align="center" class="black_txt"  colspan="2"><strong>Qty</strong></td>
                                        <td width="40" align="center" class="black_txt" colspan="4"><strong>Price</strong></td>
                                      </tr>
                                      <?php 
        $sql_d
=executeQuery("select shipping_price  from tbl_admin ");
         
$l=mysql_fetch_array($sql_d);
         
$sprice1=$l['shipping_price'];
         
$SubTotal=0;
        
$x=1;
        while(
$Result mysql_fetch_array($sql)){
        
$className = ($className == "#ffffff")?"#f6f7f2":"#ffffff";
        
$x++;
        
$query mysql_query("select * from tbl_product where id='".$Result[product_id]."'");
        
$ProductFind mysql_fetch_array($query);
        
$ProductName $ProductFind[title];
        
//$ProductDescription = $ProductFind[product_description];
        
$ProductID $ProductFind[id];
        
//$ProductPrice = $ProductFind[product_price];
        
$ProductImage    =  $ProductFind[image];
        
//$ProductQuantity =  $ProductFind[product_quantity];
        
$ProductModel    =  $ProductFind[product_model];
        
$ResultPrice $Result[price]*$Result['qty'];
        if(
$Result['type']=='buy'){
        
$ResultPrice=$ResultPrice+$sprice1;
        }
         else if(
$Result['type']=='rent')
       {
        
$ResultPrice=$ResultPrice;
       }      
       
$SubTotal=$SubTotal+$ResultPrice;
             
//////////////////   tax for 
    
    
?>
                                      <input type="hidden" name="id[]" value="<?php echo $Result[id]; ?>" />
                                      <tr  bgcolor="<?php echo $className?>">
                                        <td width="141" align="center"><img src="uploaded_files/thumb/<?php echo $ProductFind[image];?>" border="0" width="120" /></td>
                                        <td width="105" valign="top" align="center" class="grey_txt"><?php echo $ProductName;?></td>
                                        <td width="122" valign="top" align="center" class="grey_txt"><a href="g_cart.php?temp_id=<?php echo $Result[id]; ?>&action=del"><img src="images/icon_delete.gif" alt="Delete" width="19" height="14" hspace="20" border="0" title="Delete"></a></td>
                                        <!--<td align="center"><input type="text" value="<?php echo $Result[qty];?>" name="qty[]" size="2"/></td>-->
                                        <td align="center" valign="top" class="grey_txt" colspan="2"><?php echo ucfirst($Result['type']);?></td>
                                        <td width="70" align="center" valign="top" class="grey_txt"><?php echo ucfirst($Result['qty']);?></td>
                                        <td align="center" class="grey_txt" valign="top" colspan="4">$
                                            <?php 
                                            
                                            
echo number_format($ResultPrice,2);
                                            
                                                 
?>
                                            <?php //echo "&nbsp;Old=".number_format($ProductPrice); ?></td>
                                        <?php }?>
                                      </tr>
                                      <!--<tr>
                                            <td colspan="100%" class="grey_txt" align="right"><?php echo "<span class=black_txt>Shipping &nbsp;=&nbsp;</span>"; echo "<span class=txt>$10</span>"?></td>
                                        </tr>-->
                                      <tr>
                                        <td class="black_txt" colspan="6" align="right">&nbsp;</td>
                                        <td  align="left"  class="black_txt">&nbsp;</td>
                                      </tr>
                                      <?php 
                                        $sql_state_chech
=executeQuery("select  state from tbl_user where id='".$_SESSION['sess_id']."'");
                                    
$hh=mysql_fetch_array($sql_state_chech); 
                                    
$state$hh[0];
                                if(
$state=="CA")
                                {
                                  
$sql=executeQuery("select tax from tbl_tax ");
                                  
$tax=mysql_fetch_array($sql);
                                  
$t=$tax[0]; 
                                  
$SubTotal1=($SubTotal*$t)/100;
                                  
$SubTotal=$SubTotal1+$SubTotal;
                                  
?>
                                      <tr>
                                        <td colspan="100%" align="right" class="grey_txt"><table width="50%"  border="0" cellspacing="0" cellpadding="3">
                                            <tr>
                                              <td width="58%" align="right">SubTotal:</td>
                                              <td width="42%" align="right">$<?php echo number_format($SubTotal,2);?></td>
                                            </tr>
                                            <tr>
                                              <td align="right">Tax :</td>
                                              <td align="right">&nbsp;$<?php echo number_format($SubTotal1,2); ?></td>
                                            </tr>
                                            <tr>
                                              <td align="right">Shipping :</td>
                                              <td align="right"><span class="black_txt">
                                                <select name="ship"  onChange="shipping(this.value)" >
                                                  <option  value="">Free</option>
                                                  <?php 
                                 $sql_ship
=executeQuery("select * from tbl_shipping where status=1");
                               while(
$ship=mysql_fetch_array($sql_ship))
                                 {  
                                
?>
                                                  <option value="<?php  echo $ship['price']?>"  <?php if($ship['price']==$_REQUEST['price']){ ?> selected<?php }?> ><?php echo $ship['shipping_type'?></option>
                                                  <?php }?>
                                                </select>
                                              </span></td>
                                            </tr>
                                            <tr>
                                              <td align="right">Total:</td>
                                              <td align="right">$<?php echo number_format(($SubTotal+$sp),2); ?></td>
                                            </tr>
                                          </table>
                                     <span class="black_txt"> </span> <br>
                                        </td>
                                      </tr>
                                      <?php }
                             else {
?>
                                      <tr>
                                        <td colspan="100%" align="right" class="grey_txt"><table width="50%"  border="0" cellspacing="0" cellpadding="3">
                                            <tr>
                                              <td width="62%" align="right">Shipping :</td>
                                              <td width="38%" align="right" valign="top"><span class="black_txt">
                                                <select name="ship"  onChange="shipping(this.value)" >
                                                  <option  value="">Free</option>
                                                  <?php 
                                 $sql_ship
=executeQuery("select * from tbl_shipping where status=1");
                                                                while(
$ship=mysql_fetch_array($sql_ship))
                                 {  
                                
?>
                                                  <option value="<?php  echo $ship['price']?>"  <?php if($ship['price']==$_REQUEST['price']){ ?> selected<?php }?>><?php echo $ship['shipping_type'?></option>
                                                  <?php }?>
                                                </select>
                                              </span></td>
                                            </tr>
                                            <tr>
                                              <td align="right">Total:&nbsp;</td>
                                              <td align="right" valign="top">$<?php echo number_format(($SubTotal),2); ?></td>
                                            </tr>
                                          </table>
                                            <span class="black_txt"> </span> <br>
                                        </td>
                                      </tr>
                                      <?php  
                             
}
                            
                            
?>
                                      <tr>
                                        <td colspan="100%" align="right"><table width="100%">
                                          <tr>
                                            <td width="54%" align="left" valign="middle" class="warning"><p><strong>Note:-</strong><br>
                                                    <strong> minimum rental order is $2.98</strong><br>
                                                    <strong>Shipping :</strong><strong>$<?php echo number_format($sprice1,2);  ?></strong><br>
                                                    <strong>Free-All DVD rentals</strong><br>
                                                    <strong>First class: $3.99<br>
                                                </strong><strong>Priority: $5.99</strong> </p></td>
                                            <td width="46%" align="right" valign="top"><a href="javascript:void(0)" onClick="location.href='st_dvdlist.php'">
                                              <input type="image" src="images/btn_continue.jpg" border="0">
                                              </a> &nbsp;&nbsp;
                                              <?php 
                                            
if($SubTotal>2.98){ ?>
                                              <a href="javascript:void(0)" onClick="location.href='checkout.php'">
                                              <input type="image" src="images/btn_checkout.jpg" border="0">
                                              </a>
                                              <?php }?></td>
                                          </tr>
                                        </table></td>
                                      </tr>
                                      <?php //&type=<?php echo $_REQUEST['type'];
                                    
}else{?>
                                      <tr>
                                        <td colspan="100%" align="center" class="grey_txt"><font color="#FF0000">There is No Item in cart</font></td>
                                      </tr>
                                      <tr>
                                        <td colspan="100%" align="right"><input name="Continue Shopping" type="button" class="button"  value="Continue Shopping" onclick="location.href='st_dvdlist.php'"/></td>
                                      </tr>
                                      <?php }?>
                                    </table></td>
                              </tr>
                  </table>
                </td>
          </tr>
               </table></td>
        <td width="1" align="left" valign="top" bgcolor="#59727a"><img src="images/spacer.gif" width="1" height="1"></td>
        <td width="188" align="left" valign="top">
        <?php include("st_right.inc.php");?>
        </td>
      </tr>
      <tr>
      <td colspan="100%" align="center" valign="top" style="padding-top:10px; "><?php include("g_footer.inc.php");?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" valign="top">&nbsp;</td>
  </tr>
</table>
</body>
</html>
Pornguy89 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-20-2008, 06:16 PM Re: Porn site quanity problem (Appropriate for all)
Defies a Status

Posts: 1,606
Trades: 0
If I followed the script correctly you need to get the sql query for:

Quote:
$los=-1;

somewhere after the order is confirmed.

That is what you need to do even if I picked the wrong line.


__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 12-21-2008, 05:23 PM Re: Porn site quanity problem (Appropriate for all)
Banned

Posts: 13
Trades: 0
Okay can someone help me out and expand, maybe show an example because I am totally confused.
Pornguy89 is offline
Reply With Quote
View Public Profile
 
Old 12-21-2008, 07:56 PM Re: Porn site quanity problem (Appropriate for all)
Defies a Status

Posts: 1,606
Trades: 0
I copied your code , saved it and still find it difficult to follow. In the future I suggest a lot more remark lines during developement. You can always take them out later.

This I think is your real question:

Quote:
when a dvd is added to the cart and the order is not finished it is subtracting the item from the quanity,
Some where in your code you are subtracting the item when it is added to the cart. This process should actually occur after the payment has been made or the order is confirmed.

You may need to move or recode that portion of the script, possibly even move it to another script. The second option is to reverse the process if the order is cancelled. That may be harder since some people don't empty the cart, they just close the browser.

There is no way for anyone to show you an example without having a complete copy of the scripts and the database. At least I know I could not. And that is not an offer.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Porn site quanity problem (Appropriate for all)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15790 seconds with 12 queries