Woocommerce checkout page has unconfigurable fields - php

I am stuck with trying to configure my website's checkout fields in woo commerce.It comes prefilled with values and doesnt get removed even after purging the cache.
https://shinujohn.com/checkout/ ...set as with the default shortcode
The country has 2 field boxes now...one is clickable drop down.
Server side caching is disabled.
The theme I'm using is Kallyas
I Have tried:-
Field editor : It does not even show the field ..say company name.and adding a new field is not reflected here.even if i add it to the billing or checkout fields
Adding code to functions.php
/returning woo commerce field as blank/
add_filter('woocommerce_checkout_get_value','__return_empty_string', 1, 1);
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
or
function custom_override_billing_fields( $fields ) {
unset($fields['billing_postcode']);
unset($fields['billing_state']);
unset($fields['billing_country']);
unset($fields['billing_address_1']);
return $fields;
}
neither work
3. issue persists with multiple browsers and unlogged users in different machines..
4. Within the theme's page editor... i can of course change front end ...but it doesnt reflect it after publishing.

I don't recommend you to use any extra plugin to edit the Woocommerce checkout fields. Here is the simple solution that you can easily customize the Woocommerce checkout fields.
add_filter( 'woocommerce_checkout_fields' , 'custom_override_billing_fields', 5);
function custom_override_billing_fields( $fields ) {
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_address_1']);
return $fields;
}
May this code helps you.

Related

Unset billing fields with condition in Woocommerce

I'm trying to remove some required billing fields if the checkout page based on a certain page template.
Everything in the code below works fine if I remove the if condition, but with the condition even though the fields are unset it still throws the required field error on submission. I also tried a different condition such as checking for a $_GET variable but that didn't work either, it is an option though.
function custom_override_checkout_fields( $fields ) {
if ( is_page_template( 'page-simple.php') ) {
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['order']['order_comments']);
return $fields;
} else {
return $fields;
}
}
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
I've already ruled out a plugin or theme conflict by changing to twentysixteen and disabling all unnecessary plugins. I'm running the latest version of Woocommerce as of post. I'm running the One Page Checkout plugin to give me separate checkout pages, but ruled it out as the issue since this doesn't work with the regular checkout either when a condition is present.
Please let me know if I'm missing some information that would be helpful in troubleshooting this.

Clear only some checkout fields values in Woocommerce

In Woocommerce i am trying to clear the checkout fields. so when a user that has ordered something before, and is now ordering something again, he/she will have to write in all his/her information again.
i am using this code
function clear_checkout_fields($input){
return '';
}
add_filter( 'woocommerce_checkout_get_value' , 'clear_checkout_fields' , 1);
Now this code is clearing all the fields, but it also changes my VAT to show as 0.
does anyone know a solution to this?
There is some arguments errors in your woocommerce_checkout_get_value hooked function.
There is in fact 2 arguments:
the $value argument that is returned as it is a filter hook,
the $imput argument that you can use to target any checkout field.
So in your case you will use the $imput argument, to avoid your custom VAT checkout field to be emptied. In the code below, you will need to replace vat_number by the correct field name attribute that is set in your custom VAT checkout field:
add_filter( 'woocommerce_checkout_get_value' , 'clear_checkout_fields' , 10, 2 );
function clear_checkout_fields( $value, $input ){
if( $input != 'vat_number' )
$value = '';
return $value;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.

How to add custom fee to woocommerce from a custom filed

I have added a custom text field (named add_for_charity_field) in woocommerce. This filed is for adding desired amount for charity. I have used the WooCommerce Checkout Field Editor plugin to adding this field in checkout form. Now I need to add this field content to cart by add_fee function but I don't have access to the field content in php. Is there a solution for it ? I am not familiar with jQuery and I think that I must use jQuery.
I have use this code in function.php
function woo_add_cart_fee() {
global $woocommerce;
$woocommerce->cart->add_fee( __('Charity', 'woocommerce'), $_POST['add_for_charity_field'] );
}
add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );

How can I remove the Add Product (s) in woocommerce order admin page?

I am trying to customize my "Add new" order page.
I want to remove the "Add product(s)" line along with other lines on that row.
would love to have some explanation of how to find the relevant data for filtering the buttons out.
I have searched the forum and found that adding a similar filter might be the option.
// remove Order Notes from checkout field in Woocommerce
add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' );
function alter_woocommerce_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}

WooCommerce Checkout trim

Im running a web shop based on WP and WooCommerce. After the latest WC update some things changed on my checkout page and I'm looking for a way to trim the page a bit.
What I'm looking to do is to remove some of the unnecessary options shown to customers. I'm just not quite sure how do this :)?
What i want to hide/remove is:
(1) Since i only sell to Denmark
Land *
Danmark
(2) The second input box for address. Only the first is needed.
Adresse*
Apartment, suite etc.
(3) Additional information section - I dont need to have this either.
YDERLIGERE INFORMATION
Ordre Bemærkninger
I really hope that someone out there will be able to answer this and help me out! :)
The website is www.motorcykelgrej.dk <- to access the checkout page you need to add something to the basket first.
Best regards
Michael
Add this to your theme functions.php:
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_address_2']);
unset($fields['order']['order_comments']);
return $fields;
}
And this custom CSS code:
.checkout-group h3 {
display:none;
}

Categories