0){
$message = 3;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
} else {
if(!file_exists($target_path)){
if(move_uploaded_file($_FILES['variation-picture']['tmp_name'], $target_path)){
$filename = urlencode(basename($_FILES['variation-picture']['name']));
mysql_query('INSERT INTO wp_custom_variations (name, code, price, picture) VALUES("'.$name.'", "'.$code.'", "'.$price.'", "'.$filename.'")');
$message = 4;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
} else{
$message = 5;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
}
} else {
$message = 6;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
}
}
} else {
$message = 7;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
}
$message = 1;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
} else {
$message = 2;
header('Location: '.$url.'?message='.$message.'&variation-name='.$name.'&variation-code='.$code.'&variation-price='.$price);
}
}
if($_POST['save-general']=='Salvesta'){
$url = $_POST['url'];
$tosix = $_POST['to-six-embro'];
$perc = $_POST['product-perc'];
if($tosix!='' && $perc!=''){
mysql_query('UPDATE wp_custom_general SET to_six_embro="'.$tosix.'", percentage="'.$perc.'" WHERE id="1"') or die(mysql_error());
header('Location: '.$url.'?to-six-embro='.$tosix.'&product-perc='.$perc);
} else {
header('Location: '.$url);
}
}
if($_POST['add-measure']=='Lisa'){
$url=$_POST['url'];
$measure=$_POST['measure-name'];
if($measure!=''){
$measure = trim($measure);
$measure = str_replace(' ','',$measure);
$measure = strtolower($measure);
mysql_query('INSERT INTO wp_custom_measures (measure) VALUES("'.$measure.'")') or die(mysql_error());
$message = 9;
header('Location: '.$url.'?message='.$message.'&measure-name='.$measure);
} else {
$message = 8;
header('Location: '.$url.'?message='.$message.'&measure-name='.$measure);
}
}
if($_POST['add-measure-to-product']=='Salvesta'){
$measure=$_POST['measure-name'];
$url = $_POST['url'];
$measureid = $_POST['measure-id'];
$measureidarray = $_POST['measureid'];
if($measure!=''){
$measure = trim($measure);
$measure = str_replace(' ','',$measure);
$measure = strtolower($measure);
mysql_query('UPDATE wp_custom_measures SET measure="'.$measure.'" WHERE id="'.$measureid.'"') or die(mysql_error());
}
for($i=1; $i<6; $i++){
if($measureidarray[$i]!=''){
$queryifhasmeasures = mysql_query('SELECT * FROM wp_custom_measures_assoc WHERE product_id="'.$measureidarray[$i].'" AND measure_id="'.$measureid.'" LIMIT 1');
if(mysql_num_rows($queryifhasmeasures)<1){
mysql_query('INSERT INTO wp_custom_measures_assoc (product_id, measure_id) VALUES("'.$measureidarray[$i].'", "'.$measureid.'")');
}
} else {
mysql_query('DELETE FROM wp_custom_measures_assoc WHERE product_id="'.$i.'" AND measure_id="'.$measureid.'"');
}
}
header('Location: '.$url.'?measure-id='.$measureid);
}
if($_GET['action']=='delete-measure' && $_GET['id']!='' && $_GET['url']!=''){
$id = $_GET['id'];
$url = $_GET['url'];
mysql_query('DELETE FROM wp_custom_measures WHERE id="'.$id.'"') or die(mysql_error());
mysql_query('DELETE FROM wp_custom_measures_assoc WHERE measure_id="'.$id.'"') or die(mysql_error());
header('Location: '.$url);
}
if(isset($_POST['add-variation-to-product'])){
$url = $_POST['url'];
$variationid = $_POST['variation-id'];
$productidarray = $_POST['productid'];
if($_POST['variation-name']!='' && $_POST['variation-price']!='' && $_POST['variation-code']!=''){
mysql_query('UPDATE wp_custom_variations SET name="'.$_POST['variation-name'].'", code="'.$_POST['variation-code'].'", price="'.$_POST['variation-price'].'" WHERE id="'.$variationid.'"') or die(mysql_error());
}
for($i=1; $i<6; $i++){
if($productidarray[$i]!=''){
$queryifhasvariations = mysql_query('SELECT * FROM wp_custom_variations_assoc WHERE product_id="'.$productidarray[$i].'" AND variation_id="'.$variationid.'" LIMIT 1');
if(mysql_num_rows($queryifhasvariations)<1){
mysql_query('INSERT INTO wp_custom_variations_assoc (product_id, variation_id) VALUES("'.$productidarray[$i].'", "'.$variationid.'")');
}
} else {
mysql_query('DELETE FROM wp_custom_variations_assoc WHERE product_id="'.$i.'" AND variation_id="'.$variationid.'"');
}
}
header('Location: '.$url.'?variation-id='.$variationid);
}
if($_GET['action']=='delete-variation' && $_GET['id']!='' && $_GET['url']!=''){
$id = $_GET['id'];
$url = $_GET['url'];
$queryvariationpicture = mysql_query('SELECT picture FROM wp_custom_variations WHERE id="'.$id.'"');
$row = mysql_fetch_array($queryvariationpicture);
unlink('images/patterns/'.$row['picture']);
mysql_query('DELETE FROM wp_custom_variations WHERE id="'.$id.'"') or die(mysql_error());
mysql_query('DELETE FROM wp_custom_variations_assoc WHERE variation_id="'.$id.'"') or die(mysql_error());
header('Location: '.$url);
}
if($_POST['action']=='get-price'){
$querygeneral = mysql_query('SELECT * FROM wp_custom_general WHERE id="1" LIMIT 1');
$general = mysql_fetch_array($querygeneral);
$tosix = $general['to_six_embro'];
$percentage = $general['percentage']/100;
if(isset($_POST['pillowleft']) || isset($_POST['pillowright']) || isset($_POST['sheet']) || isset($_POST['blankettop']) || isset($_POST['blanketbottom'])){
$echo = '';
$echo2 = '';
$subprice = 0;
$price = 0;
if($_POST['pillowleft']!='none' && $_POST['pillowleft']!='' && $_POST['measurepillow']!=''){
if($_POST['embroideryfont']!='' && $_POST['embroiderytext']!='' && $_POST['embroiderycolor']!=''){
$embroideryfont = $_POST['embroideryfont'];
$embroiderytext = $_POST['embroiderytext'];
$embroiderycolor = $_POST['embroiderycolor'];
if(strlen($embroiderytext)>0){
$embroiderylenght = strlen($embroiderytext);
$subprice = $embroiderylenght*$tosix;
$price += $embroiderylenght*$tosix;
$echo2 = ' Padja tikandi värv: '.$embroiderycolor.', Padja tikandi tekst: '.$embroiderytext.', Padja tikandi font: '.$embroideryfont.' ('.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK - '.number_format($subprice, 2, ',', ' ').'€) ';
}
}
$measurepillow = $_POST['measurepillow'];
$pillowleft = $_POST['pillowleft'];
preg_match('/patterns\/(.*)\)/', $pillowleft, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measurepillow.'" AND wcp.product="Padi pealt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+10;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Padi pealt ('.$row['name'].' - '.$row['measure'].' cm): '.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK ('.number_format($subprice, 2, ',', ' ').'€)'.$echo2.'
';
}
if($_POST['pillowright']!='none' && $_POST['pillowright']!='' && $_POST['measurepillow']!=''){
$measurepillow = $_POST['measurepillow'];
$pillowright = $_POST['pillowright'];
preg_match('/patterns\/(.*)\)/', $pillowright, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measurepillow.'" AND wcp.product="Padi alt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+10;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Padi alt ('.$row['name'].' - '.$row['measure'].' cm): '.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK ('.number_format($subprice, 2, ',', ' ').'€)
';
}
if($_POST['sheet']!='none' && $_POST['sheet']!='' && $_POST['measuresheet']!=''){
$measuresheet = $_POST['measuresheet'];
$sheet = $_POST['sheet'];
preg_match('/patterns\/(.*)\)/', $sheet, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measuresheet.'" AND wcp.product="Lina" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+20;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Lina ('.$row['name'].' - '.$row['measure'].' cm): '.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK ('.number_format($subprice, 2, ',', ' ').'€)
';
}
if($_POST['blankettop']!='none' && $_POST['blankettop']!='' && $_POST['measureblanket']!=''){
if($_POST['embroideryfont2']!='' && $_POST['embroiderytext2']!='' && $_POST['embroiderycolor2']!=''){
$embroideryfont = $_POST['embroideryfont2'];
$embroiderytext = $_POST['embroiderytext2'];
$embroiderycolor = $_POST['embroiderycolor2'];
if(strlen($embroiderytext)>0){
$embroiderylenght = strlen($embroiderytext);
$subprice = $embroiderylenght*$tosix;
$price += $embroiderylenght*$tosix;
$echo2 = ' Revääri tikandi värv: '.$embroiderycolor.', Revääri tikandi tekst: '.$embroiderytext.', Revääri tikandi font: '.$embroideryfont.' ('.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK - '.number_format($subprice, 2, ',', ' ').'€) ';
}
}
$measureblanket = $_POST['measureblanket'];
$blankettop = $_POST['blankettop'];
preg_match('/patterns\/(.*)\)/', $blankettop, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measureblanket.'" AND wcp.product="Tekikott alt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+45;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Tekikott alt ('.$row['name'].' - '.$row['measure'].' cm): '.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK ('.number_format($subprice, 2, ',', ' ').'€)'.$echo2.'
';
}
if($_POST['blanketbottom']!='none' && $_POST['blanketbottom']!='' && $_POST['measureblanket']!=''){
$measureblanket = $_POST['measureblanket'];
$blanketbottom = $_POST['blanketbottom'];
preg_match('/patterns\/(.*)\)/', $blanketbottom, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measureblanket.'" AND wcp.product="Tekikott pealt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length-5;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Tekikott pealt ('.$row['name'].' - '.$row['measure'].' cm): '.number_format((($subprice)*15.6466), 2, ',', ' ').' EEK ('.number_format($subprice, 2, ',', ' ').'€)
';
}
$pricetotal = $price*15.6466;
echo $echo;
echo 'Hind Kokku: '.number_format($pricetotal, 2, ',', ' ').' EEK ('.number_format($price, 2, ',', ' ').'€)';
}
}
if($_POST['action']=='add-to-cart'){
$querygeneral = mysql_query('SELECT * FROM wp_custom_general WHERE id="1" LIMIT 1');
$general = mysql_fetch_array($querygeneral);
$tosix = $general['to_six_embro'];
$oversix = $general['over_six_embro'];
$percentage = $general['percentage']/100;
if(isset($_POST['pillowleft']) || isset($_POST['pillowright']) || isset($_POST['sheen']) || isset($_POST['blankettop']) || isset($_POST['blanketbottom'])){
$echo = '';
$echo2 = '';
$subprice = 0;
$price = 0;
if($_POST['pillowleft']!='none' && $_POST['pillowleft']!='' && $_POST['measurepillow']!=''){
if($_POST['embroideryfont']!='' && $_POST['embroiderytext']!='' && $_POST['embroiderycolor']!=''){
$embroideryfont = $_POST['embroideryfont'];
$embroiderytext = $_POST['embroiderytext'];
$embroiderycolor = $_POST['embroiderycolor'];
if(strlen($embroiderytext)>0){
$embroiderylenght = strlen($embroiderytext);
$subprice = $embroiderylenght*$tosix;
$price += $embroiderylenght*$tosix;
$echo2 = ' Padja tikandi värv: '.$embroiderycolor.', Padja tikandi tekst: '.$embroiderytext.', Padja tikandi font: '.$embroideryfont.' ';
}
}
$measurepillow = $_POST['measurepillow'];
$pillowleft = $_POST['pillowleft'];
preg_match('/patterns\/(.*)\)/', $pillowleft, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measurepillow.'" AND wcp.product="Padi pealt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+10;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Padi pealt ('.$row['name'].' - '.$row['measure'].' cm) '.$echo2.' ';
}
if($_POST['pillowright']!='none' && $_POST['pillowright']!='' && $_POST['measurepillow']!=''){
$measurepillow = $_POST['measurepillow'];
$pillowright = $_POST['pillowright'];
preg_match('/patterns\/(.*)\)/', $pillowright, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measurepillow.'" AND wcp.product="Padi alt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+10;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Padi alt ('.$row['name'].') '.$echo2.' ';
}
if($_POST['sheet']!='none' && $_POST['sheet']!='' && $_POST['measuresheet']!=''){
$measuresheet = $_POST['measuresheet'];
$sheet = $_POST['sheet'];
preg_match('/patterns\/(.*)\)/', $sheet, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measuresheet.'" AND wcp.product="Lina" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length-5;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Lina ('.$row['name'].' - '.$row['measure'].' cm) ';
}
if($_POST['blankettop']!='none' && $_POST['blankettop']!='' && $_POST['measureblanket']!=''){
if($_POST['embroideryfont2']!='' && $_POST['embroiderytext2']!='' && $_POST['embroiderycolor2']!=''){
$embroideryfont = $_POST['embroideryfont2'];
$embroiderytext = $_POST['embroiderytext2'];
$embroiderycolor = $_POST['embroiderycolor2'];
if(strlen($embroiderytext)>0){
$embroiderylenght = strlen($embroiderytext);
$subprice = $embroiderylenght*$tosix;
$price += $embroiderylenght*$tosix;
$echo2 = ' Revääri tikandi värv: '.$embroiderycolor.', Revääri tikandi tekst: '.$embroiderytext.', Revääri tikandi font: '.$embroideryfont.' ';
}
}
$measureblanket = $_POST['measureblanket'];
$blankettop = $_POST['blankettop'];
preg_match('/patterns\/(.*)\)/', $blankettop, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measureblanket.'" AND wcp.product="Tekikott alt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length+45;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Tekikott pealt ('.$row['name'].' - '.$row['measure'].' cm)'.$echo2.' ';
}
if($_POST['blanketbottom']!='none' && $_POST['blanketbottom']!='' && $_POST['measureblanket']!=''){
$measureblanket = $_POST['measureblanket'];
$blanketbottom = $_POST['blanketbottom'];
preg_match('/patterns\/(.*)\)/', $blanketbottom, $matches);
$filename = $matches[1];
$filename = str_replace('\"', '', $filename);
$querycurrentprice = mysql_query('SELECT wcv.price, wcv.name, wcm.measure FROM wp_custom_products AS wcp INNER JOIN wp_custom_variations_assoc AS wcva ON wcp.id=wcva.product_id INNER JOIN wp_custom_variations AS wcv ON wcva.variation_id=wcv.id INNER JOIN wp_custom_measures_assoc AS wcma ON wcp.id=wcma.product_id INNER JOIN wp_custom_measures AS wcm ON wcma.measure_id=wcm.id WHERE wcm.id="'.$measureblanket.'" AND wcp.product="Tekikott pealt" AND wcv.picture="'.$filename.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($querycurrentprice);
$length = explode('x',$row['measure']);
$length = $length[1];
$length = $length-5;
$length = $length/100;
$subprice = $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$price += $length*$row['price']+5.11+(($length*$row['price']+5.11)*$percentage);
$echo .= 'Tekikott alt ('.$row['name'].')'.$echo2.' ';
}
$pricetotal = $price*15.6466;
}
$query = mysql_query('SELECT id FROM wp_wpsc_product_list WHERE name="'.$echo.'" LIMIT 1') or die(mysql_error());
if(mysql_num_rows($query)==0){
mysql_query('INSERT INTO wp_wpsc_product_list (name, price, publish, image) VALUES("'.$echo.'", "'.$price.'", "0", "0")') or die(mysql_error());
} else {
mysql_query('UPDATE wp_wpsc_product_list SET price="'.$price.'" WHERE name="'.$echo.'"') or die(mysql_error());
}
$query = mysql_query('SELECT id FROM wp_wpsc_product_list WHERE name="'.$echo.'" LIMIT 1') or die(mysql_error());
$row = mysql_fetch_array($query);
$product_id = $row['id'];
$parameters['quantity'] = 1;
foreach($wpsc_cart->cart_items as $cartitem){
if($cartitem->product_name==$echo){
$parameters['quantity'] = $parameters['quantity'] + 1;
}
}
$wpsc_cart->set_item($product_id, $parameters, $wpsc_cart);
echo 'Laen toote ostukorvi...';
}
?>