Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 07:56
Show Gist options
  • Save bradleysa/2e3915dfb19dd5ce94034e6c45a00af6 to your computer and use it in GitHub Desktop.
Save bradleysa/2e3915dfb19dd5ce94034e6c45a00af6 to your computer and use it in GitHub Desktop.
WC: Add attributes to checkout fields
// Add attributes to checkout fields
function wc_add_checkout_add_ons_attributes( $checkout_fields ) {
$add_on_id = 2; // change number to correct add-on id
if ( isset( $checkout_fields['add_ons'][ 'wc_checkout_add_ons_' . $add_on_id ] ) ) {
$checkout_fields['add_ons'][ 'wc_checkout_add_ons_' . $add_on_id ]['placeholder'] = "Add a short message for a handwritten card (optional)";
//Adds placeholder text
}
return $checkout_fields;
}
add_filter( 'woocommerce_checkout_fields', 'wc_add_checkout_add_ons_attributes', 20 );
/** http://docs.woothemes.com/document/woocommerce-checkout-add-ons-developer-docs/ **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment