Example #1
0
 function get_sub_total()
 {
     $sub_total = 0;
     $products = $this->get_products();
     if ($products) {
         foreach ($products as $product) {
             $sub_total += learn_press_is_free_course($product['id']) ? 0 : floatval(learn_press_get_course_price($product['id']));
         }
     }
     learn_press_format_price($sub_total);
     return apply_filters('learn_press_get_cart_subtotal', $sub_total, $this->get_cart_id());
 }
Example #2
0
echo $item['id'];
?>
" data-remove_nonce="<?php 
echo wp_create_nonce('remove_order_item');
?>
">
	<td>
		<a href="" class="remove-order-item">&times;</a>
		<a href="<?php 
echo get_the_permalink($item['course_id']);
?>
"><?php 
echo $item['name'];
?>
</a>
	</td>
	<td>
		<?php 
echo learn_press_format_price($item['total'], $currency_symbol);
?>
	</td>
	<td><?php 
echo $item['quantity'];
?>
</td>
	<td class="align-right"><?php 
echo learn_press_format_price($item['total'], $currency_symbol);
?>
</td>
</tr>
 /**
  * Get the price of course with html
  *
  * @return mixed
  */
 public function get_price_html()
 {
     if ($this->is_free()) {
         $price_html = apply_filters('learn_press_course_price_html_free', __('Free', 'learn_press'), $this);
     } else {
         $price = $this->get_price();
         $price = learn_press_format_price($price, true);
         $price_html = apply_filters('learn_press_course_price_html', $price, $this);
     }
     return $price_html;
 }
/**
 * Get the price of a course
 *
 * @author  Tunn
 * @param   null $course_id
 * @return  int
 */
function learn_press_get_course_price($course_id = null, $with_currency = false)
{
    if (!$course_id) {
        global $course;
        $course_id = $course ? $course->ID : 0;
    }
    if (!learn_press_is_free_course($course_id)) {
        $price = floatval(get_post_meta($course_id, '_lpr_course_price', true));
        if ($with_currency) {
            $price = learn_press_format_price($price, true);
        }
    } else {
        $price = 0;
    }
    return apply_filters('learn_press_get_course_price', $price, $course_id);
}
Example #5
0
					<span class="order-subtotal">
						<?php 
echo learn_press_format_price($order->order_subtotal, $currency_symbol);
?>
					</span>
				</td>
			</tr>
			<tr>
				<td class="align-right" colspan="3"><?php 
_e('Total', 'learn_press');
?>
</td>
				<td class="align-right total">
					<span class="order-total">
						<?php 
echo learn_press_format_price($order->order_total, $currency_symbol);
?>
					</span>
				</td>
			</tr>
			<tr>
				<td class="align-right" colspan="4">
					<button class="button" type="button" id="learn-press-add-order-item"><?php 
_e('Add Item', 'learn_press');
?>
</button>
					<!--<button class="button" type="button" id="learn-press-calculate-order-total"><?php 
_e('Calculate Total', 'learn_press');
?>
</button>-->
				</td>
Example #6
0
 function get_formatted_order_total()
 {
     $currency_symbol = learn_press_get_currency_symbol($this->order_currency);
     return learn_press_format_price($this->order_total, $currency_symbol);
 }
Example #7
0
 function get_item_subtotal($course, $quantity = 1)
 {
     $price = $course->get_price();
     $row_price = $price * $quantity;
     $course_subtotal = learn_press_format_price($row_price, true);
     return apply_filters('learn_press_cart_item_subtotal', $course_subtotal, $course, $quantity, $this);
 }
