php

Format billing phone number on WooCommerce checkout

笑着哭i 提交于 2021-02-18 18:09:21
问题 For the WooCommerce checkout billing field, how can I make this field require 9 numbers and insert dashes for proper phone formatting? For example, instead of typing out 3053453212 in the phone number field, it displays: (305-345-3212) 回答1: Based on "Formatting a phone number in a form using jquery" answer code, here is the way to format the Woocommerce billing phone: add_action('wp_footer', 'format_checkout_billing_phone'); function format_checkout_billing_phone() { if ( is_checkout() && !

Format billing phone number on WooCommerce checkout

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 18:08:59
问题 For the WooCommerce checkout billing field, how can I make this field require 9 numbers and insert dashes for proper phone formatting? For example, instead of typing out 3053453212 in the phone number field, it displays: (305-345-3212) 回答1: Based on "Formatting a phone number in a form using jquery" answer code, here is the way to format the Woocommerce billing phone: add_action('wp_footer', 'format_checkout_billing_phone'); function format_checkout_billing_phone() { if ( is_checkout() && !

Replace all non numeric characters in MSSQL with an empty string

拈花ヽ惹草 提交于 2021-02-18 18:04:16
问题 My current MSSQL table has a "phone" column which is a varchar. Unfortunately, the phone numbers that are already in the database are not in standard format. For example, 888-888-8888 OR 888/888/8888 OR (888)8888888 OR 8888888888. I want to get all the rows that are equivalent to 88888888, i.e it should match with 888-888-8888, (888)888888 etc. I have tried using REPLACE() but there are certain rows where entries have other alphabetic characters like "e", "ex", "ext", etc. So I would like to

Run both Django and PHP application in Apache

匆匆过客 提交于 2021-02-18 18:00:34
问题 I'm trying to host Django and PHP(wordpress) app in Apache domain.com, should point to Django app domain.com/wp, should point to wordpress app Here is my 000-default.conf in /etc/apache2/sites-available <VirtualHost *:80> DocumentRoot "/var/www/html/wp" ServerName domain.com/wp Alias /wp /var/www/html/wp <Directory /var/www/html/wp> Options Indexes FollowSymLinks AllowOverride None Order Deny,Allow Allow from all </Directory> </VirtualHost> <VirtualHost *:80> Alias /static /var/www/html

How do you generate a list of all possible strings given a generator of characters and a length?

旧时模样 提交于 2021-02-18 18:00:24
问题 For example given ['a', 'b'] (as a generator) and 2 as a length the function would output a generator that would yield: '', 'a', 'b', 'ab' 'ba' 'aa' 'bb' or given ['a'] and a length of 3: '', 'a', 'aa', 'aaa', As you could imagine this set would get a lot larger if more letters were added or length was increased, it should list all permutations of the given characters up until the length 回答1: Here's a fairly self-explanatory solution. //Returns all permuations of a certain length. function

Dynamic checkout custom fields per persons and items in Woocommerce bookings

折月煮酒 提交于 2021-02-18 17:55:44
问题 For a bookings website I'm trying to create a function which makes it possible to add an attendee list, based on the amount of persons. I've already got the code for a single booking, thanks to LoicTheAztec. That part is working fine. I also need the same functionality for multiple bookings. How can I achieve this? Here is the code: //* Add a new checkout field add_filter( 'woocommerce_checkout_fields', 'ppp_filter_checkout_fields' ); function ppp_filter_checkout_fields($fields){ $fields[

How to display image from aws s3 in blade laravel 5.2

两盒软妹~` 提交于 2021-02-18 17:10:51
问题 I have created a method for getting the data(image file) from aws S3 like this : public static function getImage ($imagePath) { if(Storage::exists($imagePath)) { return Storage::disk('s3')->get($imagePath); }else { return 'No Image'; } } I'm sure that those image is exist on the aws, so there is no problem with that. And then I use above method as the src in my blade view like this : {!!Html::image(getImage($myPath),'logo',['width'=>60,'height'=>55])!!} $myPath here already point to the

MySQL update, skip blank fields with PDO

邮差的信 提交于 2021-02-18 17:09:37
问题 I would like to update a MySQL row via the form below. The form works great as is but, if I leave a field blank, it changes the field in MySQL to blank as well. I would like to update the sql but skip over any fields that are blank. I have read a few ways of doing this but they didn't seem logical. I.e. using if statements in the sql string itself. (Having MySQL do the work that should be done in PHP). if($_SERVER['REQUEST_METHOD'] != 'POST') { echo '<form method="post" action=""> ID: <input

MySQL update, skip blank fields with PDO

我们两清 提交于 2021-02-18 17:09:27
问题 I would like to update a MySQL row via the form below. The form works great as is but, if I leave a field blank, it changes the field in MySQL to blank as well. I would like to update the sql but skip over any fields that are blank. I have read a few ways of doing this but they didn't seem logical. I.e. using if statements in the sql string itself. (Having MySQL do the work that should be done in PHP). if($_SERVER['REQUEST_METHOD'] != 'POST') { echo '<form method="post" action=""> ID: <input

Convert 64 bit hexadecimal to float in PHP

随声附和 提交于 2021-02-18 17:08:48
问题 I'm trying to convert a 64 bit hexadecimal number to a float in PHP. 40F82C719999999A If I run that in the IEEE-754 Floating-Point Conversion page at http://babbage.cs.qc.cuny.edu/IEEE-754.old/64bit.html it converts to: 99015.100000000000 Which is the number I'm looking for. But I can't get to this number in PHP. I've tried using various combinations of pack() and unpack() but I'm not anywhere close. :( 回答1: function hex2float($strHex) { $hex = sscanf($strHex, "%02x%02x%02x%02x%02x%02x%02x