Skip to content

Instantly share code, notes, and snippets.

@jwebcat
Created September 9, 2013 21:48
Show Gist options
  • Save jwebcat/6501993 to your computer and use it in GitHub Desktop.
Save jwebcat/6501993 to your computer and use it in GitHub Desktop.
Override Woo Commerce Add to cart and go straight to checkout page. Also, override fields comments field Checkout page.
add_filter ('add_to_cart_redirect', 'redirect_to_checkout');
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
add_filter('single_add_to_cart_text', 'woo_custom_cart_button_text');
function woo_custom_cart_button_text() {
return __('Donate Now', 'woocommerce');
}
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['order']['order_comments']['placeholder'] = 'Order Comments';
$fields['order']['order_comments']['label'] = 'You will receive a donation substantiation letter directly from Infinite One Ministries. All donations are tax deductible to the extent allowed by law. Infinite One Ministries has submitted its 1023 application to the IRS to become an approved 501c3 entity. Our EIN number is 45-2959586';
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment