Skip to content

Instantly share code, notes, and snippets.

@ahmedeshaan
Created October 16, 2023 06:36
Show Gist options
  • Save ahmedeshaan/9f99204695b20ce2218ae17509d92629 to your computer and use it in GitHub Desktop.
Save ahmedeshaan/9f99204695b20ce2218ae17509d92629 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_loop_add_to_cart_button', 20, 2 );
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_loop_add_to_cart_button', 20, 2 );
function custom_loop_add_to_cart_button( $button_text, $product ) {
// HERE define your specific product IDs in this array
$specific_ids = array(10357339); // product id
if( in_array($product->get_id(), $specific_ids) ) {
$button_text = __("Subscribe now!", "woocommerce");
}
return $button_text;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment