checkout

Conditionally customizing WooCommerce checkout fields

帅比萌擦擦* 提交于 2021-02-06 14:17:24
问题 I am trying to modify WooCommerce check out fields. There are two points I want to reach. Conditional fields I want to make conditional fields for different shipping type in shipping section. To reach this point, Javascript is used. Administrator can edit the custom fields in the order on back-end As a result, I write the code as below. However, I met a problem. My javascript cannot work on the front-end. Does anybody can help me? //修改check out shipping field add_action( 'woocommerce_before

Conditionally customizing WooCommerce checkout fields

微笑、不失礼 提交于 2021-02-06 14:11:39
问题 I am trying to modify WooCommerce check out fields. There are two points I want to reach. Conditional fields I want to make conditional fields for different shipping type in shipping section. To reach this point, Javascript is used. Administrator can edit the custom fields in the order on back-end As a result, I write the code as below. However, I met a problem. My javascript cannot work on the front-end. Does anybody can help me? //修改check out shipping field add_action( 'woocommerce_before

Allow proceed to checkout for non mixed defined product categories in Woocommerce

独自空忆成欢 提交于 2021-02-05 08:31:44
问题 In woocommerce I am trying to avoid proceed to checkout when cart items are from mixed product categories… The following code is mostly working as I intended: function sv_wc_prevent_checkout_for_category() { // set the slug of the category that cannot be mixed from other categories $category = 'test'; // get the product category $product_cat = get_term_by( 'slug', $category, 'product_cat' ); // sanity check to prevent fatals if the term doesn't exist if ( is_wp_error( $product_cat ) ) {

Redirection for non checkout guest allowed in WooCommerce

陌路散爱 提交于 2021-02-05 08:22:27
问题 After Allow guest checkout for specific products only in WooCommerce answer to my previous question, the following code redirect users to login page: add_action( 'template_redirect', 'checkout_redirect_non_logged_to_login_access'); function checkout_redirect_non_logged_to_login_access() { if( is_checkout() && !is_user_logged_in()){ wp_redirect( get_permalink( get_option('woocommerce_myaccount_page_id') ) ); exit; } } But I have some products which allows guest checkout (see the linked

Add a new custom field to WooCommerce checkout

吃可爱长大的小学妹 提交于 2021-02-05 08:14:49
问题 I have the code that should work, but for some reason it doesnt. I want to add a new custom field called "City" under Woocommerce checkout, using this code: // Display a custom checkout select field after Billing form add_action( 'woocommerce_after_checkout_billing_form', 'my_custom_checkout_field', 10, 1 ); function my_custom_checkout_field( $checkout ) { echo '<div id="my_custom_checkout_field"> ' . __('City') . ''; woocommerce_form_field( 'delivery_date', array( 'type' => 'select',

Add a custom checkout field based on cart items quantity in Woocommerce

做~自己de王妃 提交于 2021-02-05 06:17:05
问题 Ultimately I am trying to add a field to checkout in woocommerce when a customer has over a certain quantity in their checkout. For this example I am using 500 and just trying to get a message to show at the bottom of checkout. I have been trying various variations of code and this is what I have so far. add_action( 'woocommerce_after_checkout_form', 'woocommerce_add_quantity_message', 12 ); function woocommerce_add_quantity_message() { global $woocommerce; $total_products = 0; foreach (

Add a custom checkout field based on cart items quantity in Woocommerce

点点圈 提交于 2021-02-05 06:17:05
问题 Ultimately I am trying to add a field to checkout in woocommerce when a customer has over a certain quantity in their checkout. For this example I am using 500 and just trying to get a message to show at the bottom of checkout. I have been trying various variations of code and this is what I have so far. add_action( 'woocommerce_after_checkout_form', 'woocommerce_add_quantity_message', 12 ); function woocommerce_add_quantity_message() { global $woocommerce; $total_products = 0; foreach (

Change postcode shipping field to a dropdown in Woocommerce

老子叫甜甜 提交于 2021-02-04 19:41:21
问题 Im trying to make the postcode field in shipping only to be a select type with my options in woocommerce checkout page: Unsetting shipping state and post code checkout fields add_filter( 'woocommerce_checkout_fields' , 'partial_unsetting_checkout_fields' ); function partial_unsetting_checkout_fields( $fields ) { unset($fields['shipping']['woocommerce_checkout_fields']); return $fields; } Reinserting custom shipping post code checkout field, add_filter( 'woocommerce_checkout_fields' , 'art

Change town/city text field to Select Option field in checkout form

混江龙づ霸主 提交于 2021-02-04 19:15:38
问题 In Woocommerce, I would like to change Town/City text field in a select field option field. What should i do? Here is a screenshot: Thanks 回答1: You need first to change the field type from 'text' to 'select' using the dedicated hook woocommerce_default_address_fields . Then you have also to change the label and to and an options argument where you are going to set your towns in an array of key/values . In this array, you will have a line by town separated by a coma. Here is the code: add

Show hide payment gateways based on checkout fields in Woocommerce [closed]

会有一股神秘感。 提交于 2021-02-04 16:46:53
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Improve this question In Woocommerce checkout page, I am trying to hide some payment gateways, keeping only "Cash on delivery" payment method (COD) when "Ship to a different address?" is checked. I have tried Conditionally hiding et showing payment gateways with some changes, but