Jump to content

How to convert number in String to Value, then calculate Markup?


mahogan

Recommended Posts

It still hangs at: Getting price.

 

Here is the exact code that I have:

 

<?php
error_reporting(-1);
include('simple_html_dom.php');
// Request parameters
$materialid = $_GET['materialid'];
$sizeid = $_GET['sizeid'];
$quantity = $_GET['quantity'];
$numcolors = $_GET['numcolors'];
// form URL for request
//$url = "http://www.suppliersite.com/pricing?materialid=104&sizeid=37&quantity=1&numcolors=1";
$url = "http://www.suppliersite.com/pricing?materialid=".$materialid."&sizeid=".$sizeid."&quantity=".$quantity."&numcolors=".$numcolors;
// Create DOM from URL or file
$html = file_get_html($url);
// Echo page
//echo $html->plaintext;
//Code that creates $html
echo "<pre>";var_dump ($html);die();
$price_per_item = $html->find('#price-per-item');
var_dump ($price_per_item);
// $price_per_item = $html->find('#price-per-item');
$total_price = $html->find('#total-price');
$description = $html->find('.description');
$name = $html->find('h3');
//echo $price_per_item[0]."<br />";
//echo $total_price[0]."<br />";
//echo $description[0]."<br />";
//echo $name[1]."<br />";


// Iterate through all combinations:
echo "<table id=\"products\">";
echo "<tr>";
//echo "<th>Price per item</th><th>Total Price</th><th>Product</th><th>Description</th><th>Size</th><th>Quantity</th>";
echo "<th width=\"25%\">Price per item</th><th width=\"15%\">Total Price</th><th width=\"30%\">Product</th><th width=\"10%\">Size</th><th width=\"10%\">Colors</th>";
echo "<tr>";
$price_per_item = $html->find('#price-per-item');
$total_price = $html->find('#total-price');
$description = $html->find('.description');
$size = $html->find('select[id='.'top-sizes-select'.'] option[value='.$sizeid.']');	
 echo"<tr>";
echo "<td>".$price_per_item[0]."</td>".
"<td>".$total_price[0]."</td>".
"<td>".$name[1]->innertext."</td>".
// "<td>".$description[0]."</td>".
"<td>".$size[0]->innertext."</td>".
"<td>".$numcolors."</td>";
echo "</table>";
echo "<br />";
echo "<div style=\"width:40%\">";
echo $description[0];
echo "</div>";

?>

 

 

Is it possible that there is a security protocol from my supplier site that is preventing this from working?

Ok, I was looking up online why the var_dump() function might be failing and I found this, not exactly sure if it is relevant:

http://stackoverflow...ump-not-working

 

So, I see with their issue, it was something to do with thier Ajax script. So I got to looking at my files, and wonder if this is helpful?

 

Here is the my script that deals with Ajax getting the pricing data, this is located within a javascript section of my index page:

 

//////////////////// GET APPLICABLE SIZE OPTIONS FOR SELECTED MATERIAL
 function sizeOptions(materialid)
 {
//alert(materialid);

if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 }
else
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
xmlhttp.onreadystatechange=function()
 {

 if (xmlhttp.readyState==4 && xmlhttp.status==200)
   {
   document.getElementById('sizeid').innerHTML=xmlhttp.responseText;
   additionalOptions(materialid);
   }

 }
xmlhttp.open("GET","options.php?materialid="+materialid,true);
xmlhttp.send();  
 }

//////////////////// GET ADDITIONAL OPTIONS - DOUBLE SIDED & GROMMETS
 function additionalOptions(materialid)
 {
//alert(materialid);

if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 }
else
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
xmlhttp.onreadystatechange=function()
 {

 if (xmlhttp.readyState==4 && xmlhttp.status==200)
   {
   document.getElementById('radio').innerHTML=xmlhttp.responseText;
   }

 }
xmlhttp.open("GET","additional_options.php?materialid="+materialid,true);
xmlhttp.send();  
 }

//////////////////// GET PRICES VIA AJAX  
 function getPrices(materialid, sizeid, quantity, numcolors)
 {
//alert("Materal ID: "+materialid+" Size ID: "+sizeid+" Quantity: "+quantity+" # of colors: "+numcolors);

if (window.XMLHttpRequest)
 {// code for IE7+, Firefox, Chrome, Opera, Safari
 xmlhttp=new XMLHttpRequest();
 }
else
 {// code for IE6, IE5
 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 }
xmlhttp.onreadystatechange=function()
 {

 if (xmlhttp.readyState==4 && xmlhttp.status==200)
   {
   document.getElementById('price').innerHTML=xmlhttp.responseText;
   }

 }
document.getElementById('price').innerHTML="<p/ ><b>Getting price. Please wait....</b>";
xmlhttp.open("GET","price.php?materialid="+materialid+"&sizeid="+sizeid+"&quantity="+quantity+"&numcolors="+numcolors,true);
xmlhttp.send();  
 }

 

Not sure if this is helpful, if so please let me know. Thanks again!

Well, I am at wits end with this... so if anyone is interested in some freelance work, I posted this project for hire, there are some additional factors to that of what I was working on here.

 

https://www.freelancer.ph/projects/PHP-Javascript/Serif-WebPlus-integrate-php-script.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.