checkout

Checkout fields: Hiding and showing existing fields

眉间皱痕 提交于 2019-11-29 08:50:50
Based on this working answer: // Registering external jQuery/JS file function cfields_scripts() { // IMPORTANT NOTE: // For a child theme replace get_template_directory_uri() by get_stylesheet_directory_uri() // The external cfields.js file goes in a subfolder "js" of your active child theme or theme. wp_enqueue_script( 'checkout_script', get_template_directory_uri().'/js/cfields.js', array('jquery'), '1.0', true ); } add_action( 'wp_enqueue_scripts', 'cfields_scripts' ); add_filter( 'woocommerce_checkout_fields', 'ba_custom_checkout_billing_fields' ); function ba_custom_checkout_billing

Changing WooCommerce cart item names

北城以北 提交于 2019-11-29 08:20:48
The goal is to change the name of the item as it gets passed to our payment gateway, but leave it as-is for display on our product pages. I've tried this in my functions.php: function change_item_name( $item_name, $item ) { $item_name = 'mydesiredproductname'; return $item_name; } add_filter( 'woocommerce_order_item_name', 'change_item_name', 10, 1 ); But it doesn't seem to be working for me. I feel like I should be passing in an actual item ID or something… I'm a little lost. Any information on what I'm doing wrong here would be greatly appreciated. The woocommerce_order_item_name filter hook

Make Woocommerce checkout phone field optional based on shipping country

荒凉一梦 提交于 2019-11-29 08:08:19
In Woocommerce checkout, I am trying to make the phone field not required for specific shipping countries. Based on " Make checkout phone field optional for specific countries in WooCommerce " answer code, which works fine, I have tried to make some changes to get this code working for the shipping country rather than billing country. After a lot of tries, I wasn't able to figure out how to make it work. Any help will be awesome and greatly appreciated. The following code will make billing phone field required only for specific "Shipping" countries. Since Woocommerce version 3.4+, things have

How to make Woocommerce not to save Checkout billing fields

时间秒杀一切 提交于 2019-11-29 04:55:25
I have a particular case where I need many people to login to ONE specially created user (one login name and one password for all) and purchase items through it. The problem is if Person A logins with this ONE user credentials and makes a purchase he will leave a trace in shipping/billing details, person B will then see those details when in checkout page. Woocommerce saves those details by default, how could I disable that? How can I make Woocommerce Chechout page to always have empty fields with no prepopulated data from previous purchases? Thanks! Mantas you need this filter... this filter

Custom validation of WooCommerce checkout fields

泄露秘密 提交于 2019-11-29 04:08:45
I would like add my own regular expression for validating the phone number. In my class-wc-validation.php I have changed the regular expression to my requirement. public static function is_phone( $phone ) { //if ( strlen( trim( preg_replace( '/[\s\#0-9_\-\+\(\)]/', '', $phone ) ) ) > 0 ) if ( strlen( trim( preg_replace( '/^[6789]\d{9}$/', '', $phone ) ) ) > 0 ) return false; return true; } But the validation is not happening. What am I missing? I have not seen your code that hooks these up to the woocommerce checkout flow. please check their documentation on woocommerce_checkout_process and

创建SVN代码托管

让人想犯罪 __ 提交于 2019-11-28 18:16:41
在我们开发过程中,避免不了要使用svn,如果不是从初始版本入手的话,很可能你需要使用co,up,st,diff,ci等几个命令,这些都是比较常用的,在下面我们讲述的是 如何将整个工程,传到SVN创建初始版本 。 在这里我们的项目房子baseFont中,目录结果如下:其中 文件夹dist和node_modules是运行时文件夹 ,没有必要加入到svn版本管理之后。 --baseFont ----app/ ----dist/ ----Gruntfile.js ----js/ ----.jshintrc ----node_modules/ 。。。。。 导入-import/mkdir svn import baseFont svn://git.oschina.net/wjzk/baseFont -m 'create folder' --depth empty 这个命令中使用了 --depth empty 意思是之创建文件夹 baseFont ,而不inport任何文件夹,这样可以便于我们有选择的只上传需要的代码,而忽略掉不必须要的代码。同意也可以使用如下代码创建文件夹,效果是同等的: svn mkdir svn://git.oschina.net/wjzk/baseFont -m 'create folder' 导出工程-co svn co --depth=empty svn://git

Pre-fill Woocommerce checkout fields with Url variables saved in session

蓝咒 提交于 2019-11-28 14:27:49
When people enter the my woocommerce shop following a link in an sales email with email and name as parameters I would like to prefill the name and email in the checkout page. Therefore I created an action and filter. This works as expected but only if I do a hard refresh on the sales page (ctrl + f5) I've excluded the sales page and the checkout page from the cache and varnish cache but this didn't fix the issue. Am I missing something here? Do you have any idea why this only works with a hard refresh? Any help is greatly appreciated. Code: function save() { if ( is_page( 'sales-page' ) ) {

Hide Added to Cart message in Woocommerce

早过忘川 提交于 2019-11-28 13:28:16
I want to remove the "xx product has been added to your cart" message from the top of my checkout page. How can I do that? There was a suggestion by someone (link below), but it didn't work for me. Remove/Hide Woocommerce Added to Cart Message but Keep/Display Coupon Applied Message Update for Woocommerce 3+ The hook wc_add_to_cart_message is deprecated and replaced by wc_add_to_cart_message_html . You can use the following (compact effective way): add_filter( 'wc_add_to_cart_message_html', '__return_false' ); Or the normal way: add_filter( 'wc_add_to_cart_message_html', 'empty_wc_add_to_cart

Custom dropdown selector showing or hiding other Checkout custom fields

十年热恋 提交于 2019-11-28 12:44:17
I use this code to create custom checkout fields and reorder fields: add_filter( 'woocommerce_checkout_fields', 'custom_checkout_billing_fields' ); function custom_checkout_billing_fields( $fields ) { // 1. Creating the additional custom billing fields // The "status" selector $fields['billing']['billing_status']['type'] = 'select'; $fields['billing']['billing_status']['class'] = array('form-row-wide, status-select'); $fields['billing']['billing_status']['required'] = true; $fields['billing']['billing_status']['label'] = __('User status', 'my_theme_slug'); $fields['billing']['billing_status'][