Как удалить поля при оформлении заказа в WooCommerce?

Вот полный список полей в массиве, переданных woocommerce_checkout_fields:

  • Billing
    • billing_first_name
    • billing_last_name
    • billing_company
    • billing_address_1
    • billing_address_2
    • billing_city
    • billing_postcode
    • billing_country
    • billing_state
    • billing_email
    • billing_phone
  • Shipping
    • shipping_first_name
    • shipping_last_name
    • shipping_company
    • shipping_address_1
    • shipping_address_2
    • shipping_city
    • shipping_postcode
    • shipping_country
    • shipping_state
  • Account
    • account_username
    • account_password
    • account_password-2
  • Order
    • order_comments

Соответственно, ниже, мы вызываем нужные хуки WooCommerce, прикрепляем функции которые и будут удалять неугодные поля. Пользовательский код должен быть скопирован в файл functions.php вашей дочерней темы .

/*
*  Удаляем поля со страницы аккаунта и со страницы оформления заказа 
*/
add_filter( 'woocommerce_checkout_fields' , 'cisp_override_checkout_fields' );
add_filter( 'woocommerce_billing_fields' , 'cisp_override_billing_fields' );
add_filter( 'woocommerce_shipping_fields' , 'cisp_override_shipping_fields' );

function cisp_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_first_name']);
    unset($fields['shipping']['shipping_first_name']);
    unset($fields['billing']['billing_last_name']);
    unset($fields['shipping']['shipping_last_name']);
    unset($fields['billing']['billing_company']);
    unset($fields['shipping']['shipping_company']);
    unset($fields['billing']['billing_address_1']);
    unset($fields['shipping']['shipping_address_1']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['shipping']['shipping_address_2']);
    unset($fields['billing']['billing_postcode']);
    unset($fields['shipping']['shipping_postcode']);
    unset($fields['billing']['billing_city']);
    unset($fields['shipping']['shipping_city']);
    unset($fields['billing']['billing_state']);
    unset($fields['shipping']['shipping_state']);
    //unset($fields['billing']['billing_email']);
    //unset($fields['shipping']['shipping_email']);

    return $fields;
}

function cisp_override_billing_fields( $fields ) {
    unset($fields['billing_country']);
    unset($fields['billing']['billing_company']);
    unset($fields['billing']['billing_address_1']);
    unset($fields['billing']['billing_address_2']);
    unset($fields['billing']['billing_state']);
    unset($fields['billing']['billing_postcode']);
    unset($fields['billing']['billing_email']);

    return $fields;
}

function cisp_override_shipping_fields( $fields ) {
    unset($fields['shipping_country']);
    unset($fields['shipping']['shipping_company']);
    unset($fields['shipping']['shipping_address_1']);
    unset($fields['shipping']['shipping_address_2']);
    unset($fields['shipping']['shipping_state']);
    unset($fields['shipping']['shipping_postcode']);
    unset($fields['shipping']['shipping_email']);

    return $fields;
}

Оставьте комментарий

Добавить комментарий

%d такие блоггеры, как: