Last active
April 11, 2020 21:02
WooCommerce add notices for when backorders are (not) allowed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//output with add to cart button on product detail page | |
add_action( 'woocommerce_after_add_to_cart_form', 'custom_notice_for_backorders_allowed' ); | |
function custom_notice_for_backorders_allowed() | |
{ | |
//instantinate product object | |
global $product; | |
//check if backorders are allowed | |
if ( $product->backorders_allowed() ) | |
{ | |
?> | |
Backorders allowed: Put some text and <a href="#">links here.</a> | |
<?php | |
} | |
} | |
//output after product title | |
add_action( 'woocommerce_single_product_summary', 'custom_notice_for_backorders_not_allowed' ); | |
function custom_notice_for_backorders_not_allowed() | |
{ | |
global $product; | |
//check if backorders are not allowed | |
if ( ! $product->backorders_allowed() ) | |
{ | |
?> | |
Backorders not allowed: Put some text and <a href="#">links here.</a> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment