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?

Edited by mahogan
Link to comment
Share on other sites

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!

Edited by mahogan
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.