Data sent to nShift when retrieving shipping methods

  1. Home
  2. /
  3. Krokedil Shipping Connector
  4. /
  5. Customization
  6. /
  7. Data sent to nShift when retrieving shipping methods

Data sent to nShift when retrieving shipping methods

When using nShift Checkout (both via the nShift Checkout widget and via WooCommerce shipping) a request to retrieve available shipping methods will happen in checkout everytime the cart or the customer address changes. This is done via the GET delivery checkout request.

By default the following data is sent to nShift in this request:

  • currency (currency for the order)
  • language (language used for the order, fetched from get_locale()).
  • tocountry (customer country)
  • tozipcode (customer post code)
  • cartprice
  • weight (sum of all cart items)
  • Coupons – the name of each coupon code with this structure: coupon code name=true. If the coupon code enables free shipping, free_shipping=true will also be sent.

This data can be used when creating conditional logic in your nShift account.


Modify the data sent to nShift


If you want to add custom data to the request it is possible by using the filter ksc_delivery_checkouts_query_param in the following way:

/**
 * Filter the cart data sent to nShift in the GET delivery checkout request.
 * 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_delivery_checkouts_query_param', 'krokedil_ksc_delivery_checkouts_query_param');

function krokedil_ksc_delivery_checkouts_query_param( $args ) {
    // Add customer city to request.
  	$args['tocity'] = WC()->customer->get_shipping_city();
    return $args;
}