Beispiel #1
0
 function add_to_cart($course_id)
 {
     $course = get_post($course_id);
     $price = learn_press_get_course_price($course_id);
     $quantity = 1;
     $_SESSION['learn_press_cart']['products'][$course_id] = array('id' => $course_id, 'quantity' => $quantity, 'price' => $price);
 }
Beispiel #2
0
<div>
	<?php 
do_action('learn_press_before_own_course_title');
the_title(sprintf('<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>');
do_action('learn_press_after_own_course_title');
do_action('learn_press_before_own_course_price');
printf('<p class="course-price">%s</p>', __('Price', 'learn_press'), learn_press_get_course_price(get_the_ID(), true));
do_action('learn_press_after_own_course_price');
do_action('learn_press_before_student_enrolled');
printf('<p class="student-enrolled">%s: %d</p>', __('Students enrolled', 'learn_press'), learn_press_count_students_enrolled(get_the_ID()));
do_action('learn_press_after_student_enrolled');
do_action('learn_press_before_student_passed');
printf('<p class="student-passed">%s: %d</p>', __('Students passed', 'learn_press'), learn_press_count_students_passed(get_the_ID()));
do_action('learn_press_after_student_passed');
?>
</div>
function learn_press_generate_transaction_object()
{
    $cart = learn_press_get_cart();
    if ($products = $cart->get_products()) {
        foreach ($products as $key => $product) {
            $products[$key]['product_base_price'] = floatval(learn_press_get_course_price($product['id']));
            $products[$key]['product_subtotal'] = floatval(learn_press_get_course_price($product['id']) * $product['quantity']);
            $products[$key]['product_name'] = get_the_title($product['id']);
            $products = apply_filters('learn_press_generate_transaction_object_products', $products, $key, $product);
        }
    }
    $transaction_object = new stdClass();
    $transaction_object->cart_id = $cart->get_cart_id();
    $transaction_object->total = round($cart->get_total(), 2);
    $transaction_object->sub_total = $cart->get_sub_total();
    $transaction_object->currency = learn_press_get_currency();
    $transaction_object->description = learn_press_get_cart_description();
    $transaction_object->products = $products;
    $transaction_object->coupons = '';
    $transaction_object->coupons_total_discount = '';
    $transaction_object = apply_filters('learn_press_generate_transaction_object', $transaction_object);
    return $transaction_object;
}
Beispiel #4
0
<?php

/**
 * Template for displaying the price of a course
 */
learn_press_prevent_access_directly();
if (learn_press_is_enrolled_course()) {
    return;
}
do_action('learn_press_before_course_price');
?>
<span class="course-price">
    <?php 
do_action('learn_press_begin_course_price');
?>
	<?php 
echo learn_press_get_course_price(null, true);
?>
    <?php 
do_action('learn_press_end_course_price');
?>
</span>
<?php 
do_action('learn_press_after_course_price');