/**
 * Function to return the vars for adding new order for iT Exchange, ID integration
 */
function iditexch_payment_vars($transaction_id, $product_id, $price, $count)
{
    // Getting post for date and status
    $post = get_post($transaction_id);
    if (isset($post)) {
        $date = $post->post_date;
        $is_paid = it_exchange_transaction_is_cleared_for_delivery(new IT_Exchange_Transaction($post));
        if ($is_paid) {
            $status = 'C';
        } else {
            $status = strtoupper(substr($post->post_status, 0, 1));
        }
    }
    // else {
    // 	$status = 'P';
    // }
    // Getting the shipping of transaction
    $transaction = get_post($transaction_id);
    $shipping_method = it_exchange_get_transaction_shipping_method($transaction);
    // If we are not getting the shipping method, get user details from his id
    if (empty($shipping_method)) {
        // Getting transaction customer
        $customer = it_exchange_get_transaction_customer($transaction);
        // $user_id = get_post_meta($transaction_id, '_it_exchange_customer_id', true);
        // $user_info = get_userdata($user_id);
        $first_name = $customer->wp_user->first_name;
        $last_name = $customer->wp_user->last_name;
        $email = $customer->wp_user->user_email;
    } else {
        $first_name = $shipping_method['first-name'];
        $last_name = $shipping_method['last-name'];
        $email = $shipping_method['email'];
    }
    // Getting the level and ID project id from iT exchange product_id
    list($project_id, $level) = get_paired_level_from_itexch_product($product_id);
    $vars = array('id' => null, 'first_name' => $first_name, 'last_name' => $last_name, 'email' => $email, 'address' => '', 'state' => '', 'city' => '', 'zip' => '', 'country' => '', 'product_id' => $project_id, 'transaction_id' => $transaction_id . '-v' . $level . '-' . $count, 'preapproval_key' => '', 'product_level' => $level, 'prod_price' => $price, 'status' => $status, 'created_at' => $date);
    return $vars;
}
コード例 #2
0
ファイル: class-exchange.php プロジェクト: nerrad/AffiliateWP
 public function mark_referral_complete($transaction, $old_status, $old_status_cleared, $new_status)
 {
     $new_status = it_exchange_get_transaction_status($transaction->ID);
     $new_status_cleared = it_exchange_transaction_is_cleared_for_delivery($transaction->ID);
     if ($new_status != $old_status && !$old_status_cleared && $new_status_cleared) {
         $this->complete_referral($transaction->ID);
     }
 }
コード例 #3
0
/**
 * Disable a key when a transaction's status changes.
 *
 * @internal
 *
 * @since 1.0
 *
 * @param \IT_Exchange_Transaction $txn
 * @param string                   $old_status
 * @param bool                     $old_status_cleared
 */
function disable_key_on_transaction_status_change($txn, $old_status, $old_status_cleared)
{
    $txn = it_exchange_get_transaction($txn);
    if ($old_status_cleared && !it_exchange_transaction_is_cleared_for_delivery($txn)) {
        $keys = itelic_get_keys(array('transaction' => $txn->ID));
        foreach ($keys as $key) {
            $key->set_status(Key::DISABLED);
        }
    }
}