Example #8
0
        function order_details($post)
        {
            $user = learn_press_get_user(get_post_meta($post->ID, '_learn_press_customer_id', true));
            $order_items = learn_press_get_order_items($post->ID);
            $status = strtolower(get_post_meta($post->ID, '_learn_press_transaction_status', true));
            if ($status && !in_array($status, array('completed', 'pending'))) {
                $status = 'Pending';
            }
            $currency_symbol = learn_press_get_currency_symbol($order_items->currency);
            ?>
            <div class="order-details">
                <div class="order-data">
                    <div class="order-data-number"><?php 
            echo learn_press_transaction_order_number($post->ID);
            ?>
</div>
                    <div
                        class="order-data-date"><?php 
            echo learn_press_transaction_order_date($post->post_date);
            ?>
</div>
                    <div class="order-data-status <?php 
            echo sanitize_title($status);
            ?>
"><?php 
            echo $status;
            ?>
</div>
                    <div
                        class="order-data-payment-method"><?php 
            echo learn_press_payment_method_from_slug($post->ID);
            ?>
</div>
                </div>
                <div class="order-user-data clearfix">
                    <div class="order-user-avatar">
                        <?php 
            echo get_avatar($user->ID, 120);
            ?>
                    </div>
                    <div class="order-user-meta">
                        <h2 class="user-display-name">
                            <?php 
            echo empty($user->display_name) ? __('Unknown', 'learn_press') : $user->display_name;
            ?>
                        </h2>

                        <div class="user-email">
                            <?php 
            echo empty($user->user_email) ? __('Unknown', 'learn_press') : $user->user_email;
            ?>
                        </div>
                        <div class="user-ip-address">
                            <?php 
            echo get_post_meta($post->ID, '_learn_press_customer_ip', true);
            ?>
                        </div>
                    </div>
                </div>
                <div class="order-products">
                    <table>
                        <thead>
                        <tr>
                            <th colspan="2"><?php 
            _e('Courses', 'learn_press');
            ?>
</th>
                            <th class="align-right"><?php 
            _e('Amount', 'learn_press');
            ?>
</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php 
            if ($products = learn_press_get_transition_products($post->ID)) {
                foreach ($products as $pro) {
                    ?>
                            <tr>
                                <td colspan="2">
                                    <a href="<?php 
                    the_permalink($pro->ID);
                    ?>
"><?php 
                    echo get_the_title($pro->ID);
                    ?>
</a>
                                </td>
                                <td class="align-right"><?php 
                    echo $pro->amount ? learn_press_format_price($pro->amount, $currency_symbol) : __('Free!', 'learn_press');
                    ?>
</td>
                            </tr>
                        <?php 
                }
            }
            ?>
                        </tbody>
                        <tfoot>
                        <tr>
                            <td></td>
                            <td width="300" class="align-right"><?php 
            _e('Sub Total', 'learn_press');
            ?>
</td>
                            <td width="100"
                                class="align-right"><?php 
            echo learn_press_format_price($order_items->sub_total, $currency_symbol);
            ?>
</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="align-right"><?php 
            _e('Total', 'learn_press');
            ?>
</td>
                            <td class="align-right total"><?php 
            echo learn_press_format_price($order_items->total, $currency_symbol);
            ?>
</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="align-right" colspan="2">
                                <?php 
            _e('Status', 'learn_press');
            ?>
                                <select name="learn_press_order_status">
                                    <?php 
            foreach (learn_press_get_order_statuses() as $status => $label) {
                ?>
                                    <option value="<?php 
                echo $status;
                ?>
" <?php 
                selected($status == get_post_status($post->ID) ? 1 : 0, 1);
                ?>
><?php 
                echo $label;
                ?>
</option>
                                    <?php 
            }
            ?>
                                </select>
                                <button id="update-order-status" class="button button-primary" type="button"><?php 
            _e('Apply', 'learn_press');
            ?>
</button>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        <?php 
        }
Example #9
0
        ?>
&nbsp;
						<?php 
        echo apply_filters('learn_press_cart_item_remove_link', sprintf('<a href="%s" class="remove" title="%s" data-course_id="%s">%s</a>', esc_url(add_query_arg('remove-cart-item', $_course_id)), __('Remove this course', 'learn_press'), esc_attr($_course_id), __('Remove', 'learn_press')), $cart_item);
        ?>
					</td>

					<td class="course-price">
						<?php 
        echo learn_press_format_price(apply_filters('learn_press_cart_item_price', $_course->price, $cart_item), true);
        ?>
					</td>

					<td class="course-total">
						<?php 
        echo learn_press_format_price(apply_filters('learn_press_cart_item_subtotal', $cart_item['subtotal'], $cart_item), true);
        ?>
					</td>
				</tr>
				<?php 
    }
}
do_action('learn_press_cart_contents');
?>
		<tr>
			<td colspan="3"><?php 
