Home › Forums › Legacy Support › Support queries › How-to & Troubleshooting › Skip product and cart hook
Tagged: Skip product
- This topic has 10 replies, 2 voices, and was last updated 3 years, 11 months ago by Diana.
Viewing 11 posts - 1 through 11 (of 11 total)
-
AuthorPosts
-
May 23, 2020 at 6:28 pm #262245StudioLeBusParticipantHello! Is there a way to have a hook for the skip woocommerce product and cart option ? I would like to put something like:that for instance If (product category == 000) {don't skip!!} Or maybe you can tell me which file to change in the core file to implement that?? Tell me it's possible pleeeaaasssee !! :) :) Thanks in advance... DanMay 25, 2020 at 4:29 am #262386DianaParticipant@StudioLeBus, But we have a setting for this, in wp-admin > WPLMS > Miscellaneous > http://prntscr.com/sn5rgvMay 25, 2020 at 4:32 am #262387StudioLeBusParticipantHello thanks for your answer but I want to filter this for a category of products or some products Id... This is my question :) So is there a hook I could put a condition for the redirect? Or I could edit a file?? Thanks in advanceMay 25, 2020 at 4:34 am #262389StudioLeBusParticipantIt's to have a name your price option only for some courses.. And this plug-in appears only on the corresponding productMay 26, 2020 at 7:57 am #262818DianaParticipant@StudioLeBus, Okay, So I can try custom Code on your site just share the product URL for which you want redirection So, I can check whether the code is working or not directly on your siteMay 26, 2020 at 7:59 am #262819StudioLeBusParticipantHello Diano thanks for your answer.. well I don't have one product only, but I thought I could create a category let's say with the name :"nameyourprice" for products, and if it is in it the system doesn't skip, it goes normally on the product... :) :) It would be awesommmmmmeee !!! hope it's possible !! :) ThanksMay 27, 2020 at 11:57 am #263236DianaParticipantThis reply has been marked as private.May 27, 2020 at 7:23 pm #263422StudioLeBusParticipantHellooo woaaww thanks very much I think we're close ! the problem is that I want to direct to the product (if he got 'nameyourpric' categorie and not go to the checkout... so I did:
but it loops and I get a ERR_TOO_MANY_REDIRECTS page... I guess because this fonction is in the product page ? What's the solution ? so just to be clear I would like : When clicking on take the course: if product is in category: "nameyourprice" : Don't redirect directly to checkout if not: redirect directly to checkout as normal... hope it's possible thanks again ! :)if ($value->slug == 'nameyourprice') { $lurl = get_permalink($post->ID); wp_redirect($lurl); // my custom page exit(); }
May 28, 2020 at 11:08 am #263680DianaParticipantThis reply has been marked as private.May 28, 2020 at 11:37 am #263707StudioLeBusParticipantHello !! Ok I did it ! I disabled the direct checkout option and changes the code to: add_action('template_redirect', 'show_products_woocommerce'); function show_products_woocommerce() { global $post; if ($post->post_type == 'product') { $product_categories = get_the_terms( $post->ID, 'product_cat' ); foreach ($product_categories as $key => $value) { if ($value->slug == 'nameyourprice' or $value->slug == 'nameyourprice-fr' ) { $donotredirect = true; } } if ($donotredirect!=true) { global $woocommerce; $woocommerce->cart->add_to_cart( $post->ID ); $checkout_url = $woocommerce->cart->get_checkout_url(); wp_redirect($checkout_url); // my custom page exit(); } } } Maybe my code could be optimised a little bit more but now it's working good!!! :) :) Thanks !May 29, 2020 at 6:40 am #263961DianaParticipantThis reply has been marked as private. -
AuthorPosts
Viewing 11 posts - 1 through 11 (of 11 total)
- The topic ‘Skip product and cart hook’ is closed to new replies.