I've had a problem on the checkout of my site's page for a while whereby the Update Cart button is not working. If you go into the element where the quantity of the item is, and change the amount from (for example) 4 to 2 and press enter then it updates, but if you change the quantity and press Update Cart, nothing happens. This is the code for the button in my FTP, and I'm just not seeing the problem:
<button type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>"><?php esc_html_e( 'Update cart', 'woocommerce' ); ?></button>
Inspecting the element in Google I notice it is down as being disabled, but I don't know where to enable it in the FTP:
<button type="submit" class="button" name="update_cart" value="Update cart" disabled="">Update cart</button>
EDIT: Moved comment into question
Though looking at the Coupon section of the Checkout, I'm wondering if the Update Cart button should look more like this:
<div class="coupon">
<label for="coupon_code">
<?php esc_html_e( 'Coupon:', 'woocommerce' ); ?>
</label>
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" />
<input type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>" />
<?php do_action( 'woocommerce_cart_coupon' ); ?>
</div>
<?php } ?>
EDIT2: I found a temporary solution by going to:
wp-content/plugins/woocommerce/assets/js/frontend/cart.min.js
searching for:
.prop("disabled",!0)},input_changed
and changing the !0 into a !1
This works for the first update to the cart, then it goes back to not working again, but it's a start.
try replacing the
<button name="update_cart">
with an input instead
<input type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>">
Had the same problem when updating woocommerce and noticed they changed some of their inputs into buttons instead, so just revert back to using inputs for problem areas.
Related
I had added three buttons to the cart page, one for each payment method. Clicking on one of the buttons led to the checkout page where the corresponding payment method used to be pre-selected. It used to work, but somehow has stopped working after updating to the latest Woocommerce version. Any other way of doing this?
Here is the code in cart.php template for the buttons:
<form action="<?php echo esc_url( WC()->cart->get_cart_url() ); ?>" method="post">
<input type="submit" class="checkout-button button alt wc-forward" name="proceed" value="<?php _e( 'Order with Purchase Order', 'woocommerce' ); ?>" />
<input type="submit" class="checkout-button button alt wc-forward" name="proceed" value="<?php _e( 'Order with PayPal', 'woocommerce' ); ?>" />
<input type="submit" class="checkout-button button alt wc-forward" name="proceed" value="<?php _e( 'Order with Credit Card', 'woocommerce' ); ?>" />
<?php /*do_action( 'woocommerce_proceed_to_checkout' );*/ ?>
<?php wp_nonce_field( 'woocommerce-cart' ); ?>
</form>
I need to set the search that's part of the theme, to search for Products only. At the moment it searches the whole platform.
It's not a custom form I need just the ability to change the default search operation. So rather than going to /s?green, it includes the 'product' code in the URL so it searches only for products.
add_filter( 'pre_get_posts', 'custom_pre_get_posts' );
function custom_pre_get_posts( $query ) {
if ( is_search() ) {
$query->set('post_type', 'product');
}
return $query;
}
We just want it to show products in their product tiles, rather that blog results.
If you only will ever be searching the product post type on your site, you can create your own searchform.php template to include this hidden field:
<input type="hidden" name="post_type" value="product" />
You can place that anywhere within the form HTML markup. Below is the what WP outputs by default if there is no searchform.php file and you're using the HTML5 form support.
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="hidden" name="post_type" value="product"/>
<label>
<span class="screen-reader-text"><?php _e( 'Search for:', 'label' ); ?></span>
<input type="search" class="search-field" placeholder="<?php esc_attr_e( 'Search …', 'placeholder' ); ?>" value="<?php echo get_search_query(); ?>" name="s"/>
</label>
<input type="submit" class="search-submit" value="<?php esc_attr_e( 'Search', 'submit button' ); ?>"/>
</form>
You can add the above code to your own searchform.php and add that to the root of your THEME directory.
It was within the functions file in the root theme area. We were directed to it, them took it out, placed it in child theme, edited the Form tag in the code, and it worked.
I have to change the input type of a password field.
When I click on a button, it toggled from show to hide value. Also, input type changed from password to text.
How can I implement the same functionality in Laravel as defined in WordPress -
wordpress/wp-admin/install.php?
Can any one help me in understanding this piece of code:
<label for="pass1">
<?php _e( 'Password' ); ?>
</label>
</th>
<td>
<div class="">
<?php $initial_password = isset( $_POST['admin_password'] ) ? stripslashes( $_POST['admin_password'] ) : wp_generate_password( 18 ); ?>
Please, explain the below code:
<input type="password" name="admin_password" id="pass1" class="regular-text" autocomplete="off" data-reveal="1" data-pw="<?php echo esc_attr( $initial_password ); ?>" aria-describedby="pass-strength-result" />
<button type="button" class="button wp-hide-pw hide-if-no-js" data-start-masked="<?php echo (int) isset( $_POST['admin_password'] ); ?>" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
<span class="dashicons dashicons-hidden"></span>
<span class="text"><?php _e( 'Hide' ); ?></span>
</button>
Please, explain these terms:
data-reveal="1"
data-pw
aria-describedby="pass-strength-result"
data-start-masked
Are these HTML or Bootstrap attributes?
Please, tell me, what files are related to this code & where.
aria-describedby is an attribute from JavaScript.
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-describedby_attribute
data-toggle is an attribute from Bootstrap. Example
aria-label is an attribute from JavaScript. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Techniques/Using_the_aria-label_attribute
data-reveal is an attribute from Foundation. https://foundation.zurb.com/sites/docs/v/5.5.3/components/reveal.html
I created a custom checkout page.
I wanted to put the coupon code anywhere and it worked.
Unfortunately after clicking on the "apply coupon" button, instead of validating the coupon and adding it to the order, the system responds as per clicking the "order and pay" button Code used in form-checkout.php:
<?php do_action('woocommerce_checkout_coupon_form', $checkout); ?>
<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
<div class="checkout-form-container">
<?php if ( sizeof( $checkout->checkout_fields ) > 0 ) : ?>
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
<div class="col2-set" id="customer_details">
<div class="col-1">
<?php do_action( 'woocommerce_checkout_billing' ); ?>
</div>
</div>
<?php do_action( 'woocommerce_checkout_after_customer_details'); ?>
<p class="form-row form-row-first">
<label for="coupon_code">Coupon?</label>
<input type="text" name="coupon_code" class="custom-coupon-code-input input-text" placeholder="<?php esc_attr_e( 'Wprowadż kod', 'woocommerce' ); ?>" id="coupon_code" value="" />
</p>
<p class="form-row form-row-last">
<input type="submit"button class="button custom-apply-coupon-btn">
<?php esc_attr_e( 'Apply', 'woocommerce' ); ?>
</button>
</p>
<?php endif; ?>
</div>
Check your checkout page HTML. You are actually putting your coupon form inside checkout form. HTML forms doesn't support nested forms.
Put the form outside of checkout form. If you really need to show them there then take those values by javascript with the click of 'Apply Coupon' button and do the validation. But A form tag inside another form is not the correct way.
The submit button is submitting parent form also. That's why you are getting that.
I know where is the problem. Everything works perfectly on woo 2.6.8 but after update to min 3.0.4 its crash as I described above.
In woocommerce form-edit-account.php, i have the following but would only like to retain the Password and Confirm new password fields. I deleted all fields except Password and Confirm new password field but there is a validator that prompts me to fill up First Name, Last Name, Email address fields. How do i disable the validator for that? Really need help on this. Thanks in advance.
<?php
/**
* Edit account form
*
* #author WooThemes
* #package WooCommerce/Templates
* #version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $woocommerce;
?>
<?php wc_print_notices(); ?>
<form action="" method="post">
<p class="form-row form-row-first">
<label for="account_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_first_name" id="account_first_name" value="<?php esc_attr_e( $user->first_name ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="account_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="account_last_name" id="account_last_name" value="<?php esc_attr_e( $user->last_name ); ?>" />
</p>
<p class="form-row form-row-wide">
<label for="account_email"><?php _e( 'Email address', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="email" class="input-text" name="account_email" id="account_email" value="<?php esc_attr_e( $user->user_email ); ?>" />
</p>
<p class="form-row form-row-first">
<label for="password_1"><?php _e( 'Password (leave blank to leave unchanged)', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_1" id="password_1" />
</p>
<p class="form-row form-row-last">
<label for="password_2"><?php _e( 'Confirm new password', 'woocommerce' ); ?></label>
<input type="password" class="input-text" name="password_2" id="password_2" />
</p>
<div class="clear"></div>
<p><input type="submit" class="button" name="save_account_details" value="<?php _e( 'Save changes', 'woocommerce' ); ?>" /></p>
<?php wp_nonce_field( 'save_account_details' ); ?>
<input type="hidden" name="action" value="save_account_details" />
</form>
Well, I do that using this:
// Hook in
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
function custom_override_default_address_fields( $fields ) {
unset($fields['first_name']);
return $fields;
}
It will remove the "First Name" field from both, billing and shipping address.
After some quick research, the solution to exactly your problem, and also resently my problem.
Just add this to functions.php
add_filter( 'woocommerce_save_account_details_required_fields','custom_woocommerce_save_account_details_required_fields' );
function custom_woocommerce_save_account_details_required_fields( $required_fields ) {
unset($required_fields["account_first_name"]);
unset($required_fields["account_last_name"]);
return $required_fields;
}
It will remove the First Name field and Last Name field from the condition of required fields. Of course you can do that with all of your required inputs.
You can remove these validation manually.
Woocomaerce->includes->class-wc-form-handler.php
find function
save_account_details()
edit this function or you can remove validation form here.