Last active
October 13, 2019 12:40
-
-
Save hedqvist/3c44e613a177a56b867ae92b35f52a7d to your computer and use it in GitHub Desktop.
Sync order on another status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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