Custom User Fields on Woocommerce My Account Page

In below example, we’re going to update the user’s Phone and FB Url information with add field on User My account page in Woocommerce


add_action( ‘woocommerce_edit_account_form’, ‘my_woocommerce_edit_account_form’ );
add_action( ‘woocommerce_save_account_details’, ‘my_woocommerce_save_account_details’ );

function my_woocommerce_edit_account_form() {

$user_id = get_current_user_id();
$user = get_userdata( $user_id );

if ( !$user )

$phone_no = get_user_meta( $user_id, ‘_phone_no’, true );
$fb_username = get_user_meta( $user_id, ‘_fb_username’, true );

<p class=”form-row form-row-thirds”>
<label for=”twitter”>Phone  *</label>
<input type=”text” name=”phone_no” value=”<?php echo esc_attr( $phone_no ); ?>” class=”input-text” />

<p class=”form-row form-row-thirds”>
<label for=”url”>FB Username</label>
<input type=”text” name=”fb_username” value=”<?php echo esc_attr( $fb_username ); ?>” class=”input-text” />



function my_woocommerce_save_account_details( $user_id ) {

update_user_meta( $user_id, ‘_phone_no’, htmlentities( $_POST[ ‘phone_no’ ] ) );
update_user_meta( $user_id, ‘_fb_username’, htmlentities( $_POST[ ‘fb_username’ ] ) );
//$user = wp_update_user( array( ‘ID’ => $user_id, ‘user_url’ => esc_url( $_POST[ ‘url’ ] ) ) );



Display message or specific content on Single Product Page after Product detail in Woocommerce

Display custom message or specific content on all Woocommerce Single Product Page after Product detail using Woocommerce filter action without modify Theme or Wocommerce single product page scripting.

Add below script in your active theme functions.php file

function ls_fn_custom_msg($atts, $content = null)
echo ‘Add your custom message or content that you want to show on Single Product Page’;
return ob_get_clean();
add_action( ‘woocommerce_after_single_product_summary’, ‘ls_woocommerce_msg_after_single_product_page’, 15 );
function ls_woocommerce_msg_after_single_product_page() {
echo do_shortcode(‘[ls_custom_msg]’);

Change Product Sale badge WooCommerce

Hello WooCommerce fan
You don’t like the Sale text badge that WooCommerce prints on your sale discounted price products? and want to display something other message than Sale

Than dont worry!  You can quickly change that text by whatever you want, or you can show the discounted percentage or Save amount base on different of Original Price and Sale (Discounted ) price.

If you would like to show dynamically percent of discount amount or saving number than you may contact us by visit Lathiya WordPress Solutions.

Here im going to show how you can easily replace default Sale text of Woocommerce Product by something other more interesting text like ‘Special’ ‘Hot Sale’ ‘Best Price’ etc etc

To change product Sale flash text in WooCommerce open your active theme functions.php file that located in wp-content/themes/your-active-theme-name/ and add below code at the end of it:

add_filter( ‘woocommerce_sale_flash’, ‘wc_custom_replace_sale_text’ );
function wc_custom_replace_sale_text( $html ) {
return str_replace( __( ‘Sale’, ‘woocommerce’ ), __( ‘Special’, ‘woocommerce’ ), $html );

Note :  In your site if by default display flash text is like Sale! instead of Sale  than your code little change like

add_filter( ‘woocommerce_sale_flash’, ‘wc_custom_replace_sale_text’ );
function wc_custom_replace_sale_text( $html ) {
return str_replace( __( ‘Sale!’, ‘woocommerce’ ), __( ‘Special’, ‘woocommerce’ ), $html );


Get Records Between Lat Long Radius in WordPress & Php Mysql

Current article is very helpful for developers who are familiar with WordPress or with PHP/MySQL, and want to do something like below task with their website or application.
> Geographical proximity query with post_meta in WordPress
> Find list of record that comes between latitude longitude radius area in wordpress & Php MySql
> Querying within longitude and latitude in MySQL
> Find points within a distance using MySQL
> Fetch WordPress posts record by proximity to a latitude and longitude radius circle

After reading this article you know well how to display list of records that is either Shop list, User list or anything who given you their location by latitude and longitude during registration / entry time. and you want to list out them based on specific radius latitude and longitude area.

here you can see Best article by Google on Creating a Store Locator with PHP, MySQL & Google Maps

Download complete example script Click me to Download


In Php & MySql

Step – 1

Create Database with table markers by hit below mysql query in PhpMyadmin

CREATE TABLE `markers` (
`name` VARCHAR( 60 ) NOT NULL ,
`address` VARCHAR( 80 ) NOT NULL ,
`lat` FLOAT( 10, 6 ) NOT NULL ,
`lng` FLOAT( 10, 6 ) NOT NULL

Step – 2

Add some records into your created Table markers

INSERT INTO `markers` (`name`, `address`, `lat`, `lng`) VALUES ('Frankie Johnnie & Luigo Too','939 W El Camino Real, Mountain View, CA','37.386339','-122.085823');
INSERT INTO `markers` (`name`, `address`, `lat`, `lng`) VALUES ('Amici\'s East Coast Pizzeria','790 Castro St, Mountain View, CA','37.38714','-122.083235');
INSERT INTO `markers` (`name`, `address`, `lat`, `lng`) VALUES ('Kapp\'s Pizza Bar & Grill','191 Castro St, Mountain View, CA','37.393885','-122.078916');
INSERT INTO `markers` (`name`, `address`, `lat`, `lng`) VALUES ('Round Table Pizza: Mountain View','570 N Shoreline Blvd, Mountain View, CA','37.402653','-122.079354');
INSERT INTO `markers` (`name`, `address`, `lat`, `lng`) VALUES ('Tony & Alba\'s Pizza & Pasta','619 Escuela Ave, Mountain View, CA','37.394011','-122.095528');
INSERT INTO `markers` (`name`, `address`, `lat`, `lng`) VALUES ('Oregano\'s Wood-Fired Pizza','4546 El Camino Real, Los Altos, CA','37.401724','-122.114646');

Step – 3
Create .php file and add following code

$con=mysql_connect("localhost","root","")or die(mysql_error());
die('connect fail ' . mysql_error());

$clat = 37.387138;
$clng =-122.083237;
$radius = 10;

$query = “SELECT address, name, lat, lng, ( 3959 * acos( cos( radians(‘”.$clat.”‘) ) * cos( radians( lat ) ) * cos( radians( lng ) – radians(“.$clng.”) ) + sin( radians(“.$clat.”) ) * sin( radians( lat ) ) ) ) AS distance
FROM markers HAVING distance < ‘”.$radius.”‘ ORDER BY distance LIMIT 0 , 20″;

$result = mysql_query($query);

while ($row = @mysql_fetch_assoc($result)){

In WordPress

With WordPress you store Shop list or something like any records by custom post type and save their location in format of latitude and longitude into post_meta with specific key.

Now you want to display records that comes under specific radius (Between Latitude and Longitude ) than below custom query help you to fetch list of records.


$lat = 21.1702401;
$long = 72.83106070000008;
$radius = 30;
$sql = “SELECT ID, (
6371 * acos (
cos ( radians( $lat) )
* cos( radians( latitude.meta_value ) )
* cos( radians( longitude.meta_value ) – radians($long) )
+ sin ( radians($lat) )
* sin( radians( latitude.meta_value ) )
) AS distance
FROM $wpdb->posts
INNER JOIN $wpdb->postmeta latitude
ON (ID = latitude.post_id AND latitude.meta_key = ‘jv_item_lat’)
INNER JOIN $wpdb->postmeta longitude
ON (ID = longitude.post_id AND longitude.meta_key = ‘jv_item_lng’)
HAVING distance < $radius ORDER BY distance LIMIT 0,6”; $rw = $wpdb->get_results( $sql);


Displaying Categories list – Custom post type texonomy list in wordpress by shortcode

with below shortcode ypu can Displays list of your custom post type Categories in a grid. The categories can be displayed in two modes. Either just the most top categories or categories and sub categories underneath.

Display top categories in specific count columns and do not display total count
of post

[cpt_categories show=”top” columns=”4″ show_count=”0″]

Display all categories in specific count columns, display max. 5 sub categories for each top category and than View all category link

[cpt_categories show=”all” columns=”4″ sub_count=”5″]

To see complete code .. click me



add_shortcode(‘cpt_categories’, ‘shortcode_cpt_categories’);
function shortcode_cpt_categories( $atts ) {

‘name’ => ‘default’,
‘show’ => ‘top’,
‘columns’ => 4,
‘show_count’ => true,
‘sub_count’ => 5

), $atts));

$columns = “flexbox-columns-” . (int)$columns;

if($show != ‘top’) {$show = ‘all’;}

$terms = get_terms( ‘cpt_category_name’, array(
‘hide_empty’ => 0,
‘parent’ => null,
) );

wp_enqueue_style( ‘add_here_css_file_if_need’);

if(!empty($terms)): ?>

slug ?>”> “>
name) ?>

<?php endforeach; ?>
<?php else: ?>

<?php endif;

if(!empty($terms)): ?>

slug ?>”> “>
name) ?>

<?php endforeach; ?>
else: ?>

<?php endif;
return ob_get_clean();




iPhone ios Safari / Web App Viewport Problem (expands to fit all elements in view)

Fetching viewport issue in iPhone specific device which is looking perfect in other devices like Desktop, Android etc. than it might issue due to your page viewport setting.

with add following script to your page your page view port set correct for as it needed for iPhone device screen.


if(/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){

document.querySelector(‘meta[name=viewport]’).setAttribute(‘content’, ‘initial-scale=1.0001, minimum-scale=1.0001, maximum-scale=1.0001, user-scalable=no’);

Add Fusion Page Builder support to New Create Custom Post Type in Avada theme

Hi WordPress Developer

Are you using WordPress top selling Avada theme ? To add some specif article / category post you want to create custom post type ? than might be my following sharing for Add Fusion Page Builder support to New Create Custom Post Type in Avada theme become helpful for you.

In Custom Post type new post Fusion Page builder by default not shows. than if you want to add it and use fusion page builder to add content in your newly created custom post type than you have to made following support related change in Fusion Core page builder plugin files.

Go to fusion-core plugin folder inside /wp-content/plugins/fusion-core/

than admin/class-pagebuilder.php

Now go to line 53

var $allowed_post_types = array(‘page’,’post’,’avada_faq’,’avada_portfolio’,’add_your_cpt’);