Last active
February 21, 2021 21:57
-
-
Save noellesteegs/d71951e0bada8f89aa388a1f098cbd2d to your computer and use it in GitHub Desktop.
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
<?php | |
// Determines what to do - creates the function with your function name | |
function add_note_to_product() { | |
// Checks whether the product is in the Hoodies product category | |
if ( has_term('hoodies', 'product_cat' ) ) { | |
// Gets the note field | |
$note = get_field( 'note' ); | |
// Checks whether the field has text in it | |
if( $note ) { | |
// Outputs the text you entered in the backend | |
echo '<p class="my-product-note">' . $note . '</p>'; | |
} | |
} | |
} | |
// Determines where to do it - the first part is the hook, the second your function name | |
add_action( 'woocommerce_after_add_to_cart_button', 'add_note_to_product' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment