Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Add to Cart button to Course Page
Tagged: add to cart, course page enhancement
- This topic has 15 replies, 2 voices, and was last updated 3 years, 1 month ago by Veronica.
-
AuthorPosts
-
October 16, 2021 at 4:22 pm #372933uaffiliateParticipantHi, 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?October 16, 2021 at 4:25 pm #372934uaffiliateParticipantQuick 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.October 18, 2021 at 12:14 pm #372983VeronicaModerator
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);
October 18, 2021 at 12:26 pm #372987uaffiliateParticipantHi, 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,October 19, 2021 at 10:20 am #373083VeronicaModeratorI have edited the above reply please try thatOctober 19, 2021 at 7:45 pm #373117uaffiliateParticipantReally 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.October 20, 2021 at 12:32 pm #373172VeronicaModeratorhi this course will work on v3, not on v4 need to review this code for v4 and then let you knowOctober 21, 2021 at 12:30 pm #373268uaffiliateParticipantThank 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 advanceOctober 22, 2021 at 12:02 pm #373344VeronicaModeratorping me here tomorrow for the codeOctober 22, 2021 at 2:23 pm #373369uaffiliateParticipantwill do so, thanks a lot. does this mean it will be ready tomorrow?October 23, 2021 at 1:03 pm #373426uaffiliateParticipantHi, do you have maybe any update on the code like you said yesterday, that I should ping you today?October 23, 2021 at 1:25 pm #373427VeronicaModerator
add this oneadd_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);
October 30, 2021 at 8:11 pm #373879uaffiliateParticipanthi, 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? ThanksNovember 1, 2021 at 10:35 am #373919VeronicaModeratoryes it needs little bit modification use this one:
here it will look like on a single course page: http://prntscr.com/1y1pvifadd_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);
November 13, 2021 at 10:25 am #374554uaffiliateParticipantThanks a lot, this one worked -
AuthorPosts
- The topic ‘Add to Cart button to Course Page’ is closed to new replies.