Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active January 29, 2020 10:04
Show Gist options
  • Select an option

  • Save hedqvist/49d98b8716b2d77382c13e20cabf0ee3 to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/49d98b8716b2d77382c13e20cabf0ee3 to your computer and use it in GitHub Desktop.
Unifaun - Adds Insurance AddOn
<?
/**
* @snippet WooCommerce - Adds ADDON to Shipment
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.9.0
*/
function redlight_unifaun_aspo_insurance( $shipment, $order ) {
// Only DHL Service Point
if($order->get_total() < 2000 ){
return $shipment;
}
if( 'ASPO' === $shipment['service']['id'] ){
$shipment['service']['addons'][] = array(
'id' => 'INSU',
'amount' => $order->get_total(),
'unit' => 'SEK'
);
}
return $shipment;
}
add_filter('ac_wc_unifaun_shipment_data', 'redlight_unifaun_aspo_insurance', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment