Show multiple pricing for Course via WooCommerce

Multiple Course Pricing, you’ll be able to connect multiple products to a course and display course pricing in following format:

 

add_filter('wplms_course_product_metabox','wplms_course_product_metabox');
function wplms_course_product_metabox($metabox_settings){
    $metabox_settings['vibe_more_products'] = array(
        'label' => __('Associated Products','vibe-customtypes'), // <label>
        'desc'  => __('Associated Products with the Course.','vibe-customtypes'), // description
        'id'    => 'vibe_more_products', // field id and name
        'type'  => 'selectmulticpt', // type of field
        'post_type'=> 'product',
    );
    return $metabox_settings;
}

add_filter('wplms_course_credits_array','wplms_show_more_products',10,2);
function wplms_show_more_products($credits,$course_id){
    $more_products = get_post_meta($course_id,'vibe_more_products',true);
    if(!empty($more_products) && is_Array($more_products)){
        foreach($more_products as $product_id){
            if(isset($product_id) && $product_id !='' && function_exists('get_product')){ //WooCommerce installed
                $product = get_product( $product_id );
                if(is_object($product)){
                    $link =get_permalink($product_id);
                    $check=vibe_get_option('direct_checkout');
                    if(isset($check) && $check)
                        $link.='?redirect';
                    $price_html = str_replace('class="amount"','class="amount" itemprop="price"',$product->get_price_html());
                    $credits[$link] = '<strong itemprop="offers" itemscope itemtype="http://schema.org/Offer">'.$price_html.'</strong>';
                }
            }
        }
    }
    return $credits;
}

 

a. Edit the course in WP Admin.

b. Locate course product settings.

c. Connect more products.

d. Update the course.

This is very useful if you’re using Paid Memberships Pro and WooCommerce.

You can keep 1 checkout by installing the PMPRO – WooCommerce Add-on Plugin : https://wordpress.org/plugins/pmpro-woocommerce/

and connecting the WooCommerce product for the membership with the course.

Leave a Reply

Your email address will not be published. Required fields are marked *