Opt1kal Posted September 27, 2010 Posted September 27, 2010 Wondering, How would I add a single text box submit form into oscommerce? Basically there would be a link on the left and when clicked on would load a page that has a single text box and a submit button. The button would send the entered text inside of an xml to a url and wait for a response. Once clicked it would load a new page with nothing but text. Any help is greatly appreciated.
♥mdtaylorlrim Posted September 27, 2010 Posted September 27, 2010 All you need to do Op, is place a button on the Order Edit page with the tag "Send Order to Papes" and have a hidden field that contains the variable "data" with the value of your XML information. When it places the order Papes returns the Order Number which you place in the database. If the order number already exists in the database then gray out the Order button and change the button title to the order number found in the database. Sounds easy, huh? On second thought, since the Order Edit page has already sent headers and all, it would be better to have that as a page of it's own so that you can cleanly retrieve the order number, put it in the database, and then return to the Order Edit screen. It can still be a button on the page that calls your new page. Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 Well, now I'm completely lost...lol. To be more specific, the submit button would send the order query xml to the supplier, and if it comes back with a order status of completed it would show the tracking number. If not it would display "Order is still pending please try again later".
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 Well, now I'm completely lost...lol. To be more specific, the submit button would send the order query xml to the supplier, and if it comes back with a order status of completed it would show the tracking number. If not it would display "Order is still pending please try again later". I guess I just assumed that now that you have your 'post order' procedure perfected you now wanted to integrate it into osC. What were you planning on putting in the input box? Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 It's where customers can put their order number they get to get the tracking number from papes. Right now, when someone makes an order, it sends the order to papes, gets an order number and saves that in the database. What I need now is a text box where a customer can enter in said order number which will send an xml to pape's asking for the status of the order. If the status is "completed" then it will come back with a tracking number for UPS. If it's not it comes back with just "Pending".
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 Ok, now I get ya.... I would put a "Check order Status" link on the account_history_info.php file which posts the order_id to a custom php page, that... 1. extracts the Papes Order Number from the database 1a if not found then it has not been ordered - return to error procedure 1b if found then build and post the xml file to Papes retrieving the xml, then 2. run procedure that formats a result page with the information. All of this can be in one php file maintaining the osC format. Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 Here is one that may be easier to do, and provides better service to your customers... Run a cron job every hour (or 2 or 3) that... Selects all orders that have not been marked as delivered, then... For each open order { check status in database send request to Papes for order status compare the two if changed { alter order status } } This way your customers do not have to press anything. The status will be updated automatically and will be shown on the order_history_info page. Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 When you get that done then add a function that sends the customer an email advising them of the status change. Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 Well, I was working on a cron job to run but thats impossible because it won't allow for multiple orders to be queried, so it must be done one order at a time. So yeah this is what the text box is there for.
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 Well, I was working on a cron job to run but thats impossible because it won't allow for multiple orders to be queried, so it must be done one order at a time. So yeah this is what the text box is there for. What won't allow for multiple orders to be queried? Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 Ok, now I get ya.... I would put a "Check order Status" link on the account_history_info.php file which posts the order_id to a custom php page, that... 1. extracts the Papes Order Number from the database 1a if not found then it has not been ordered - return to error procedure 1b if found then build and post the xml file to Papes retrieving the xml, then 2. run procedure that formats a result page with the information. All of this can be in one php file maintaining the osC format. But how would I make that php page? So far all my experiance with oscommerce has been in the backend. I haven't had to do anything with whats on the main front end or anything. What won't allow for multiple orders to be queried? Their api....it can only accept one order to be queried at a time.
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 Sure you have. It is just like the place order php function. It has no user interaction and therefore has nothing to display to anyone, but that is really the easy part. The API only allows one call, but putting the function in a loop will only send one order per api call. The function builds a list of open orders, the loops through them sending an api call on each loop through. You've done this before. It's just like the place order function. The only thing you will have to do is write the order status to the db in the right place instead of writing the Papes order number in the db... When the customer visits his order_history_info page he will see his order status and not have to press any button or enter any info. It will already be there. Now, if you really want a user input and return with data that will be a little harder, but really unnecessary. Is that really what you want to do for some reason? Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 guess not....I'll see what I can figure out. Thing thats killing me is the job is due in the morning. I guess the biggest thing thats getting to me is how to get it to loop through without sending them all at once. Because the place order loops through the products and then places that list inside of the one url and sends it once. How would it be looped through without sending it all at once?
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 guess not....I'll see what I can figure out. Thing thats killing me is the job is due in the morning. I guess the biggest thing thats getting to me is how to get it to loop through without sending them all at once. Because the place order loops through the products and then places that list inside of the one url and sends it once. How would it be looped through without sending it all at once? Just have is select the orders and loop through them instead of the items... select all orders not delivered foreach order { send to api process return info and write to db } Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 Ok, here's what I have so far, wondering if this would work...well right now I know it won't because I'm getting a parse error on line 13, but I don't know how to go about fixing that. <?php require('includes/functions/database.php'); require('includes/configure.php'); $tfile = 'tracking.xml'; $tmp_file = 'orderid.tmp'; tep_db_connect() or die('Unable to connect to database!'); $query = "select orders_id from orders where orders_status = 1"; $pending_orders = tep_db_query($query); foreach($order as tep_db_fetch_array($pending_orders)){ $ft = fopen($tmp_file, "w"); fwrite($ft, $order['orders_id']); fclose($ft); $url_to_file = 'https://www.papesinc.com/pls/papes/ext?data=<?xml+version="1.0"+encoding="utf-8"+?>+<orderquery><ctid>BD5DE1625F694EA4A892C860ADD2B1F5</ctid><orderid>'.urlencode($order['orders_id']).'</orderid>+</orderquery>'; $ch = curl_init($url_to_file); $fp = fopen($tfile, "w"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); curl_setopt($ch, CURLOPT_TIMEOUT, 120); curl_setopt($ch, CURLOPT_MAXREDIRS, 10); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_exec($ch); curl_close($ch); fclose($fp); $oDOM = new DOMDocument(); $oDOM->loadXML(file_get_contents($tfile)); $porder = $oDOM->getElementsByTagName('orderquery'); $ptrack = $porder->item(4)->nodeValue; $pstatus = $porder->item(1)->nodeValue; $porderid = $porder->item(0)->nodeValue; $psql = 'Update orders set papes_id = ' . $porderid . ' where orders_id = '. $order['orders_id']; $ssql = 'Update orders set orders_id = ' . $porderid . ' where orders_id = '. $order['orders_id']; $tsql = 'Update orders set papes_tracking = ' . $ptrack . ' where orders_id = '.$order['orders_id']; if ($pstatus = 'Complete') { mysql_query($tsql) } mysql_query($psql); mysql_query($ssql); } tep_db_close(); ?>
♥mdtaylorlrim Posted September 28, 2010 Posted September 28, 2010 Does it require the php file that the tep functions are in? I thought that was in the general.php functions. Community Bootstrap Edition, Edge Avoid the most asked question. See How to Secure My Site and How do I...?
Opt1kal Posted September 28, 2010 Author Posted September 28, 2010 No the tep functions are in the database.php file.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.