Great question — answering as the UphillTech team:
You can even hide the add to cart button and add a custom one and work with it. For the product page: add_action( 'woocommerce_single_product_summary', function () { global $product; if( $product->is_type('external') ) { echo '<a href="YOUR-URL/?affiliateID-1">Affiliate Button</a>'; } }, 30 ); Or like this: add_action( 'woocommerce_after_add_to_cart_button', function () { global $product; if( $product->is_type('external') ) { $link = 'YOUR-URL/?affiliateID-1'; // <== Here set button link $name = 'Affiliate Button'; // <== Here set button name $class = 'button alt'; $style = 'display: inline-block; margin-top: 12px;'; // Output echo ' <a href="'.$link.'" class="'.$class.'"...
Full answer by Ivijan Stefan Stipić: https://stackoverflow.stackexchange.com/a/68180448 (CC BY-SA 4.0).
Need it done for your business? UphillTech.