Krokedil Shipping Connector

  1. Home
  2. /
  3. Krokedil Products
  4. /
  5. Krokedil Shipping Connector

Krokedil Shipping Connector

Introduction


Krokedil Shipping Connector is a plugin which makes it possible for you as a merchant to create or store shipments in nShift Delivery (previously Unifaun Online) directly from WooCommerce, for orders created via Klarna Shipping Assistant (KSA) which is a part of Klarna Checkout.

Useful internal links

Technical information – plugin data and changelog

Useful external links

English product page on krokedil.com

Svensk produktsida på krokedil.se


Requirements



Installation


You install this plugin just like any other WordPress plugin:

  1. Download and unzip the latest release zip file.
  2. If you use the WordPress plugin uploader to install this plugin skip to step 4.
  3. Upload the entire plugin directory to your /wp-content/plugins/ directory.
  4. Activate the plugin through the ‘Plugins’ menu in WordPress Administration.

Configuration – plugin


  1. Navigate to WooCommerce -> Settings -> Shipping.
  2. Now Krokedil Shipping Connector is displayed as an available option in the horizontal menu at the top. Click on this link to access the Krokedil Shipping Connector settings.
  3. nShift id – Your nShift API ID . Available from your nShift Delivery account. 
    In your nShift Delivery account, navigate to → Maintenance → API keys, and click on the search button. Now you will see a list of the API Keys in your account. Click on the “Pen” next to API Id. Now you will find the ID.
  4. nShift secret id – Your nShift Secret API ID. Available from your nShift Delivery account. 
    In your nShift Delivery account, navigate to → Maintenance → API keys, and click on the search button. Now you will see a list of the API Keys in your account. Click on the “Pen” next to API Id. Now you will find the Secret ID.
  5. nShift quick id – Your nShift Quick ID. Available from your nShift Delivery account.
    In your nShift Delivery account, navigate to  → maintenance → senders → and click on the search button. Now you will see a list of the API Keys in your account. Now you will see a list of the companies you have added and there you will see the Quick ID for each individual company.
  6. nShift printing favorite mapper – Map Delivery Option Title with Printing favorite Name.
    – The Delivery Option Title is the name of the shipping method displayed for the customer (and what is stored as shipping method in the order in WooCommerce).
    – The Printing favorite Name is available from your nShift Delivery account. In your nShift Delivery account, navigate to → Maintenance → Printing favorites → and click on the search button. Now you will see a list of your printing setups. You should add the Name on the one you want to use as a favorite in the plugin settings.

    The data saved in this setting must be saved as valid JSON for the mapper to work. You can check if your text is valid JSON at jsonlint.com. Here is an example how to enter the text:
{
	"Delivery Option Title": "Printing favorite Name",
        "DHL Home delivery": "DHL Home",
	"Postnord Service point": "Servicepoint"
}
  1. Fallback printing favorite – Enter your default nShift Printing favorite Name. Will be used if no match is found in the “nShift printing favorite mapper”.
  2. Debug log – Log events in the module. You can find the log by navigating to → WooCommerce → Status → Logs.
  3. nShift Track & Trace – Tracking link of the shipment will be available for customer and merchant. (Requires you to have the additional “Track & Trace” service active on your nShift-plus account). 
  4. Create Shipment or Store Shipment – Select where you want to handle the shipments and printing of the pdf shipment labels. Detailed explanation here.
  5. Choose status on orders with Krokedil Shipping Connector – Enable if you want the order status in WooCommerce to change on orders edited with Krokedil Shipping Connector plugin.
  6. Create/Store Shipment on order complete – Tick the checkbox if you want the plugin to automatically make a request to nShift and create/store the shipment when the order in WooCommerce is set to status Completed.  

Configuration – KSA / nShift


  • Configuration of Klarna Shipping Assistant together with nShift Checkout is something that you need to do in your Klarna and nShift backend accounts. 
  • It’s recommended that you start the configuration in a staging/test environment so you don’t break your production web store.

Read more about how to get started with KSA & nShift in this nShift documentation.


Conditional shipping methods


In some cases you might want to enable or disable specific shipping methods if a certain condition is met. For instance if an order contains bulky goods then delivery by bicycle might not be an option. To be able to handle these conditions the Klarna Shipping Assistant plugin sends WooCommerce Product Shipping Classes to Klarna/nShift. I you would like to disable a specific shipping method if a certain product shipping class exist in an order you can do the following:

  1. Add a shipping class to a product. In this case we call it Bulky.
  2. Navigate to nShift Delivery and edit the delivery checkout you are using for the KSA integration.
  3. Add a new Parameter. Give it the same name as the WooCommerce Shipping Class slug (in our case bulky). Set the Type to Boolean and specify the default value (in our case false).
  4. Now you need to configure each delivery option and specify the Condition.

    The shipping options that should be available only when an order doesn’t contain Bulky goods you enter bulky = false in the Condition box. 

    The shipping options that should be available only when an order does contain Bulky goods you enter bulky = true in the Condition box. 
  5. After saving the changes you can first test the Delivery checkout directly in nShift online test tool. When you see that it is working you can test it in Klarna Checkout.