_e('Subtotal', 'learn_press');
?>
</td>
			<td><?php 
echo $cart->get_subtotal();
Example #10
0
 function get_formatted_order_total()
 {
     $order_items = learn_press_get_order_items($this->post->ID);
     $currency_symbol = learn_press_get_currency_symbol($order_items->currency);
     return learn_press_format_price($order_items->sub_total, $currency_symbol);
 }
Example #11
0
        /**
         * Render column data
         *
         */
        function columns_content($column)
        {
            global $post;
            $the_order = learn_press_get_order($post->ID);
            //print_r($the_order->get_items());die();
            switch ($column) {
                case 'order_student':
                    if ($the_order->user_id) {
                        $user = learn_press_get_user($the_order->user_id);
                        printf('<a href="user-edit.php?user_id=%d">%s (%s)</a>', $the_order->user_id, $user->user_login, $user->display_name);
                        printf('<br /><span>%s</span>', $user->user_email);
                    } else {
                        _e('Guest', 'learn_press');
                    }
                    break;
                case 'order_status':
                    echo learn_press_get_order_status_label($post->ID);
                    break;
                case 'order_date':
                    $t_time = get_the_time('Y/m/d g:i:s a');
                    $m_time = $post->post_date;
                    $time = get_post_time('G', true, $post);
                    $time_diff = current_time('timestamp') - $time;
                    if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
                        $h_time = sprintf(__('%s ago', 'learn_press'), human_time_diff($time));
                    } else {
                        $h_time = mysql2date('Y/m/d', $m_time);
                    }
                    echo '<abbr title="' . esc_attr($t_time) . '">' . esc_html(apply_filters('learn_press_order_column_time', $h_time, $the_order)) . '</abbr>';
                    break;
                case 'order_items':
                    $links = array();
                    foreach ($the_order->get_items() as $item) {
                        $links[] = '<a href="' . get_the_permalink($item['course_id']) . '">' . get_the_title($item['course_id']) . '</a>';
                    }
                    echo join("<br />", $links);
                    break;
                case 'order_total':
                    echo learn_press_format_price($the_order->order_total, learn_press_get_currency_symbol($the_order->order_currency));
                    break;
                case 'order_title':
                    $order_number = sprintf("%'.010d", $the_order->ID);
                    ?>
					<div class="tips">
						<a href="post.php?post=<?php 
                    echo $the_order->ID;
                    ?>
&action=edit"><strong><?php 
                    echo learn_press_transaction_order_number($order_number);
                    ?>
</strong></a>

					</div>
					<?php 
                    break;
            }
        }
Example #12
0
    <tfoot>

        <tr>
            <th scope="row"><?php 
_e('Subtotal', 'learn_press');
?>
</th>
            <td><?php 
echo learn_press_format_price($order_items->sub_total, $currency_symbol);
?>
</td>
        </tr>
        <tr>
            <th scope="row"><?php 
_e('Total', 'learn_press');
?>
</th>
            <td><?php 
echo learn_press_format_price($order_items->total, $currency_symbol);
?>
</td>
        </tr>
    </tfoot>
</table>

<?php 
do_action('learn_press_order_details_after_order_table', $order);
?>

