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 get order information
 *
 * @param int $order_id
 *
 * @return LP_Order object instance
 */
function learn_press_get_order($the_order)
{
    if (!$the_order) {
        return false;
    }
    global $post;
    if (false === $the_order) {
        $the_order = $post;
    } elseif (is_numeric($the_order)) {
        $the_order = get_post($the_order);
    } elseif ($the_order instanceof LP_Order) {
        $the_order = get_post($the_order->id);
    }
    if (!$the_order || !is_object($the_order)) {
        return false;
    }
    return LP_Order::instance($the_order);
}
 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;
 }
Пример #4
0
/**
 * 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;
}
Пример #5
0
 static function order_actions($post)
 {
     learn_press_admin_view('meta-boxes/order/actions.php', array('order' => LP_Order::instance($post)));
 }
Пример #6
0
 /**
  * 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;
 }
Пример #7
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'));
 }