Support » Fixing WordPress » How to hide billing and shipping address from digital goods?

  • Resolved sillyninja

    (@sillyninja)


    Hello,

    I sell digital good, and I don’t need any billing and shipping field on the cart page when user buy those digital goods. Is there any way to hide those details?

    I don’t want to install any plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Are you using a plugin to generate the content of the cart page? It seems like it since WordPress doesn’t have that feature.
    You should ask at the support forum for whatever plugin you are using for that.

    Thread Starter sillyninja

    (@sillyninja)

    @joyously No, I am not using any plugin. I want to hide/remove field marked in the snapshot

    https://i.imgur.com/aGIjBxQ.png

    Thread Starter sillyninja

    (@sillyninja)

    Got the code. Thanks!

    If you sell downloadable/virtual products and need to simplify your WooCommerce checkout when such product type is in the Cart, you’ve come to the right place!

    add_filter( ‘woocommerce_checkout_fields’ , ‘bbloomer_simplify_checkout_virtual’ );

    function bbloomer_simplify_checkout_virtual( $fields ) {

    $only_virtual = true;

    foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
    // Check if there are non-virtual products
    if ( ! $cart_item[‘data’]->is_virtual() ) $only_virtual = false;
    }

    if( $only_virtual ) {
    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’]);
    add_filter( ‘woocommerce_enable_order_notes_field’, ‘__return_false’ );
    }

    return $fields;
    }

    • This reply was modified 9 months, 1 week ago by sillyninja.
    • This reply was modified 9 months, 1 week ago by sillyninja.
    • This reply was modified 9 months, 1 week ago by sillyninja.
    • This reply was modified 9 months, 1 week ago by sillyninja.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to hide billing and shipping address from digital goods?’ is closed to new replies.