sim0nm
Forum Replies Created
-
Forum: Plugins
In reply to: [DHL Shipping Germany for WooCommerce] Shipping “Address 2” is empty!https://pastebin.com/auyxfJVw (untested)
As i said, this relies on https://github.com/VIISON/AddressSplitting which is basically a huge and complex regex, it was way easier to just use that than to roll my own regex.
Introducing that as a dependency for internal usage isn’t a problem for me, but for the plugin itself it might.
Forum: Plugins
In reply to: [DHL Shipping Germany for WooCommerce] Shipping “Address 2” is empty!A short followup:
A workaround seems to be:
Hook into the DHL args with a filter:
add_filter('pr_shipping_dhl_label_args', array($this, 'fix_dhl_address'), 2, 10);and to set the args fields there, e.g.:
$args['shipping_address']['address_1'] = $split['streetName']; $args['shipping_address']['address_2'] = $split['houseNumber'];(We use this: https://github.com/VIISON/AddressSplitting)
Forum: Plugins
In reply to: [DHL Shipping Germany for WooCommerce] Shipping “Address 2” is empty!Hi,
can confirm and this is clearly a bug. The assumption that house “numbers” are numeric is wrong: Check out:https://de.wikipedia.org/wiki/Hausnummer#Hausnummernerg%C3%A4nzungen
or
https://www.mjt.me.uk/posts/falsehoods-programmers-believe-about-addresses/
Another example to make it clearer:
Teststr. 2A is a valid format.
This happens in:
// ...last found number will be 'address_2' foreach ($address_exploded as $address_key => $address_value) { if (is_numeric($address_value)) { // Set last index as street number $args['shipping_address']['address_2'] = $address_value; $set_key = $address_key; } }class-pr-dhl-api-soap-label.php
It would be better to not make any assumptions about the adress field at all (just accept the first part and let DHL handle the rest, e.g. _fail_ if the DHL API can’t handle it?)
Has this anything to do with the adress being DHL codeable? If so, can’t the DHL API handle that? Does it report back if the adresss is not codeable?
This should be possible via the “customerReference” Argument (in ShipmentOrder -> ShipmentDetails of e.g. a SOAP Request to the DHL API).
From the DHL API docs:
ShipmentOrder. Shipment. ShipmentDetails.
customerReference String
maxLength: 35 Optional A reference number that the client can assign for better association purposes. Appears on shipment label.In the meantime it would be great to have a filter on the return value of set_message() in dhl-for-woocommerce/includes/pr-dhl-api/class-pr-dhl-api-soap-label.php, e.g.:
return apply_filters('pr_shipping_dhl_label_soap_message', $this->body_request);A filter for $dhl_label_body would work as well, before:
// Unset/remove any items that are empty strings or 0, even if required! $this->body_request = $this->walk_recursive_remove( $dhl_label_body );(I know the pr_shipping_dhl_label_args filter exists, but that only allows manipulation of existing args, can’t add/inject anything to the request itself).
Basically a one-liner for you Shadi without breaking anything, for my use case it’s probably enough. Wouldn’t need to hack it into the plugin itself (stays updateable).
- This reply was modified 7 years, 3 months ago by sim0nm. Reason: fix typo