I have an existing functionality from our companies website that lets you enter your reference order number and it will provide you a list of all items status on that order(It actually uses SOAP that contacts our company database to provide the status. Please take note that our website is hosted thru an external provider). Now we got a web developer that develop our website using WordPress how can i insert/use the fuctionality that i have before with PHP website to the New Wordpress Website.
Please see Code
<?php
class philipshow extends modul {
function __construct($name = __CLASS__) {
parent::__construct($name);
$this->process();
}
protected function process() {
$s = Request::postVars('workordernumber');
$key = $s['key'];
$wsdl = "http://x.x.x.x/WOTracking.svc?wsdl";
$client = new SoapClient($wsdl, array(
"trace"=>1,
"exceptions"=>0));
$parameter->WorkOrderNumber = $key;
$value = $client->GetWorkOrderMasterDetail($parameter);
$content = $client->__getLastResponse();
// Loads the XML
$xml = simplexml_load_string($content);
$xml->registerXPathNamespace('a', '');
$woresult = $xml->xpath('//a:WorkOrder');
$det= array();
foreach ($woresult as $workorder) {
$wo['CustName'] = $workorder->xpath('a:xxx')[0];
$wo['PONumber'] = $workorder->xpath('a:xxx')[0];
......
}
$this->woresults = $wo;
$woitems = $xml->xpath('//a:WorkOrderItems/a:WorkOrderItemInformation');
foreach ($woitems as $woi) {
$items['ItemNo']= $woi->xpath('a:itemno')[0] ;
$items['Descript'] = $woi->xpath('a:itemdesc')[0];
.......
array_push($det,$items);
}
$this->wodetails = $det;
}
}
?>
TPL Code
<!-- left-side -->
<!-- left-side -->
{$wohead = $obj->woresults}
{$woitemdetails = $obj->wodetails}
<!-- center-side -->
{$count=1}
<div >
<div class="border-box company_article clr">
<h3><span>»</span> Sales Order <span> Status</span></h3>
<p><h6>Customer Name : {$wohead.CustName} </h6>
<h6>Purchase Order Number : {$wohead.PONumber}</h6>
<h6>Our Ref No. : {$wohead.WONumber} </h6>
</p>
<p>
<table border="1" style="width:100%">
<tr>
<b>
<td>Item #</td>
<td>Description</td>
<td>Size</td>
<td>Quantity</td>
<td>UOM</td>
<td>Status</td>
</b>
</tr>
{foreach $woitemdetails as $detail}
<tr>
<td> {$detail.ItemNo}</td>
<td> {$detail.Descript}</td>
<td> {$detail.Size}</td>
<td> {$detail.Quantity}</td>
<td> {$detail.UOM}</td>
<td>{$detail.Status}</td>
</tr>
{/foreach}
</table>
</div>
</div>
<!-- center-side -->
I have an existing functionality from our companies website that lets you enter your reference order number and it will provide you a list of all items status on that order(It actually uses SOAP that contacts our company database to provide the status. Please take note that our website is hosted thru an external provider). Now we got a web developer that develop our website using WordPress how can i insert/use the fuctionality that i have before with PHP website to the New Wordpress Website.
Please see Code
<?php
class philipshow extends modul {
function __construct($name = __CLASS__) {
parent::__construct($name);
$this->process();
}
protected function process() {
$s = Request::postVars('workordernumber');
$key = $s['key'];
$wsdl = "http://x.x.x.x/WOTracking.svc?wsdl";
$client = new SoapClient($wsdl, array(
"trace"=>1,
"exceptions"=>0));
$parameter->WorkOrderNumber = $key;
$value = $client->GetWorkOrderMasterDetail($parameter);
$content = $client->__getLastResponse();
// Loads the XML
$xml = simplexml_load_string($content);
$xml->registerXPathNamespace('a', 'http://schemas.xxxx');
$woresult = $xml->xpath('//a:WorkOrder');
$det= array();
foreach ($woresult as $workorder) {
$wo['CustName'] = $workorder->xpath('a:xxx')[0];
$wo['PONumber'] = $workorder->xpath('a:xxx')[0];
......
}
$this->woresults = $wo;
$woitems = $xml->xpath('//a:WorkOrderItems/a:WorkOrderItemInformation');
foreach ($woitems as $woi) {
$items['ItemNo']= $woi->xpath('a:itemno')[0] ;
$items['Descript'] = $woi->xpath('a:itemdesc')[0];
.......
array_push($det,$items);
}
$this->wodetails = $det;
}
}
?>
TPL Code
<!-- left-side -->
<!-- left-side -->
{$wohead = $obj->woresults}
{$woitemdetails = $obj->wodetails}
<!-- center-side -->
{$count=1}
<div >
<div class="border-box company_article clr">
<h3><span>»</span> Sales Order <span> Status</span></h3>
<p><h6>Customer Name : {$wohead.CustName} </h6>
<h6>Purchase Order Number : {$wohead.PONumber}</h6>
<h6>Our Ref No. : {$wohead.WONumber} </h6>
</p>
<p>
<table border="1" style="width:100%">
<tr>
<b>
<td>Item #</td>
<td>Description</td>
<td>Size</td>
<td>Quantity</td>
<td>UOM</td>
<td>Status</td>
</b>
</tr>
{foreach $woitemdetails as $detail}
<tr>
<td> {$detail.ItemNo}</td>
<td> {$detail.Descript}</td>
<td> {$detail.Size}</td>
<td> {$detail.Quantity}</td>
<td> {$detail.UOM}</td>
<td>{$detail.Status}</td>
</tr>
{/foreach}
</table>
</div>
</div>
<!-- center-side -->
Share
Improve this question
edited Feb 20, 2020 at 9:35
Alexter Philip de Guzman
asked Feb 19, 2020 at 12:27
Alexter Philip de GuzmanAlexter Philip de Guzman
32 bronze badges
3
- Please provide more details - it's hard to answer a question without sufficient information. Do you have any code samples/snippets? – Tony Djukic Commented Feb 19, 2020 at 15:33
- Please see modified post. – Alexter Philip de Guzman Commented Feb 20, 2020 at 9:39
- Ok, I see what you're looking for now... ...basically, you can either build a plugin and generate a template tag or integrate your functionality within the theme and again generate a template tag. You'll want to wrap your functionality and your output into the template tag and then add it to the template that is supposed to display the output. wpshout/why-when-and-how-to-make-your-own-template-tags Hope that helps. – Tony Djukic Commented Feb 20, 2020 at 15:00
1 Answer
Reset to default 1Generally speaking, you can typically take PHP code and place a comment at the top:
<?php
/* Plugin Name: My SOAP Plugin
*/
?>
You can then create a folder for the plugin inside /wp-content/plugins/ (for example, /wp-conten/plugins/my-soap-plugin/) and place the PHP file inside that folder. At that point, you can activate the plugin from wp-admin.
Depending on what specifically the PHP file does, it may need editing. For example, if it refers to any specific paths on a server, you'll need to adjust those as you almost certainly didn't have the file inside of a /wp-content/plugins/ folder before. Other changes will likely be needed - for example, you'll have to figure out what to do with the SOAP data - show it on a new admin screen? Display it on the front end for logged-in users associated with that data? - so it might require a significant amount of development work.