HTTP Post
1 2 3 4 5 |
// modify Content-Type for HTTP Post ( Pro version) add_filter('wc_order_export_http_args', function ($args) { $args['headers']['Content-Type'] = "text/csv"; return $args; }); |
1 2 3 4 5 |
// send xml as POST variable "xml" ( Pro version) add_filter('wc_order_export_http_args', function ($args) { $args['body'] = http_build_query( array("xml"=>$args['body']) ); return $args; }); |
1 2 3 4 5 6 7 |
// parse and save HTTP reply ( Pro version) add_filter('woe_export_http_response', function ($response) { $parts = explode(",", $response['body'] ); // we get reply as plan text - "Tracking Number, Amount" update_post_meta( WC_Order_Export_Engine::$order_id, "tracking_number", $parts[0]); update_post_meta( WC_Order_Export_Engine::$order_id, "tracking_price", $parts[1]); return $response; }); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// Status Change job sends GET request , default action won't work add_filter("woe_export_http_custom_action", function($response, $url, $args) { $order = new WC_Order(WC_Order_Export_Engine::$order_id); //make vars here $vars = array(); $vars['key'] = "secretkey"; $vars['id'] = $order->get_id(); $vars['recipient'] = $order->get_shipping_first_name() . " " . $order->get_shipping_last_name(); $vars['company'] = $order->get_shipping_company(); $vars['street'] = $order->get_shipping_address_1(); $vars['city'] = $order->get_shipping_city(); $vars['state'] = $order->get_shipping_state(); $vars['countrycode'] = $order->get_shipping_country(); $vars['zipcode'] = $order->get_shipping_postcode(); $vars['phone'] = $order->get_billing_phone(); //send $url .= "?" . http_build_query($vars); $response = wp_remote_get($url, $args); return $response; },10,3); |