Add to Cart button to Course Page

Home Forums Legacy Support Support queries How-to & Troubleshooting Add to Cart button to Course Page

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #372933
    uaffiliate
    Participant
    Hi, my problem is, that I cannot make an add to cart button action available on the course page, for a courses where I have associated products assigned to it. I saw the old thread here https://wplms.io/support/forums/topic/add-to-cart-and-buy-course-in-the-course-page/ and was trying to follow it exactly, but for some kind of reason I cannot make it work with that. Is the code maybe not anymore working because of recent WPLMS or Woocommerce updates, which makes the fetching not possible?
    #372934
    uaffiliate
    Participant
    Quick additional comment in case you want to know what happens for me, when I add the code you had pasted in the old thread, I am seeing first this when the page is loading https://prnt.sc/1we8lq9 and then after it has finished loading the usual text https://prnt.sc/1we8qi7 This is the code from the other thread: add_filter(‘wplms_course_details_widget’,function($course_details,$course_id){ $product = get_post_meta($course_id,’vibe_product’,true); if(!empty($product)){ echo ‘<div class=”course_add_to_cart”>’.do_shortcode(‘[add_to_cart id=”‘.$product.'”]’).'</div><style>.course_add_to_cart del,.course_add_to_cart ins{display:none}.course_add_to_cart p.product.woocommerce.add_to_cart_inline{display:grid;grid-template-columns:1fr;align-items:center;justify-items:center;}</style>’; } return $course_details; },10,2); My guess is that something has changed with the hooks/actions. Thanks in advance for the help.
    #372983
    Veronica
    Moderator
    add_filter('wplms_course_details_widget',function($course_details,$course_id){
    
    $product = get_post_meta($course_id,'vibe_product',true);
    
    if(!empty($product)){
    
    echo '<div class="course_add_to_cart">'.do_shortcode('[add_to_cart id="'.$product.'"]').'</div><style>.course_add_to_cart del,.course_add_to_cart ins{display:none}.course_add_to_cart p.product.woocommerce.add_to_cart_inline{display:grid;grid-template-columns:1fr;align-items:center;justify-items:center;}</style>';
    
    }
    
    return $course_details;
    
    },10,2);
    #372987
    uaffiliate
    Participant
    Hi, thanks a lot for the response. I added the new code, but it had no effect, it is still not visible for me. Does it work for you, when you add it to the wplms-customizer.php file? Thanks,
    #373083
    Veronica
    Moderator
    I have edited the above reply please try that
    #373117
    uaffiliate
    Participant
    Really sorry, but it still does not appear. Does it for you, when you add that code snippet? It had no effect at all, when I added replaced it (https://prnt.sc/1wrb10z) with your latest shared code snippet. I would be really curious, if it really works for you really. Thanks.
    #373172
    Veronica
    Moderator
    hi this course will work on v3, not on v4 need to review this code for v4 and then let you know
    #373268
    uaffiliate
    Participant
    Thank you very much, I was using v4, maybe this was the reason like you said. Keep me updated please, when you have news. Thanks in advance
    #373344
    Veronica
    Moderator
    ping me here tomorrow for the code
    #373369
    uaffiliate
    Participant
    will do so, thanks a lot. does this mean it will be ready tomorrow?
    #373426
    uaffiliate
    Participant
    Hi, do you have maybe any update on the code like you said yesterday, that I should ping you today?
    #373427
    Veronica
    Moderator
    add_action('wplms_4_the_course_button',function($course_details,$course_id){
    
    $product = get_post_meta($course_id,'vibe_product',true);
    
    if(!empty($product)){
    
    echo '<div class="course_add_to_cart">'.do_shortcode('[add_to_cart id="'.$product.'"]').'</div><style>.course_add_to_cart del,.course_add_to_cart ins{display:none}.course_add_to_cart p.product.woocommerce.add_to_cart_inline{display:grid;grid-template-columns:1fr;align-items:center;justify-items:center;}</style>';
    
    }
    
    return $course_details;
    
    },10,2);
    add this one
    #373879
    uaffiliate
    Participant
    hi, thanks for the code, but it did not work unfortunately. the course page's style/design has completely changed when adding the new custom code. Check here: https://prnt.sc/1xvauey Did this code work for you in the default v4 theme? Thanks
    #373919
    Veronica
    Moderator
    yes it needs little bit modification use this one:
    add_action('wplms_4_the_course_button',function($course_id){
    
    $product = get_post_meta($course_id,'vibe_product',true);
    if(!empty($product)){
    
    echo '<div class="course_add_to_cart">'.do_shortcode('[add_to_cart id="'.$product.'"]').'</div><style>.course_add_to_cart del,.course_add_to_cart ins{display:none}.course_add_to_cart p.product.woocommerce.add_to_cart_inline{display:grid;grid-template-columns:1fr;align-items:center;justify-items:center;}</style>';
    
    }
    
    return $course_details;
    
    },10,2);
    here it will look like on a single course page: http://prntscr.com/1y1pvif
    #374554
    uaffiliate
    Participant
    Thanks a lot, this one worked
Viewing 15 posts - 1 through 15 (of 16 total)
  • The topic ‘Add to Cart button to Course Page’ is closed to new replies.