Changeset 2347170
- Timestamp:
- 07/27/2020 12:52:31 PM (6 years ago)
- Location:
- orderbee/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (2 diffs)
-
orderbee.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
orderbee/trunk/README.txt
r2346824 r2347170 4 4 Requires at least: 4.0.1 5 5 Tested up to: 5.4.2 6 Stable tag: 1.2. 26 Stable tag: 1.2.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 37 37 38 38 == Changelog == 39 40 = 1.2.3 = 41 * Bug fixing : updating products affected placing orders 42 39 43 40 44 = 1.2.2 = -
orderbee/trunk/orderbee.php
r2346824 r2347170 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.2. 219 * Version: 1.2.3 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.2. 2');37 define('ORDERBEE_VERSION', '1.2.3'); 38 38 39 39 /** … … 270 270 function obfrwc_push_product_to_server( $product_id ) { 271 271 272 $product_info = new WC_Product($product_id); 273 if($product_info->status === 'publish'){ 274 $arr_temp_product_info = array( 275 'id' => $product_info->id, 276 'status' => $product_info->status, 277 'type' => $product_info->get_type(), 278 'SKU' => $product_info->sku, 279 'manage_stock' => $product_info->manage_stock, 280 'images_links' => wp_get_attachment_url($product_info->image_id), 281 'name' => $product_info->name, 282 'price' => $product_info->price, 283 'regular_price' => $product_info->regular_price, 284 'tax_status' => $product_info->tax_status, 285 'tax_rate' => WC_Tax::get_rates( $product_info->get_tax_class() ), 286 'stock_quantity' => $product_info->stock_quantity, 287 'meta_data' => $product_info->get_meta_data(), 288 'variations' => array() 289 ); 290 /* VARIATION INFO */ 291 $obj_current_product = wc_get_product($product_info->id); 292 if ($obj_current_product->is_type('variable') == true) { 293 $arr_variations = $obj_current_product->get_available_variations(); 294 $temp_prod_var_list = array(); 295 foreach ($arr_variations as $prod_var_info) { 296 $variation_o = new WC_Product_Variation( $prod_var_info['variation_id'] ); 297 $manageStock = $variation_o->get_manage_stock(); 298 if($prod_var_info['max_qty']){ 299 $varQty = $prod_var_info['max_qty']; 300 }else{ 301 $varQty = $variation_o->get_stock_quantity(); 302 } 303 $temp_prod_var_list[] = array( 304 'id' => $prod_var_info['variation_id'], 305 'sku' => $prod_var_info['sku'], 306 'stock_quantity' => $varQty, 307 'manage_stock' => $manageStock, 308 'price' => $prod_var_info['display_price'], 309 'regular_price' => $prod_var_info['display_regular_price'], 310 'attributes' => $prod_var_info['attributes'], 311 'meta_data' => $variation_o->get_meta_data() 312 ); 313 } 314 if (!empty($temp_prod_var_list)) { 315 $arr_temp_product_info['variations'] = $temp_prod_var_list; 316 } 317 } 318 $url = 'https://app.orderbee.be/api/Woocommerce/NewProduct'; 319 $obfrwc_server_auth_id = get_option('obfrwc_server_auth_id'); 320 $arr_auth_param = array( 321 'consumer_id' => $obfrwc_server_auth_id, 322 'data' => json_encode($arr_temp_product_info), 323 'http' => $_SERVER["HTTP_HOST"] 324 ); 325 $response = wp_remote_post($url, ['body' => $arr_auth_param]); 326 $response_code = wp_remote_retrieve_response_code($response); 327 /* 328 print_r($response); 329 print_r($arr_temp_product_info); 330 exit; 331 */ 272 if ( !is_front_page() ) { 273 $product_info = new WC_Product($product_id); 274 if($product_info->status === 'publish'){ 275 $arr_temp_product_info = array( 276 'id' => $product_info->id, 277 'status' => $product_info->status, 278 'type' => $product_info->get_type(), 279 'SKU' => $product_info->sku, 280 'manage_stock' => $product_info->manage_stock, 281 'images_links' => wp_get_attachment_url($product_info->image_id), 282 'name' => $product_info->name, 283 'price' => $product_info->price, 284 'regular_price' => $product_info->regular_price, 285 'tax_status' => $product_info->tax_status, 286 'tax_rate' => WC_Tax::get_rates( $product_info->get_tax_class() ), 287 'stock_quantity' => $product_info->stock_quantity, 288 'meta_data' => $product_info->get_meta_data(), 289 'variations' => array() 290 ); 291 /* VARIATION INFO */ 292 $obj_current_product = wc_get_product($product_info->id); 293 if ($obj_current_product->is_type('variable') == true) { 294 $arr_variations = $obj_current_product->get_available_variations(); 295 $temp_prod_var_list = array(); 296 foreach ($arr_variations as $prod_var_info) { 297 $variation_o = new WC_Product_Variation( $prod_var_info['variation_id'] ); 298 $manageStock = $variation_o->get_manage_stock(); 299 if($prod_var_info['max_qty']){ 300 $varQty = $prod_var_info['max_qty']; 301 }else{ 302 $varQty = $variation_o->get_stock_quantity(); 303 } 304 $temp_prod_var_list[] = array( 305 'id' => $prod_var_info['variation_id'], 306 'sku' => $prod_var_info['sku'], 307 'stock_quantity' => $varQty, 308 'manage_stock' => $manageStock, 309 'price' => $prod_var_info['display_price'], 310 'regular_price' => $prod_var_info['display_regular_price'], 311 'attributes' => $prod_var_info['attributes'], 312 'meta_data' => $variation_o->get_meta_data() 313 ); 314 } 315 if (!empty($temp_prod_var_list)) { 316 $arr_temp_product_info['variations'] = $temp_prod_var_list; 317 } 318 } 319 $url = 'https://app.orderbee.be/api/Woocommerce/NewProduct'; 320 $obfrwc_server_auth_id = get_option('obfrwc_server_auth_id'); 321 $arr_auth_param = array( 322 'consumer_id' => $obfrwc_server_auth_id, 323 'data' => json_encode($arr_temp_product_info), 324 'http' => $_SERVER["HTTP_HOST"] 325 ); 326 $response = wp_remote_post($url, ['body' => $arr_auth_param]); 327 $response_code = wp_remote_retrieve_response_code($response); 328 /* 329 print_r($response); 330 print_r($arr_temp_product_info); 331 exit; 332 */ 333 } 332 334 } 333 335 } 334 336 //add_action( 'save_post_product', 'obfrwc_push_product_to_server', 10, 1 ); 335 add_action('wp_insert_post', 'obfrwc_push_product_to_server', 10, 3);337 add_action('wp_insert_post', 'obfrwc_push_product_to_server', 10, 1); 336 338 } 337 339 /**
Note: See TracChangeset
for help on using the changeset viewer.