<div class="clear"></div>
 /**
  * Add new course to order
  */
 static function add_item_to_order()
 {
     // ensure that user has permission
     if (!current_user_can('edit_lp_orders')) {
         die(__('Permission denied', 'learn_press'));
     }
     // verify nonce
     $nonce = learn_press_get_request('nonce');
     if (!wp_verify_nonce($nonce, 'add_item_to_order')) {
         die(__('Check nonce failed', 'learn_press'));
     }
     // validate order
     $order_id = learn_press_get_request('order_id');
     if (!is_numeric($order_id) || get_post_type($order_id) != 'lp_order') {
         die(__('Order invalid', 'learn_press'));
     }
     // validate item
     $item_id = learn_press_get_request('item_id');
     $post = get_post($item_id);
     if (!$post || 'lp_course' !== $post->post_type) {
         die(__('Course invalid', 'learn_press'));
     }
     $course = learn_press_get_course($post->ID);
     $order = learn_press_get_order($order_id);
     $item = array('course_id' => $course->id, 'name' => $course->get_title(), 'quantity' => 1, 'subtotal' => $course->get_price(), 'total' => $course->get_price());
     // Add item
     $item_id = learn_press_add_order_item($order_id, array('order_item_name' => $item['name']));
     $item['id'] = $item_id;
     // Add item meta
     if ($item_id) {
         $item = apply_filters('learn_press_ajax_order_item', $item);
         learn_press_add_order_item_meta($item_id, '_course_id', $item['course_id']);
         learn_press_add_order_item_meta($item_id, '_quantity', $item['quantity']);
         learn_press_add_order_item_meta($item_id, '_subtotal', $item['subtotal']);
         learn_press_add_order_item_meta($item_id, '_total', $item['total']);
         do_action('learn_press_ajax_add_order_item_meta', $item);
     }
     $order_data = learn_press_update_order_items($order_id);
     $currency_symbol = learn_press_get_currency_symbol($order_data['currency']);
     $order_data['subtotal_html'] = learn_press_format_price($order_data['subtotal'], $currency_symbol);
     $order_data['total_html'] = learn_press_format_price($order_data['total'], $currency_symbol);
     ob_start();
     include learn_press_get_admin_view('meta-boxes/order/order-item.php');
     $item_html = ob_get_clean();
     learn_press_send_json(array('result' => 'success', 'item_html' => $item_html, 'order_data' => $order_data));
 }
Example #14
0
 /**
  * Print content for custom column
  *
  * @param $column
  */
 function columns_content($column)
 {
     global $post;
     switch ($column) {
         case 'sections':
             $course = LP_Course::get_course($post->ID);
             $sections = $course->get_curriculum();
             if ($sections) {
                 $items = $course->get_curriculum_items(array('group' => true));
                 $count_sections = sizeof($sections);
                 $count_lessons = sizeof($items['lessons']);
                 $count_quizzes = sizeof($items['quizzes']);
                 $output = sprintf(_nx('%d section', '%d sections', $count_sections, 'learn_press'), $count_sections);
                 $output .= ' (';
                 if ($count_lessons) {
                     $output .= sprintf(_nx('%d lesson', '%d lessons', $count_lessons, 'learn_press'), $count_lessons);
                 } else {
                     $output .= __("0 lesson", 'learn_press');
                 }
                 $output .= ', ';
                 if ($count_quizzes) {
                     $output .= sprintf(_nx('%d quiz', '%d quizzes', $count_quizzes, 'learn_press'), $count_quizzes);
                 } else {
                     $output .= __("0 quiz", 'learn_press');
                 }
                 $output .= ')';
                 echo $output;
             } else {
                 _e('No content', 'learn_press');
             }
             break;
         case 'price':
             $price = get_post_meta($post->ID, '_lp_price', true);
             echo $price ? learn_press_format_price(get_post_meta($post->ID, '_lp_price', true), true) : __('Free', 'learn_press');
     }
 }
Example #15
0
    foreach ($items as $item_id => $item) {
        //$_course  = apply_filters( 'learn_press_order_item_course', get_post( $item_id ), $item );
        if (apply_filters('learn_press_order_item_visible', true, $item)) {
            ?>
				<tr class="<?php 
            echo esc_attr(apply_filters('learn_press_order_item_class', 'order_item', $item, $order));
            ?>
">
					<td class="course-name">
						<?php 
            echo apply_filters('learn_press_order_item_name', sprintf('<a href="%s">%s</a>', get_permalink($item['course_id']), $item['name']), $item);
            ?>
					</td>
					<td class="product-total">
						<?php 
            echo !empty($item['total']) ? learn_press_format_price($item['total'], $currency_symbol) : __('Free!', 'learn_press');
            ?>
					</td>
				</tr>
				<?php 
        }
    }
}
do_action('learn_press_order_items_table', $order);
?>
	</tbody>
	<tfoot>

	<tr>
		<th scope="row"><?php 
_e('Subtotal', 'learn_press');