Custom Hooks (technical knowledge required)

⚠️  Note that this is a technical explanation intended for website builders.

For our (Parcel Pro) plugin, we also have the ability to overwrite certain values via external code before sending them to our server. This is useful if you have a separate implementation of the checkout in which standard fields from WooCommerce are modified. A common example of this is the field address_1 which is often split into separate fields: street name and house number. If this data is forwarded, the house numbers often do not come in correctly

Below we show how to modify this with our custom hook in the WooCommerce code.

1 Function

The first step is to create an independent function. That means a function outside the scope of a class so that it can be easily found by the WooCommerce system during the call.
//A function that is not in the scope of class to add to the custom hook.

This function will receive the value $data. This will be padded with the complete shipping data sent to the Parcel Pro system. Below is the json representation of this data.
In this example, we take the value shipping_address and from it the field address_1 and overwrite it with our new value, street name and house number stuck together. In this case we chose Griede and 22 for this, you could replace these with variables.

JSON $data

{<br>   "orderNR":"421",<br><br>   "increment_id":421,<br><br>   "order":{<br><br>   },<br><br>   "items":[<br><br>      {<br><br>         "id":135,<br><br>         "order_id":421,<br><br>         "name":"Product 7"<br><br>         "product_id":15,<br><br>         "variation_id":0,<br><br>         "quantity":2,<br><br>         "tax_class":"",<br><br>         "subtotal":"0",<br><br>         "subtotal_tax":"0",<br><br>         "total":"0",<br><br>         "total_tax":"0",<br><br>         "taxes":{<br><br>            "total":[<br><br>            ],<br><br>            "subtotal":[<br><br>            ]<br><br>         },<br><br>         "meta_data":[<br><br>         ],<br><br>         "sku":""<br><br>      }<br><br>   ],<br><br>   "billing_address":{<br><br>       "firstname":"ICT",<br><br>      "lastname":"Parcel Pro",<br><br>      "company":"",<br><br>      "address_1":"Griede 22",<br><br>      "address_2":"",<br><br>      "city":"hoogvliet",<br><br>      "state":"",<br><br>      "postcode":"3191 EE",<br><br>      "country_id":"NL",<br><br>      "email":" ict",<br><br>      "telephone":""<br><br>   },<br><br>   "shipping_address":{<br><br>      "firstname":"ICT",<br><br>      "lastname":"Parcel Pro",<br><br>      "company":"",<br><br>      "address_1":"Griede 22",<br><br>      "address_2":"",<br><br>      "city":"hoogvliet",<br><br>      "state":"",<br><br>      "postcode":"3191 EE",<br><br>      "country_id":"NL",<br><br>      "email":"[email protected]",<br><br>      "telephone":""<br><br>   },<br><br>   "subtotal":0,<br><br>   "subtotal_incl_tax":0,<br><br>   "grand_total":"0.00",<br><br>   "shipping_method":"parcelpro_maatwerk_5_0",<br><br>   "created_at":{<br><br>      "date":"2020-03-24 14:10:27.000000",<br><br>      "timezone_type":1,<br><br>      "timezone":"+00:00"<br><br>   },<br><br>   "aantal_pakketten":1<br><br>}

2 Add_action

To ensure that this function is called, we need to add an action for our hook parcelpro_format_order_data for this purpose. You can do that using the following line:
'add_action(' parcelpro_format_order_data','independent_function_to_process_data');
After this modification, the previously created function is called and the data is modified. Then this is sent to the Parcel Pro shipping system, now with the correct value of your custom check out!

Frequently Asked Questions 

With a WooCommerce shop, can you also show DHL and/or PostNL parcel points in the checkout?
Yes you can set the option DHL Parcelshop or PostNL Parcelshop in the WooCommerce plugin to show all points. This way, customers who order can choose a pickup point themselves.
Is it also possible to create multiple WooCommerce links?
Yes this is possible as long as there is a separate back-end environment for each link. You can then install the link in the new back-end in exactly the same way.

An order transfer using the button does not work.
Check if your UserID and API  Key data are correct in the plugin's configuration. These can be found via WooCommerce > Settings > Shipping Methods > Parcel Pro. And in the shipping system on the Links page.

Which carriers are supported?
The carriers  BrengerBudbeeDHLFedex Cross BorderHomerrPostNLSave your Package and  UPS are supported based on the activated contracts under your account in the shipping system.
The track & trace button shows a blank page
For best performance, we recommend using the shipping methods from our plugin. This way a consumer can choose a linked shipping method. When the data is transferred, the shipping system can determine a corresponding shipping type and immediately feed back the required track & trace data. If not, it will be based on the default shipping method set in the shipping system.
If our shipping methods are not used in the plugin, all shipments will be entered into our shipping system based on the default shipping type. This can therefore mean that an incorrect track & trace code is fed back to WooCommerce. In this case, it is useful to uncheck the checkbox Add tracking to order.

A shipment contains incorrect data or an incorrect type of shipment
This has to be changed manually in our shipping system. For the time being, it is not possible - after an order with chosen shipping type from the consumer - to make a change to the shipping type in WooCommerce, or to resubmit an order.

Need support?

Still experiencing problems or having questions? Please don't hesitate to contact us via or by phone via  +31 (0)320 - 33 77 77. 

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.