further we suggest a code change to make the plugin much faster when used with OPC:
located this file:
\plugins\vmshipment\cpsolvm2\cpsolvm2php
and update whole function to this including the static variable definition:
- Code: Select all
//stAn:
static $cacher;
private function sendRequestXML() {
if (!empty(self::$cacher[$this->xml_request]))
{
foreach ( self::$cacher[$this->xml_request] as $key=>$val)
{
$this->$key = $val;
}
return;
}
else
{
self::$cacher[$this->xml_request] = new stdClass();
}
//check cURL enabled
if (in_array('curl', get_loaded_extensions())) {
$url = "http://sellonline.canadapost.ca:30000";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->xml_request);
$response = curl_exec($ch);
if (curl_errno($ch)) {
$this->_error = true;
$this->_error_msg = curl_errno($ch) . " : " . curl_error($ch);
$this->xml_response = '';
self::$cacher[$this->xml_request]->_error = true;
self::$cacher[$this->xml_request]->_error_msg = curl_errno($ch) . " : " . curl_error($ch);
self::$cacher[$this->xml_request]->xml_response = '';
} else {
$this->xml_response = $response;
self::$cacher[$this->xml_request] = $response;
}
// Close connection
curl_close($ch);
} else {
//try fsockopen
$fp = fsockopen("http://sellonline.canadapost.ca", 30000, $errno, $errstr, 30);
if (!$fp) {
VmError(JText::sprintf('PLG_VMSHIPMENT_CPSOL_OPEN_SOCKET_ERROR', $errstr, $errno));
$this->_error = true;
$this->_error_msg = $errstr;
self::$cacher[$this->xml_request]->_error = true;
self::$cacher[$this->xml_request]->_error_msg = $errstr;
} else {
fwrite($fp, $this->xml_request);
while (!feof($fp)) {
$data = fgets($fp, 4096);
$this->xml_response .= $data;
self::$cacher[$this->xml_request]->xml_response .= $data;
}
fclose($fp);
}
}
}
secondly as far as we had tested this plugin, it seems that it only works when no other plugins are used because of using this line:
- Code: Select all
$html .= '<input type="hidden" name="virtuemart_shipmentmethod_id" value="' . $method->$pluginmethod_id . '" />
which always forces the ID to be the Canada Post plugin.
The updated opc code to support this version of cpsolvm2 will be available in opc 2.0.249.
Best Regards, Stan