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.
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.
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;
}
I designed a WooCommerce template for a customer. Now he wants to remove prices and visitors only add what they want to the list. So there will be no payment method. s:
- I can't change plugin or database. All data must remain how they are.
- I need to remove prices from all over the site. where ever they are. Cart, wishlist, single page & etc.
- I need to change payment method to something like submit list.
- at the end after submit list page there must be a contact info page.
please help.
You can hook into wc_price and remove the prices there
function my_filter_wc_price( $price ){
return '';
}
add_filter( 'wc_price', 'my_filter_wc_price' );
Then you can hook into parse_query and redirect the checkout page to the contact page.
function my_parse_query(){
if( is_page( wc_get_page_id( 'checkout' ) ) ){
wp_redirect( '/contact' );
exit;
}
}
add_action( 'parse_query', 'my_parse_query' );
That will stop people from being able purchasing things. Just hiding the price with CSS will not. They will still be able to craft URL's to add to cart, and find the cart / checkout pages.
since I found no other way I decided to do it width CSS and translation.
I removed all prices by display:none;
and I translated all the strings which are about shop and price.
On the woocommerce checkout page I want to move the field where the apply coupon input is and place it just below the order summary and above the payment options. I'm not sure how to change the php because the checkout page is comprised of multiple php files therefore I come to you genius people to help. Anybody know how I can achieve this? Thank you in advance!
P.S. I've added pictures; the first is of the top half of the page and the second is of the second half of the page.
#noufalcep you answer is not clear.
Finally after everything i came up with a working solution. i am using woocommerce 3.2.5 and wordpress version of 4.8.3.
As #noufalcep said the form inside form is not the issue. When we do
add_action( ‘woocommerce_checkout_after_order_review’, ‘woocommerce_checkout_coupon_form’ );
coupon container doesn't wrap up with form element. But the button has submit as input type. That's why when we apply coupon main form get suibmitted.
Therefore what i did is inserted the coupon form with jquery insertAfter. Below is the code. It is perfectly working.
var coupon = $(".checkout_coupon");
coupon.insertAfter('.shop_table.woocommerce-checkout-review-order-table');
Then this will add the form after review order table. if you want it with "Have a coupon? Click here to enter your code" text, you have to wrap the element with the form.
A working example can be seen here,
https://themovementfix.com/checkout/
If you are comfortable editing your functions.php file inside your theme directory, then you can add the following lines of code:
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_after_checkout_form', 'woocommerce_checkout_coupon_form' );
This will essentially remove the coupon (which is hooked before the checkout form) and re-add it AFTER the checkout form.
Alternatively, you can use Javascript to "cut&paste" the html block containing the coupon fields, but this is a messy way of coding and I would not suggest taking that route.
This worked great for me:
Add this jQuery:
(function($) {
$(document).ready(function() {
var coupon2 = $(".checkout_coupon.woocommerce-form-coupon");
coupon2.insertAfter('.shop_table.woocommerce-checkout-review-order-table');
})
})
(jQuery);
Add this css:
/*unhide copuon code checkout*/
.checkout_coupon {
display: block !important;
}
/*hide message have a coupon?*/
.woocommerce-info {
display:none;
}
/*coupon code checkout style*/
.checkout_coupon button.button{
background-color: #insert button color here;
}
This how I put the coupon form after the billing total. So it would be more helpful to use while customization.
Just place this code inside your functions.php and see the customization on the frontend.
/*
* Removing default "Coupon form" from the top of the checkout page
*/
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
/*
* Hooking "Coupon form" after order total in checkout page with custom function
*/
add_action( 'woocommerce_review_order_after_order_total', 'woocommerce_checkout_coupon_form_custom' );
/*
* Rendering html for "Coupon form" with custom function
*/
function woocommerce_checkout_coupon_form_custom() {
echo '<tr class="coupon-form"><td colspan="2">';
wc_get_template(
'checkout/form-coupon.php',
array(
'checkout' => WC()->checkout(),
)
);
echo '</td></tr>';
}
After reading about the form within a form issue that stops the usual add_actions from working, it inspired me to create a form-checkout.php file in my theme’s woocommerce folder, and simply move the order review's starting < form ... > code to right after the do_action( ‘woocommerce_checkout_before_customer_details’ ); line, then used these two lines to move the coupon form down to under the Your Order review display, and it worked great in v3.0.x of WooCommerce:
remove_action( ‘woocommerce_before_checkout_form’, ‘woocommerce_checkout_coupon_form’, 10 );
add_action( ‘woocommerce_checkout_after_order_review’, ‘woocommerce_checkout_coupon_form’ );
Without moving the starting form code, it wouldn’t work due to the form within a form issue mentioned, but once moved, works easily.
As of woocommerce 2.6 (or maybe even earlier) placing it "after order review" no longer works. If you apply a coupon it will place the order automatically. It's caused by the form within a form issue.
In Woocommerce 2.6, using hooks alone, only these 2 options currently work:
option 1:
add_action('woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form');
option 2:
add_action('woocommerce_after_checkout_form', 'woocommerce_checkout_coupon_form');
The problem is that the whole checkout page is inside a form, and the coupon is a form also. And you are unable to nest two forms. So even though you could technically move the coupon form above the review order section, it won't work properly. You need to rearrange your form and split them into two to make it work.
Move WooCommerce Coupon Field in Checkout Page
Using process: You can use the code using any plugin like (Code snippets) or function.PHP
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
add_action( 'woocommerce_review_order_after_cart_contents', 'woocommerce_checkout_coupon_form_custom' );
function woocommerce_checkout_coupon_form_custom() {
echo '<tr class="coupon-form"><td colspan="2">';
wc_get_template(
'checkout/form-coupon.php',
array(
'checkout' => WC()->checkout(),
)
);
echo '</tr></td>';
}
A slight revision on a suggested answer:
remove_action('woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10);
add_action('woocommerce_review_order_before_payment', 'woocommerce_checkout_coupon_form');
This places the coupon input below the order and above the payment options.