Thread Starter
cybsys
(@cybsys)
Small update. All changes above were reverted and this function needs to be edited (along with get_dhl_close_out_label_file_info). “C:” must be removed from the path otherwise it fails to create a label. However, after editing these two functions, I cannot download the label when I clock on ‘Download Label’. It downloads a file called “post.htm” which seems to just contain the entire webpage source.
public function get_dhl_item_label_file_info( $barcode, $format = 'pdf' )
{
$file_name = $this->get_dhl_item_label_file_name($barcode, $format);
$folder_dir = PR_DHL()->get_dhl_label_folder_dir() . $file_name;
$folder_url = PR_DHL()->get_dhl_label_folder_url() . $file_name;
$folder_dir = substr($folder_dir, 2); // remove "C:" from the string
/*if(1) { throw new Exception( __($folder_dir)); }*/ // debugging
return (object) array(
'path' => $folder_dir,
'url' => $folder_url,
);
}
Any ideas @shadim?
-
This reply was modified 5 years, 3 months ago by
cybsys.
-
This reply was modified 5 years, 3 months ago by
cybsys.
Are you using a Windows server?
Thread Starter
cybsys
(@cybsys)
Yes. Windows Server 2012. Did you design this plugin with only a Unix system in mind? If so, we’ll need to fix it. It’s better to do a string find and replace than to remove the first 3 chars in the string like I am and run a function which verifies if it’s a Windows system or not, but that can be done later. For now, I’m just trying to figure out why the file downloads are not working. Any advice? π
Thread Starter
cybsys
(@cybsys)
Okay, I got it working. File to edit is abstract-pr-dhl-wc-order.php. However, you need to refresh the page once you have created the label (which is very annoying). This is because of this code.
global $woocommerce, $post;
$order_id = $post->ID;
To fix that, you need to edit the function generate_download_url in class-pr-dhl-wc-order-ecs-asia.php and class-pr-dhl-api-ecs-asia.php to have a second argument which is $order_id so the order ID is parsed on execution since the page doesn’t pull that data after the page has loaded.
Anyway, here is the updated function
public function generate_download_url( $endpoint_path )
{
// used for Windows Server only
global $woocommerce, $post;
$order_id = $post->ID;
// If we get a different URL addresses from the General settings then we're going to
// construct the expected endpoint url for the download label feature manually
if ( site_url() != home_url() ) {
// You can use home_url() here as well, it really doesn't matter
// as we're only after for the "scheme" and "host" info.
$result = parse_url( site_url() );
if ( !empty( $result['scheme'] ) && !empty( $result['host'] ) )
{
return $result['scheme'] . '://' . $result['host'] . $endpoint_path;
}
}
// Defaults to the "Site Address URL" from the general settings along
// with the the custom endpoint path (with parameters)
//return home_url($endpoint_path); // Unix
// Windows Server will generate "https://mysite.com/dhl_download_label/1234" so we will inject the path manually
$label_tracking_info = $this->get_dhl_label_tracking($order_id);
$label = substr($label_tracking_info['label_path'], 17);
return home_url($label);
}
Make the changes to your GitHub repo (but of course, don’t use the hardcoded substr code. Make it dynamic). This bug is horrid. You shouldn’t code projects for Unix only. A LOT of people use Windows Server.
https://github.com/shadimanna/dhl-logistic-services-for-woocommerce
-
This reply was modified 5 years, 3 months ago by
cybsys.
-
This reply was modified 5 years, 3 months ago by
cybsys.
-
This reply was modified 5 years, 3 months ago by
cybsys.
-
This reply was modified 5 years, 3 months ago by
cybsys.
-
This reply was modified 5 years, 3 months ago by
cybsys.
-
This reply was modified 5 years, 3 months ago by
cybsys.
You should actually place the substr in the download_label function at the end of that file. Can you confirm that works as well?
Thread Starter
cybsys
(@cybsys)
Dunno. I don’t want to waste any more time on this plugin. I’ve already spent several hours working on it. It’s working for me so I’ll leave it be. Best you setup a Windows Server on a localhost, get a quick database setup with WordPress and test it yourself to see the pain I had to go through to get it working.
Same Problem here; above suggested fixes did not work;
Also running on Windows; Log can be found here:
https://pastebin.com/iuRDBiG2
Thread Starter
cybsys
(@cybsys)
Your environment may not be using class-pr-dhl-api-ecs-asia.php. Some may use the REST or SOAP PHP files instead. You will have to just run tests like I did in my first post to figure out which PHP file triggers the label creation. From there, you can edit the functions and fix them as needed.
@shadim should really be working on fixing this plugin properly for public use with Windows Server though or at least mention that it’s for Unix servers only.
We are working to make the plugin compatible with Windows, thank you for your patience.
how far are you with the adjustments?
We hope to have this with a couple of weeks.
thank you for your response.
actually i used the substr function in the file class-pr-dhl-api-soap-label.php so that at least the label is created.
but i did not get the download link of the label connected with the button. the code from cybsys does not have an effect in my configuration. but i found out, that i have to use the file abstract-pr-dhl-wc-order.php. only the adjustments do not work.
but it is fine for me to wait and use the direkt access via ftp to get the label data when you bring out a version for windows servers in some weeks.