Changeset 2670794
- Timestamp:
- 02/01/2022 06:07:45 PM (4 years ago)
- File:
-
- 1 edited
-
socialproofy/trunk/socialproofy.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
socialproofy/trunk/socialproofy.php
r2670771 r2670794 37 37 register_activation_hook(__FILE__, 'socialproofy_cron_activation'); 38 38 add_action('socialproofy_cronjob', 'socialproofy_send_customers'); 39 add_action('socialproofy_cronjob', 'socialproofy_send_latest_orders');40 39 add_action('socialproofy_cronjob', 'socialproofy_send_products'); 41 40 register_deactivation_hook(__FILE__, 'socialproofy_cron_deactivate'); … … 463 462 464 463 foreach ($order->get_items() as $item) { 465 $product = $item->get_product();464 $product = wc_get_product($item->get_product_id()); 466 465 $product_id = $item->get_product_id(); 467 466 $item_name = $item->get_name(); … … 496 495 } 497 496 498 function socialproofy_is_connected()499 {500 return get_option('socialproofy_connected');501 }502 503 497 function socialproofy_send_latest_orders() 504 498 { 505 if (!socialproofy_is_connected()) {506 return;507 } 508 509 $orders = array(); 510 511 $latest_orders = get_posts(array(512 'numberposts' => 30,513 'post_type' => wc_get_order_types(),514 'post_status' => array_keys(wc_get_order_statuses()),515 )); 516 517 foreach ($latest_orders as $order) {518 $orders[] = socialproofy_generate_order_data($order->ID);519 } 520 521 socialproofy_post(array(522 'type' => 'latest_orders',523 'orders' => $orders,524 )); 525 499 $api_connected = socialproofy_check_api_key(); 500 if ($api_connected['status'] == true) { 501 502 $orders = array(); 503 504 $latest_orders = get_posts(array( 505 'numberposts' => 30, 506 'post_type' => 'shop_order', 507 'post_status' => array_keys(wc_get_order_statuses()), 508 )); 509 510 foreach ($latest_orders as $order) { 511 $orders[] = socialproofy_generate_order_data($order->ID); 512 } 513 514 socialproofy_post(array( 515 'type' => 'latest_orders', 516 'orders' => $orders, 517 )); 518 519 } 526 520 } 527 521
Note: See TracChangeset
for help on using the changeset viewer.