Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Garconis/6136ef05f45bf46428e3bcdc99443110 to your computer and use it in GitHub Desktop.
Save Garconis/6136ef05f45bf46428e3bcdc99443110 to your computer and use it in GitHub Desktop.
WooCommerce | Add custom text to a particular product ID variation area
<?php
//hook our function to the product variation
add_action( 'woocommerce_single_variation', 'fs_custom_variation_text', 18 );
function fs_custom_variation_text() {
global $product;
// checking if the product is the correct product id
if ($product->id === 454) {
// custom text
echo '<div class="product-addon"><h3 class="addon-name">Your Custom Title</h2>
<div class="addon-description"><p>Add whatever text or HTML that you want to.</p></div></div>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment