Sale Learning Paths via woocommerce

Home Forums WPLMS AddOns Custom Learning Paths Sale Learning Paths via woocommerce

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #172063
    ICHARS
    Spectator
    Some time back I had requested for a feature to sale learning paths via woocommerce where if a user bought a particular product, they would automatically be enrolled to a learning path and all courses connected in the learning path. I was provided with a code
    
    // Sell CLP via woocoommerce
    
    class WPLMS_CLP_iChars{
    
        public static $instance;
        public static function init(){
    
            if ( is_null( self::$instance ) )
                self::$instance = new WPLMS_CLP_iChars();
            return self::$instance;
        }
    
        private function __construct(){
            add_filter('wplms_lp_metabox',array($this,'lp_metabox'));
            add_action('woocommerce_order_status_completed',array($this,'lp_approve_clp'),10,1);
        }
    
        function lp_metabox($args){
    
            if(is_array($args)){
    
                $query = new WP_Query(array(
                    'post_type'=>'product',
                    'posts_per_page'=>-1
                ));
                $vibe_ichars = get_post_meta(get_the_ID(),'vibe_ichars',true);
                $products = array(array('label'=>'none','value'=>''));
                if($query->have_posts()){
                    while($query->have_posts()){
                        $query->the_post();
                        $products[get_the_ID()]=array('label'=>get_the_title(),'value'=>get_the_ID());
                    }
                    wp_reset_postdata();
                }
                
                $args['vibe_ichars'] = array(                
                    'label' => __('SELECT PRODUCT BUNDLE','wplms-clp'), // <label>
                    'desc'  => __('select a product course bundle.','wplms-clp'), // description
                    'id'    => 'vibe_ichars', // field id and name
                    'type'  => 'multiselect', // type of field
                    'options' => $products,
                    'std'   => $vibe_ichars
                );    
            }
            
    
            return $args;
        }
    
        function lp_approve_clp($order_id){
    
            $order = new WC_Order( $order_id );
            $items = $order->get_items();
            $user_id=$order->get_user_id();
    
            foreach($items as $item_id=>$item){
    
                global $wpdb;
                $id = $wpdb->get_var("SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'vibe_ichars' AND meta_value = ".$item['product_id']);
                if(!empty($id)){
    
                    //Get all step ids connected to the learning path
                    $step_ids = wplms_clp_get_all_learningpath_step_ids($id);
                    if( !empty($step_ids)){
                        if(add_user_meta($user_id,'wplms_user_custom_learning_path',$id)){
                            foreach ($step_ids as $step_id) {
                                //check step completion
                                $points = apply_filters('wplms_clp_step_user_points_on_enroll',0,$id,$step_id,$user_id);
                                $steps[$step_id] = $points;
                            }
                            update_user_meta($user_id,'wplms_clp_points_'.$id,$steps);
                            do_action('wplms_clp_user_enrolled',$user_id,$id);
                        }  
                    }
                }
            }
        }
    }
    
    WPLMS_CLP_iChars::init();
    
    add_filter('wplms_clp_step_description_length',function($length){
      $length = 350;
      return $length;
    });
    
    After the update to the plugin this code is not working. I can see the Option "Product Bundle" on CLP page but but the dropdown to select the products is not present in front of the same. Kindly suggest...
    #172263
    Diana
    Participant
    @ICHARS, Apologies for the delayed response here... Okay, I will check this on your site. But for that, I need your admin credentials as well as site URL in a private reply here. Please also give me the access of the Plugins editor so, I can check the code of your customizer  
    #172302
    ICHARS
    Spectator
    This reply has been marked as private.
    #172383
    Diana
    Participant
    @ICHARS, can you please share your FTP credentials as well in a private reply to debug the code. P.S. Mark your reply as private
    #172493
    ICHARS
    Spectator
    This reply has been marked as private.
    #172634
    Diana
    Participant
    This reply has been marked as private.
    #172710
    ICHARS
    Spectator
    This reply has been marked as private.
    #172860
    Diana
    Participant
    @ICHARS, Thanks for sharing. Let me check..
    #173060
    ICHARS
    Spectator
    Any update on this, my upcoming workshops are getting affected
    #173187
    Diana
    Participant
    This reply has been marked as private.
    #173536
    ICHARS
    Spectator
    Hi any update on this?
    #173739
    Diana
    Participant
    This reply has been marked as private.
    #173841
    ICHARS
    Spectator
    Update on this issue?
    #173883
    Diana
    Participant
    This reply has been marked as private.
    #174076
    ICHARS
    Spectator
    Thank you. After the change it allows me to select a product but I need to be able to select multiple products. Users should be able to enroll into a CLP for Level 1 by purchasing a product which is either only a level 1 product or a level 1 to 3 product or a level 1 to 5 Product. The multi select option was working earlier for this but it stopped after the last update to clp plugin. Can you please suggest how do I bring back the multiselect functionality for product course bundle. I am also open to any other option that allows users to enroll for a CLP using one of the three products.
Viewing 15 posts - 1 through 15 (of 25 total)
  • The topic ‘Sale Learning Paths via woocommerce’ is closed to new replies.