Last active
June 17, 2020 12:54
-
-
Save hedqvist/e4e5f191952c971b99aadeb6b33a0369 to your computer and use it in GitHub Desktop.
Unifaun Fix for CDON (Sharespine)
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 | |
| /** | |
| * @snippet WooCommerce - Unifaun plugin by Redlight Media - Add default shipping method to orders missing shipping | |
| * @author Redlight Media AB / Christopher Hedqvist | |
| * @compatible WooCommerce 4.2.0 | |
| */ | |
| add_filter( 'ac_wc_unifaun_order_list_shipping_method_id', 'redlight_unifaun_order_list_method_id', 10, 2); | |
| add_filter( 'ac_wc_unifaun_post_shipment_shipping_method_id', 'redlight_unifaun_order_list_method_id', 10, 2); | |
| add_filter( 'ac_wc_unifaun_post_return_shipment_shipping_method_id', 'redlight_unifaun_order_list_method_id', 10, 2); | |
| function redlight_unifaun_order_list_method_id( $method_id , $order ) { | |
| // For all orders created via rest-api, set flat_rate with instance 10 | |
| if( 'rest-api' === $order->get_created_via()){ | |
| $method_id = 'flate_rate:10'; | |
| } | |
| return $method_id; | |
| } | |
| add_filter( 'ac_wc_unifaun_order_list_shipping_instance_id', 'redlight_unifaun_order_list_instance_id', 10, 2); | |
| add_filter( 'ac_wc_unifaun_post_shipment_shipping_instance_id', 'redlight_unifaun_order_list_instance_id', 10, 2); | |
| add_filter( 'ac_wc_unifaun_post_return_shipment_shipping_instance_id', 'redlight_unifaun_order_list_instance_id', 10, 2); | |
| function redlight_unifaun_order_list_instance_id( $instance_id, $order ) { | |
| // For all orders created via rest-api, set instance id 10 | |
| if( 'rest-api' === $order->get_created_via()){ | |
| $instance_id = 10; | |
| } | |
| return $instance_id; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment