function get_request_url($order_id)
 {
     $user = learn_press_get_current_user();
     $nonce = wp_create_nonce('learn-press-paypal-nonce');
     $order = LP_Order::instance($order_id);
     $custom = array('order_id' => $order_id, 'order_key' => $order->order_key);
     $query = array('cmd' => '_xclick', 'amount' => learn_press_get_cart_total(), 'quantity' => '1', 'business' => $this->paypal_email, 'item_name' => learn_press_get_cart_description(), 'return' => add_query_arg(array('learn-press-transaction-method' => 'paypal-standard', 'paypal-nonce' => $nonce), learn_press_get_cart_course_url()), 'currency_code' => learn_press_get_currency(), 'notify_url' => get_site_url() . '/?' . learn_press_get_web_hook('paypal-standard') . '=1', 'no_note' => '1', 'shipping' => '0', 'email' => $user->user_email, 'rm' => '2', 'cancel_return' => learn_press_get_cart_course_url(), 'custom' => json_encode($custom), 'no_shipping' => '1');
     $query = apply_filters('learn_press_paypal_standard_query', $query);
     $paypal_payment_url = $this->paypal_url . '?' . http_build_query($query);
     return $paypal_payment_url;
 }
function learn_press_send_user_email_order($status, $order_id)
{
    return;
    $status = strtolower($status);
    if ('completed' == $status) {
        $order = new LP_Order($order_id);
        $mail_to = $order->get_user('email');
        $instructors = array();
        $course_title = '';
        $transaction_object = $order->get_items();
        $items = $transaction_object->products;
        $item = array_shift($items);
        $course = get_post($item['id']);
        $course_title = get_the_title($item['id']);
        $instructor = LP_User::get_user($course->post_author);
        $instructors[$instructor->ID] = $instructor->data->display_name;
        learn_press_send_mail($mail_to, 'enrolled_course', apply_filters('learn_press_vars_enrolled_course', array('user_name' => $order->get_user('display_name'), 'course_name' => $course_title, 'course_link' => get_permalink($item['id'])), $course, $instructor));
    }
}
/**
 * get confirm order URL
 *
 * @param int $order_id
 *
 * @return string
 */
function learn_press_get_order_confirm_url($order_id = 0)
{
    $url = '';
    if (($confirm_page_id = learn_press_get_page_id('taken_course_confirm')) && get_post($confirm_page_id)) {
        $url = get_permalink($confirm_page_id);
        if ($order_id) {
            $url = join(preg_match('!\\?!', $url) ? '&' : '?', array($url, "order_id={$order_id}"));
        }
    } else {
        $order = new LP_Order($order_id);
        if (($items = $order->get_items()) && !empty($items->products)) {
            $course = reset($items->products);
            $url = get_permalink($course['id']);
        } else {
            $url = get_site_url();
        }
    }
    return $url;
}
 function get_request_url($order_id)
 {
     $order = LP_Order::instance($order_id);
     $query = $this->get_paypal_args($order);
     $paypal_payment_url = $this->paypal_url . '?' . http_build_query($query);
     return $paypal_payment_url;
 }
/**
 * Update Order status
 *
 * @param $order_id int Order ID
 * @param $status   int Order status. -1: cancel,0:on-hold 1: pending, 2: completed, -2: refund
 *
 * @return bool
 */
function learn_press_update_order_status($order_id, $status = '')
{
    $order = LP_Order::instance($order_id);
    if ($order) {
        $order->update_status($status);
    }
    return;
    if ($status) {
        /*wp_update_post(
        			array( 'ID' => $order_id, 'post_status' => 'publish' )
        		);*/
        $current_status = get_post_status($order_id);
        if ($current_status != $status) {
            if (update_post_meta($order_id, '_learn_press_transaction_status', $status)) {
                do_action('learn_press_update_order_status', $status, $order_id);
                return true;
            } else {
                return false;
            }
        }
    }
    return false;
}
Exemple #6
0
 static function order_actions($post)
 {
     learn_press_admin_view('meta-boxes/order/actions.php', array('order' => LP_Order::instance($post)));
 }
 /**
  * Get the order that contains the course
  *
  * @param int
  * @param string type of order to return LP_Order|ID
  *
  * @return int
  */
 function get_course_order($course_id, $return = '')
 {
     global $wpdb;
     $query = $wpdb->prepare("\n\t\t\tSELECT order_id\n\t\t\tFROM {$wpdb->posts} o\n\t\t\tINNER JOIN {$wpdb->postmeta} om ON om.post_id = o.ID AND om.meta_key = %s AND om.meta_value = %d\n\t\t\tINNER JOIN {$wpdb->learnpress_order_items} oi ON o.ID = oi.order_ID\n\t\t\tINNER JOIN {$wpdb->learnpress_order_itemmeta} oim ON oim.learnpress_order_item_id= oi.order_item_id AND oim.meta_key = %s AND oim.meta_value = %d\n\t\t\tORDER BY order_id DESC\n\t\t", '_user_id', $this->id, '_course_id', $course_id);
     $order_id = $wpdb->get_var($query);
     if ($order_id && $return == 'object') {
         $order = LP_Order::instance($order_id);
     } else {
         $order = $order_id;
     }
     $this->_parse_item_order_of_course($course_id);
     return $order;
 }
Exemple #8
0
 static function order_details($post)
 {
     learn_press_admin_view('meta-boxes/order/details.php', array('order' => LP_Order::instance($post)));
     LP_Assets::enqueue_script('learn-press-order', LP()->plugin_url('assets/js/admin/order.js'), array('backbone', 'wp-util'));
 }