Skip to content

Instantly share code, notes, and snippets.

@rajeshsingh520
Created February 10, 2025 01:44
Show Gist options
  • Save rajeshsingh520/61db06a4af1124a928e11fe148fb4ced to your computer and use it in GitHub Desktop.
Save rajeshsingh520/61db06a4af1124a928e11fe148fb4ced to your computer and use it in GitHub Desktop.
add_action('woocommerce_after_add_to_cart_button', function(){
global $product;
if ( ! $product ) {
return;
}
$product_id = $product->get_id();
if(!$product->is_type('subscription')){
return;
}
echo '<input type="hidden" name="add-to-cart" value="' . esc_attr($product_id) . '">';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment