Skip to content

Instantly share code, notes, and snippets.

@hedqvist
Last active October 13, 2019 12:40
Show Gist options
  • Select an option

  • Save hedqvist/3c44e613a177a56b867ae92b35f52a7d to your computer and use it in GitHub Desktop.

Select an option

Save hedqvist/3c44e613a177a56b867ae92b35f52a7d to your computer and use it in GitHub Desktop.
Sync order on another status
<?php
add_action('woocommerce_order_status_changed', array($this, 'redlight_custom_update_woocommerce_order_status'), 10, 3);
/**
* @snippet WooCommerce - Fortnox plugin by Redlight Media - Sync order on "on-hold"
* @author Redlight Media AB / Christopher Hedqvist
* @compatible WooCommerce 3.7.0
*/
public function redlight_custom_update_woocommerce_order_status($order_id, $old_status, $new_status) {
if ('on-hold' == $new_status):
// cCheck if this order should be created as offer
$isOffer = Obj_Fortnox_Offer::check_is_order_offer($order_id);
if($isOffer){
$fortnoxOffer = Obj_Fortnox_Offer::get_instance();
$fortnoxOffer->create_offer($order_id);
$fortnoxOffer->create_offer_order($order_id);
}else{
// Create a normal order
$fortnoxOrder = Obj_Fortnox_Order::get_instance();
$fortnoxOrder->fortnox_order_completed($order_id);
}
endif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment