/** * Submit the product to Bling. * * @param WC_Product $order Product data. * * @return array Response data. */ public function submit_product($product) { $data = array(); $xml = $this->get_product_xml($product); if ('yes' == $this->integration->debug) { $this->integration->log->add('bling', 'Submitting product ' . $product->get_sku() . ' with the following data: ' . $xml); } // Set endpoint for update or insert $product_code = $product->bling_code; $endpoint = 'produto/json/'; if (!empty($product_code)) { $endpoint = "produto/{$product_code}/json/"; } // Get the response. $response = $this->do_request($endpoint, 'POST', $xml); if ($response) { try { $data = json_decode($response['body'], true); } catch (Exception $e) { if ('yes' == $this->integration->debug) { $this->integration->add('bling', 'Error while parsing the response: ' . print_r($e->getMessage(), true)); } } } return $data; }
/** * Submit the order to Bling. * * @param WC_Order $order Order data. * * @return array Response data. */ public function submit_order($order) { $data = array(); $xml = $this->get_order_xml($order); if ('yes' == $this->integration->debug) { $this->integration->log->add('bling', 'Submitting order ' . $order->get_order_number() . ' with the following data: ' . $xml); } // Get the response. $response = $this->do_request('pedido/json/', 'POST', $xml); if ($response) { try { $data = json_decode($response['body'], true); } catch (Exception $e) { if ('yes' == $this->integration->debug) { $this->integration->add('bling', 'Error while parsing the response: ' . print_r($e->getMessage(), true)); } } } return $data; }