Plugin Directory

Changeset 2670794


Ignore:
Timestamp:
02/01/2022 06:07:45 PM (4 years ago)
Author:
socialproofy
Message:

get order bug fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • socialproofy/trunk/socialproofy.php

    r2670771 r2670794  
    3737register_activation_hook(__FILE__, 'socialproofy_cron_activation');
    3838add_action('socialproofy_cronjob', 'socialproofy_send_customers');
    39 add_action('socialproofy_cronjob', 'socialproofy_send_latest_orders');
    4039add_action('socialproofy_cronjob', 'socialproofy_send_products');
    4140register_deactivation_hook(__FILE__, 'socialproofy_cron_deactivate');
     
    463462
    464463    foreach ($order->get_items() as $item) {
    465         $product = $item->get_product();
     464        $product = wc_get_product($item->get_product_id());
    466465        $product_id = $item->get_product_id();
    467466        $item_name = $item->get_name();
     
    496495}
    497496
    498 function socialproofy_is_connected()
    499 {
    500     return get_option('socialproofy_connected');
    501 }
    502 
    503497function socialproofy_send_latest_orders()
    504498{
    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    }
    526520}
    527521
Note: See TracChangeset for help on using the changeset viewer.