Changeset 2346001
- Timestamp:
- 07/24/2020 10:35:23 AM (6 years ago)
- Location:
- orderbee/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (1 diff)
-
orderbee.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
orderbee/trunk/README.txt
r2345995 r2346001 4 4 Requires at least: 4.0.1 5 5 Tested up to: 5.4.2 6 Stable tag: 1.1. 06 Stable tag: 1.1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
orderbee/trunk/orderbee.php
r2345996 r2346001 17 17 * Plugin URI: https://www.orderbee.be 18 18 * Description: This plugin makes a fast and safe connection between your Woocommerce and OrderBee. 19 * Version: 1.1. 019 * Version: 1.1.1 20 20 * Author: OrderBee 21 21 * Author URI: https://www.orderbee.be … … 35 35 * Rename this for your plugin and update it as you release new versions. 36 36 */ 37 define('ORDERBEE_VERSION', '1.1. 0');37 define('ORDERBEE_VERSION', '1.1.1'); 38 38 39 39 /** … … 64 64 require plugin_dir_path(__FILE__) . 'includes/class-orderbee.php'; 65 65 require plugin_dir_path(__FILE__) . 'includes/class-orderbee-settings.php'; 66 include plugin_dir_path(__FILE__) . 'includes/class-orderbee-pushorders.php';67 66 68 67 /** … … 150 149 151 150 } 151 152 if (!function_exists('obfrwc_push_to_server')) { 153 154 function obfrwc_push_to_server($order_id) { 155 global $wpdb; 156 $order = new WC_Order($order_id); 157 $input = array(); 158 $input['ordernumber'] = $order->get_order_number(); 159 $input['email'] = $order->get_billing_email(); 160 $input['name'] = $order->get_formatted_billing_full_name(); 161 $input['company_name'] = $order->get_billing_company(); 162 $input['contact_number'] = str_replace(' ', '', $order->get_billing_phone()); 163 $input['address_1'] = $order->get_billing_address_1(); 164 $input['address_2'] = $order->get_billing_address_2(); 165 $input['city'] = $order->get_billing_city(); 166 $input['postal_code'] = $order->get_billing_postcode(); 167 $input['country'] = $order->get_billing_country(); 168 $input['del_name'] = $order->get_formatted_shipping_full_name(); 169 $input['del_company_name'] = $order->get_shipping_company(); 170 $input['del_address_1'] = $order->get_shipping_address_1(); 171 $input['del_address_2'] = $order->get_shipping_address_2(); 172 $input['del_city'] = $order->get_shipping_city(); 173 $input['del_postal_code'] = $order->get_shipping_postcode(); 174 $input['del_country'] = $order->get_shipping_country(); 175 $input['instructions'] = $order->get_customer_note(); 176 $input['payment_method'] = $order->get_payment_method(); 177 $input['payment_date'] = $order->get_date_paid(); 178 $input['shipping_total'] = $order->get_shipping_total(); 179 $input['shipping_tax'] = $order->get_shipping_tax(); 180 $shipping_lines = $order->get_shipping_methods(); 181 foreach($shipping_lines as $id => $shipping_line){ 182 $shippingLineArray = $shipping_line->get_data(); 183 $taxesShipping = WC_Tax::get_rates($shipping_line->get_tax_class()); 184 foreach($taxesShipping as $taxShipping){ 185 $shippingLineArray["tax_rate"] = $taxShipping['rate']; 186 } 187 $input['shipping_lines'][] = $shippingLineArray; 188 } 189 $meta_data = $order->get_meta_data(); 190 foreach($meta_data as $meta){ 191 $meta = $meta->get_data(); 192 $input['meta_data'][] = $meta; 193 } 194 $input['order_total_inc'] = wc_format_decimal($order->get_total(), 2); 195 $items = $order->get_items(); 196 foreach($items as $item){ 197 $itemIntel = $item->get_data(); 198 $itemArray = array(); 199 $product = new WC_Product($itemIntel['product_id']); 200 $sku = $product->get_sku(); 201 $itemArray["sku"] = $sku; 202 $itemArray["name"] = $itemIntel['name']; 203 $itemArray["quantity"] = $itemIntel['quantity']; 204 $itemArray["subtotal"] = $itemIntel['subtotal']; 205 $itemArray["subtotal_tax"] = $itemIntel['subtotal_tax']; 206 $taxes = WC_Tax::get_rates($item->get_tax_class()); 207 foreach($taxes as $tax){ 208 $itemArray["tax_rate"] = $tax['rate']; 209 } 210 $itemArray["meta_data"] = $itemIntel['meta_data']; 211 $input['items'][] = $itemArray; 212 } 213 $fees = $order->get_items('fee'); 214 if($fees){ 215 $input['fee'] = array(); 216 foreach($fees as $fee){ 217 $feeArray = $fee->get_data(); 218 $taxesFee = WC_Tax::get_rates($fee->get_tax_class()); 219 foreach($taxesFee as $taxFee){ 220 $feeArray["tax_rate"] = $taxFee['rate']; 221 } 222 $input['fee'][] = $feeArray; 223 } 224 } 225 226 227 $url = 'https://app.orderbee.be/api/Woocommerce/NewOrder'; 228 $obfrwc_server_auth_id = get_option('obfrwc_server_auth_id'); 229 $arr_auth_param = array( 230 'consumer_id' => $obfrwc_server_auth_id, 231 'data' => json_encode($input), 232 'http' => $_SERVER["HTTP_HOST"] 233 ); 234 $response = wp_remote_post($url, ['body' => $arr_auth_param]); 235 $response_code = wp_remote_retrieve_response_code($response); 236 } 237 238 add_action('woocommerce_payment_complete', 'obfrwc_push_to_server'); 239 }
Note: See TracChangeset
for help on using the changeset viewer.