Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: WooCommerce - Minimal Required Fields
- Plugin URI: http://www.damiencarbery.com
- Description: Experiment with the minimal number of fields required to complete PayPal payment.
- Author: Damien Carbery
- Version: 0.2
- $Id: $
- */
- // See: http://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
- add_filter( 'woocommerce_checkout_fields' , 'wmrf_remove_checkout_fields' );
- // Our hooked in function - $fields is passed via the filter!
- function wmrf_remove_checkout_fields( $fields ) {
- global $woocommerce;
- $cart_has_physical_products = false;
- foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
- if (!$cart_item['data']->is_virtual()) {
- $cart_has_physical_products = true;
- }
- }
- if (!$cart_has_physical_products) {
- // Remove all billing fields except the email field.
- unset($fields['billing']['billing_first_name']);
- unset($fields['billing']['billing_last_name']);
- unset($fields['billing']['billing_company']);
- unset($fields['billing']['billing_address_1']);
- unset($fields['billing']['billing_address_2']);
- unset($fields['billing']['billing_city']);
- unset($fields['billing']['billing_postcode']);
- unset($fields['billing']['billing_country']);
- unset($fields['billing']['billing_state']);
- unset($fields['billing']['billing_phone']);
- unset($fields['order']['order_comments']);
- }
- return $fields;
- }
- // Hide the 'Additional Information' section (that contains the 'order_comments' field.
- add_filter('woocommerce_enable_order_notes_field', 'wmrf_remove_additional_info_section');
- function wmrf_remove_additional_info_section($yes) {
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement