Hooks (action & filter)

Hooks (action & filter)

Hooks in WordPress essentially allow you to change or add code without editing core files. They are used extensively throughout WordPress and WooCommerce and are very useful for developers.

Read more about action and filter hooks here:


How and where to insert the code?


To get the functions exemplified in this section to work you need to add the code to your theme’s functions.php. You can add it as its own plugin or through the Code Snippets plugin, or something similiar of your choice.


Filters


Goods description & parcel content text

The plugin standard is that you enter general description of the content in the nShift parcel content text field in the Shipment config settings.

Use the filter below to override the standard and submit goods description and parcel content to nShift when a Stored shipment is created. This info will populate the “Content” (“Innehåll”) field under the “Parcels” (“Kollin”) section in nShift.

add_filter('ksc_goods_description', 'my_ksc_goods_description', 10, 2 );

function my_ksc_goods_description( $goods_description, $order ) {
	if( $order ) {
		// Modifiera $goods_description här.
	}
	return $goods_description;
}