Free shipping coupons 


In the same way as product shipping classes is passed to Klarna (and then forwarded to nShift), a tag named ksa_free_shipping is sent to Klarna if a coupon code is used that enables the customer free shipping. In the same way as the bulky example in the Conditional shipping methods section above, you can enable free shipping in the nShift Checkout configuration if ksa_free_shipping = true.


Create Shipment or Store Shipment


“Create Shipment” and “Store Shipment” is two different flows of the Krokedil Shipping Connector plugin and will make it possible for you to choose where you want to handle your shipments and pdf shipment labels. 

Create Shipment

If choosing “Create Shipment” the creation of the shipment will be done directly from WooCommerce. The pdf shipment label will be generated as soon as the “Create Shipment” button has been clicked. The pdf shipment label can be accessible through navigating to the specific order or through action buttons on the order overview page in WooCommerce backend.

Store Shipment

If choosing “Store Shipment” the creation of the shipment will be done from your nShift account. The shipment will be sent to a printing queue called “Stored Printings” in nShift. In order to create the shipment you will have to login to your nShift account and once the pdf shipment label is printed the shipment will be created.


Order management


Only orders made through Klarna Shipping Service will have the ability to have the shipment be created or stored.

Create Shipment

  1. Navigate to → WooCommerce → Orders.
  2. You can Create a shipment in multiple ways.
    1. Clicking the truck icon located to the right when viewing all orders.
    2. Selecting the Create Shipment option in the WordPress Bulk Action drop down menu.
    3. Navigating to the specific order and clicking the Create Shipment button located inside the metabox to the right.
  3. If a shipment was successfully created, the order note will display Shipment successfully created.

Store Shipment

  1. Navigate to → WooCommerce → Orders.
  2. You can Store a shipment in multiple ways.
    1. Clicking the arrow icon located to the right when viewing all orders.
    2. Selecting the Create Stored Shipment option in the WordPress Bulk Action drop down menu.
    3. Navigating to the specific order and clicking the Create Stored Shipment button located inside the metabox to the right.
  3. If a shipment was successfully stored, the order note will display Shipment successfully stored.

Cancel Shipment

  1. Navigate to → WooCommerce → Orders.
  2. Navigating to the specific order and clicking the “Cancel Shipment” button located inside the metabox to the right.
  3. If a shipment was successfully cancelled, the order note will display “Shipment successfully cancelled”.

Remove Stored Shipment

  1. Navigate to → WooCommerce → Orders.
  2. Navigating to the specific order and clicking the “Remove Stored Shipment” button located inside the metabox to the right.
  3. If a shipment was successfully removed, the order note will display “Shipment successfully removed”.

Modify data sent to nShift


If yo need to add, remove or edit data sent to nShift when the create shipment request is triggered, you can use the filter  ksc_create_shipment_body.

Here is an example how to add a pickup date (which is required but not provided by Klarna or nShift) if the carrier is Budcompaniett.

<?php
/**
 * Use together with Krokedil Shipping Connector pluign.
 * https://krokedil.se/produkt/krokedil-shipping-connector/
 *
 * Modify the create shipment request body. In this case we add pickupDate if the carrier is Budcompaniet.
 * Add this code to your themes functions.php file or include it in a separate functionality plugin (https://css-tricks.com/wordpress-functionality-plugins/).
 **/
add_filter('ksc_create_shipment_body', 'custom_ksc_create_shipment_body_2', 10, 2 );

function custom_ksc_create_shipment_body_2( $args, $order ) {
	// The shimpment data for the order, selected by the customer in KCO/KSA.
	$kco_kss_data  = get_post_meta( $order->get_id(), '_kco_kss_data', true );
	$shipment_data = json_decode( $kco_kss_data, true );
	
	//Get the carrier for the order.
  	$carrier = $shipment_data['delivery_details']['carrier'];
  
  	if( 'budcompaniett' === strtolower( $carrier ) ) {
		// Send the pickup date to nShift Delivery.
		$args['service']['properties']['pickupDate' ] = date("Y-m-d");
	}
	
 	return $args;
}