LifterLMS 缩略图下方显示价格的方法(经验分享)

LifterLMS 缩略图下方显示价格的方法(经验分享)


标签: 

正在查看 2 个帖子:1-2 (共 2 个帖子)
  • 作者
    帖子
  • deathblood
    参与者
    • 文章数量: 2
    @deathblood
    楼主

    这个插件的官方实在是太恶心,这么基础的功能都不给加,花了钱也不给服务,死活给我推收费主题,我研究了一下,终于搞定了,这里放出来,希望对使用这个插件的人有用。

    wp-content/plugins/lifterlms/templates/loop下修改content.php

    在顶部添加代码:
    <?php

    global $course, $post;

    if ( empty( $course ) ) {
    $course = new LLMS_Course( get_the_ID() );
    }

    $llms_product = new LLMS_Product( get_the_ID() );
    $is_enrolled = llms_is_user_enrolled( get_current_user_id(), $llms_product->get( ‘id’ ) );
    $purchasable = $llms_product->is_purchasable();
    $has_free = $llms_product->has_free_access_plan();
    $free_only = ( $has_free && ! $purchasable );
    $user_id = empty( $user_id ) ? get_current_user_id() : $user_id;
    $lessons_ids = $course->get_lessons( get_the_ID());
    $number_of_lessons = count( $lessons_ids );
    $video = ”;
    $instructors = $course->get_instructors( true );
    $product_enrollment_date = ”;
    $product_expiry_date = ”;

    if ( $purchasable || $has_free ) {
    $plans = $llms_product->get_access_plans( $free_only );
    $min_price = 0;
    if ( count( $plans ) > 1 ) {
    $price_arr = array();

    $break = false;
    foreach ( $plans as $plan ) {
    $price_key = $plan->is_on_sale() ? ‘sale_price’ : ‘price’;
    $price = $plan->get_price( $price_key, array(), ‘float’ );
    $price_arr[] = $price;
    }
    if ( $break ) {
    $min_price = $price;
    } else {
    $minimum = max( $price_arr );

    $price = llms_price( $minimum, array() );
    $min_price = $price;
    $VIP = min( $price_arr );
    }

    }
    }
    ?>

    然后我们就可以引用了:
    <div >价格:<?php echo $min_price; ?></div>
    <div >VIP:<?php echo $VIP; ?></div>
    可以把这段放到
    do_action( ‘lifterlms_after_loop_item_title’ );
    的 ?> 后面效果不错,css自己搞

    我做了两个价格的显示,一般我们有常规价格和VIP价格

    其中$number_of_lessons为课程的课时数量,你也可以PHP内引用。

    deathblood
    参与者
    • 文章数量: 2
    @deathblood
    楼主

    这是我网站的效果

正在查看 2 个帖子:1-2 (共 2 个帖子)
  • 哎呀,回复话题必需登录。

未找到对应子版块?请直接在 [疑难杂症] 版块中发帖提问。

收藏纪念品


有奖活动

参与论坛社区问答,有机会获赠文派瓦普(Wapuu.com)手办模型。

话题信息

商业系统