...

View Full Version : Stuck on additional price function



jchrisphonte
08-05-2012, 03:14 AM
Hello All,

Working on a jewelry site with the help of an international developer and I'm stuck since they are way behind and my client is really beginning to put the pressure on me.

The problem is this: Every product has a default price (mprice) and every product has 3 options...size, metal, and color... size and metal have incremental charges above the default price depending on option chosen..

for example small-no additional charge, medium=+10, large=+20, xlarge=+30.

and the same for metal: aluminum=+20, stainless steel=+30 etc..

I have the system adding the size fee yet it doesn't add the metal fee...
I know there is some javascript posting the price or something but not sure how these work together.

Any help pointing out where I need to tweak would be greatly appreciated...
problematic pages:
http://torchedbynatalie.com/product.php?id=24 (as an fyi --- i made all the size options and metal options +100$, just cant get it to say a final price of 498)
http://torchedbynatalie.com/viewcart.php

this is the script that controls the php content

<script type="text/javascript">

function change_size()
{

$(document).ready(function()
{

var c_price= $("#product-image-price-value").html();
var q=document.getElementById('product-image-buy-models-select2').value;
var met=document.getElementById('product-image-buy-models-select').value;

$.ajax({
url: "change_price.php",
data: "pro_id="+q+"&current_price="+c_price+"&met_price="+met,
type: "POST",
dataType: "html",
success: function(msg){
$('#product-image-price-value').html(msg);
}
});


});
}
</script>

This is the php file that seems to be causing the confusion and reposting the proper price

<?php session_start();
include("admin/common/dbcon.php");


$q=$_REQUEST['pro_id'];
$current_price=$_REQUEST['c_price'];
$met_price=$_REQUEST['met_price'];


$met_p = explode("<>", $met_price);
$met_p[0];
$def=$met_p[1];



$pieces = explode("mooni", $q);
$id=$pieces[0];
$title=$pieces[1];


$query_pro= "select price from tbl_price where product_id=$id and title='".$title."'";
$query=mysql_query($query_pro);
$row_pro=mysql_fetch_array($query);
$a=$row_pro['price'];



$query_base_price= "select mprice from tbl_product where id=$id";
$query_b=mysql_query($query_base_price);
$row_b=mysql_fetch_array($query_b);
$b=$row_b['mprice'];



if($def=="default")
{

$total_price=$a+ $b;
echo $p = number_format($total_price, 2, '.', '');
exit;
}
else

{

$tot_diff=$current_price-$b;

$met_price=$_REQUEST['met_price'];

$pieces_met = explode("mooni", $met_price);
$id=$pieces_met[0];

$title=$pieces_met[1];

$query_pro_met= "select price from tbl_metal where product_id=$id and title='".$title."'";

$query_met=mysql_query($query_pro_met);
$row_met=mysql_fetch_array($query_met);
$met_price=$row_met['price'];


$total_price=$a+ $b +$met_price;
echo $p = number_format($total_price, 2, '.', '');
exit;

}






?>



<div id="mooni">
</div>

<div id="product-image-price">

<div id="product-image-price-valuta">$</div>

<div id="product-image-price-value"><?php echo $row['mprice']; ?></div>

</div>



<form id="product-image-buy" method="post" action="cart.php?act=add">

<input type="hidden" name="product_id" value="<?php echo $row['id']; ?>">



<div id="product-image-buy-labels">

<label id="product-image-buy-label-models5">size</label>
<label id="product-image-buy-label-models2">metal</label>
<label id="product-image-buy-label-models3">color</label>

<label id="product-image-buy-label-quantity">quantity</label>

</div>



<a href="javascript:void(0)" id="product-image-buy-link">add to cart</a>
<?php //echo "select * from tbl_price where product_id='".$row['id']."'"; ?>
<input placeholder="1" value="1" type="text" name="quantity" id="product-image-buy-quantity" />


<div id="product-image-buy-models">


<select onChange="change_size();" name="size" id="product-image-buy-models-select2">
<option id="product-image-buy-models-select-option-<?php echo $row['mprice']; ?><>default<>default" rel="price:<?php echo $row['mprice']; ?>" value="<?php echo $row['mprice']; ?><>default<>default"></option>

<?php


$query_price=mysql_query("select * from tbl_price where product_id='".$row['id']."'");

while($row_price=mysql_fetch_array($query_price))
{

?>


<option onchange="change_size();" id="<?php echo $row_price['product_id']; ?>" name="<?php echo $row_price['title']; ?>"
value="<?php echo $row_price['product_id'];?><><?php echo $row_price['title']; ?>">
<?php echo $row_price['title'];?> </option>

<?php } ?>
</select>

<select onChange="change_size();" id="product-image-buy-models-select" name="metal">

<option id="product-image-buy-models-select-option-<?php echo $row['mprice']; ?><>default<>default" rel="price:<?php echo $row['mprice']; ?>" value="<?php echo $row['mprice']; ?><>default<>default"></option>

<?php


$query_price=mysql_query("select * from tbl_metal where product_id='".$row['id']."'");

while($row_price=mysql_fetch_array($query_price))
{

?>


<option onchange="change_size();" id="<?php echo $row_price['product_id']; ?>" name="<?php echo $row_price['title']; ?>"
value="<?php echo $row_price['product_id'];?><><?php echo $row_price['price']; ?>">
<?php echo $row_price['title'];?> </option>

<?php } ?>
</select>
<select id="product-image-buy-models-select3" name="color">

<option id="product-image-buy-models-select-option3-<?php echo $row['mprice']; ?><>default<>default" rel="price:<?php echo $row['mprice']; ?>" value="<?php echo $row['mprice']; ?><>default<>default"></option>

<?php

$query_color=mysql_query("select * from tbl_color where product_id='".$row['id']."'");

while($row_color=mysql_fetch_array($query_color)) {

if($row_color['price']=="") { $price=$row['mprice']; } else { $price=$row_color['price']; }

?>





<option id="product-image-buy-models-select-option3-<?php echo $price; ?><><?php echo $row_color['title']; ?><><?php echo $row_color['id']; ?>" rel="price:<?php echo $price; ?>" value="<?php echo $price; ?><><?php echo $row_color['title']; ?><><?php echo $row_color['id']; ?>"><?php echo $row_color['title']; ?></option>

<?php } ?>

</select>


</div>

</form>


</div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum