brundea
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [WooCommerce] Check if a product variation allows backorderHi @pxwm
Yes! I know this is possible. Maybe I haven’t explained myself correctly. What I want to know is how to check if a selected variation allows for backorder or not (in code). If yes, then execute a piece of code. If not, do nothing.
Why do I want to do this? Because I don’t want to use the default backorder system that WooCommerce provides. I want to change the “Add to cart” button for a “Backorder product” button, which will direct you to a form that you fill and send an e-mail asking for reservation of that product. This part isn’t important, since I know how to code that.
The ‘perfect code’ I’m looking for would be something like this:
add_action( 'woocommerce_after_add_to_cart_form', 'edit_backorders_allowed' ); function edit_backorders_allowed() { global $variation; //IF VARIATION ALLOWS BACKORDER, EXECUTE CODE if ( $variation->backorders_allowed() ) { ?> <style type="text/css"> .single_add_to_cart_button { display: none !important; } .quantity { display: none !important; } </style> <button id="reservar" type="submit" class="button alt">Reservar producto</button> <?php } } ?>Thank you!
Viewing 1 replies (of 1 total)