Skip product and cart hook

Home Forums Legacy Support Support queries How-to & Troubleshooting Skip product and cart hook

Tagged: 

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #262245
    StudioLeBus
    Participant
    Hello! 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... Dan
    #262386
    Diana
    Participant
    @StudioLeBus, But we have a setting for this, in wp-admin > WPLMS > Miscellaneous > http://prntscr.com/sn5rgv
    #262387
    StudioLeBus
    Participant
    Hello 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 advance
    #262389
    StudioLeBus
    Participant
    It's to have a name your price option only for some courses.. And this plug-in appears only on the corresponding product
    #262818
    Diana
    Participant
    @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 site
    #262819
    StudioLeBus
    Participant
    Hello 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 !! :) Thanks
    #263236
    Diana
    Participant
    This reply has been marked as private.
    #263422
    StudioLeBus
    Participant
    Hellooo 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:
            if ($value->slug == 'nameyourprice')
            {
                $lurl = get_permalink($post->ID);
                wp_redirect($lurl); // my custom page
                exit();
    
            }
    
    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 ! :)
    #263680
    Diana
    Participant
    This reply has been marked as private.
    #263707
    StudioLeBus
    Participant
    Hello !! 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 !
    #263961
    Diana
    Participant
    This reply has been marked as private.
Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Skip product and cart hook’ is closed to new replies.