Тёмный

How to Set Custom Limit on Checkout Phone field in WooCommerce | Contain 10 Numbers - Validation 

WebTask With Hassan
Подписаться 7 тыс.
Просмотров 2,4 тыс.
50% 1

In this woocommerce tutorial for beginners you will learn how to set specific number limit in phone field using custom php snippet in checkout page in wordpress website. So you can validate telephone field according to your requirement, so you can set 10, 15 or 20.
* Use Below Custom Code to Set Limit:
// You can add a custom placeholder to add a hint for your CUs what you expect
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields2' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields2( $fields ) {
$fields['billing']['billing_phone']['placeholder'] = '09XXXXXXXXX';
return $fields;
}
/****************************************************************/
/* VALIDATION FOR PHONE FIELD THIS WILL THROW AN ERROR MESSAGE */
/****************************************************************/
/** Process the checkout **/
add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process');
function my_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error. This one is only requite for companies
if ( ! (preg_match('/^[0-9]{10}$/D', $_POST['billing_phone'] ))){
wc_add_notice( "The Phone should contain only 10 digits" ,'error' );
}
}
* In code you see {10} so if you want to change limit then add your digit / number instead of 10 in code.
#woocommerce #phone #checkout #limit #field #wordpress #wordpresstutorial #webtaskwithhassan #hassangilani

Опубликовано:

 

13 июн 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 15   
@arexpantallano7872
@arexpantallano7872 20 дней назад
Nice. Saved my day
@WebTaskWithHassan
@WebTaskWithHassan 8 дней назад
thank you :)
@EnyonamAntwi-us8dh
@EnyonamAntwi-us8dh Год назад
Thank you so much Sir, this is what I was looking for.
@WebTaskWithHassan
@WebTaskWithHassan Год назад
You are welcome :)
@user-yd2fj1nv7v
@user-yd2fj1nv7v 4 месяца назад
Perfect, Thank you so much sir
@WebTaskWithHassan
@WebTaskWithHassan 4 месяца назад
you are welcome :)
@Xenovaniss
@Xenovaniss Год назад
Very clear and nice video
@WebTaskWithHassan
@WebTaskWithHassan Год назад
Thank you :)
@UddhikaIshara
@UddhikaIshara 6 месяцев назад
Thank you!
@WebTaskWithHassan
@WebTaskWithHassan 5 месяцев назад
you are welcome :)
@UnlimitedAdvice
@UnlimitedAdvice 8 месяцев назад
Start with 01, how to set up this code. please tell me. Bangladesh
@mangesh6599
@mangesh6599 4 месяца назад
not working
@djelgi
@djelgi 8 месяцев назад
Hi, if i want at least 10 digits? Is this possible?
@WebTaskWithHassan
@WebTaskWithHassan 8 месяцев назад
checkout this video to set limit minimum for phone field ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-iTd3wycmdHY.html
@jitendrajaintwal6503
@jitendrajaintwal6503 3 месяца назад
sir but apko code kaha se mila
Далее
Склеил девушку-курьера ❤️
01:00
Наташа Кампуш. 3096 дней в плену.
00:58
Elementor Whatsapp Button - 2 Ways!
7:58
Просмотров 19 тыс.
Woocommerce Checkout page Field customization | Bangla
15:39
Склеил девушку-курьера ❤️
01:00