More replacement patterns are needed. Some providers need the postal code and optional some others.
We need a possibility to add these

=====
Hi,

Next to @tracking_number, I need @country, @postal_code and @language.

I am going to implement, and post the results here.

Jurgen

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jurgen8en’s picture

The language part is not part of Drupal Commerce, I think.

function simple_package_tracking_save_tracking(
  $order_id, $number, &$url, $carrier, $note, $id = NULL
) {
  $url = preg_replace('/\s+/', '', $url);
  $url = str_replace('@tracking_number', $number, $url);
  
  //NEW
  $order = commerce_order_load($order_id);
  $url = str_replace('@language', $order->field_language[LANGUAGE_NONE][0]['code'], $url);
  $order_wrapper = entity_metadata_wrapper('commerce_order', $order);
  $shipping = $order_wrapper->commerce_customer_shipping->commerce_customer_address->value();
  $url = str_replace('@country', $shipping['country'], $url);
  $url = str_replace('@postal_code', $shipping['postal_code'], $url);
rhouse’s picture

Which carrier requires these fields? Can you give an example?

tim_dj’s picture

Here is a patch that will support any field out of commerce_shipping.
In the settings screen there is now an option to enable this.

Other changes
- changed max carrier_url length to 255. 128 is too short for some carries.
- simple_package_tracking_uninstall() added the two variables that are used
- added PostNL (domestic) to tracking-urls.txt (This uses the @postal_code replacement variable)

tim_dj’s picture

Title: More replacement patters » More replacement patterns
Status: Active » Needs review
tim_dj’s picture

Issue summary: View changes
rhouse’s picture

Thanks tim_dj for that code. I have committed it, I assume it will turn up in dev soon. If no one finds any problems I can make a new release version with this and other minor changes.

Status: Needs review » Needs work
tim_dj’s picture

Status: Needs work » Fixed

already in development branch. That also the reason for the failed test.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.