Tuesday 15 August 2017

Switch Case In Jquery With Id name

Here is the working script for Switch Case In Jquery With Id name :

$(".btn").click(function () {

switch ($(this).attr('id')) {

case 'id1':

{
//query

break;

}
case 'id2':

{
//query

break;

}

}

});

Add click event on dynamic generated elements with jquery

Here is the working jQuery script:

jQuery('#div').on('click', '.class', function() {
//alert("");
});

Add style to div on mouseover effect with query

Here is the working  jquery code:

jQuery("#div").mouseover(function() {
jQuery(this).css({ "background": "#ffffff", "box-shadow": "0 -1px 4px -1px rgba(0, 0, 0, 0.3)", "position": "relative", "z-index": "999999999", "border-radius": "none" }); });

Get Image, Iframe source link on button click with jquery

Here is the working script:

jQuery(".btn").click(function() {
var iframesrc = jQuery(this).find("iframe").attr("src");
var imagesrc = jQuery(this).find("img").attr("src");
});

Show and hide menu navigation on window scroll with jquery

Here is the jquery script for Show and hide menu navigation on window scroll wih jquery :

jQuery(window).scroll(function() { 
if (jQuery(document).scrollTop() > 50) 
{
 jQuery('nav').addClass('shrink'); }
 else 

jQuery('nav').removeClass('shrink');
 }
 });

WORDPRESS: DISABLE WORDPRESS EMOJI

Here it the working code and you need to add this into your functions.php file::

function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' );
}

add_action( 'init', 'disable_emojis' );

WOOCOMMERCE HOOK - CHECKOUT: CHANGE INPUT LABELS AND PLACEHOLDERS AND THIER DISPLAY

Here it the working code and you need to add this into your functions.php file:


add_filter('woocommerce_checkout_fields', 'custom_override_checkout_fields');
function custom_override_checkout_fields($fields)
{
unset($fields['billing']['billing_address_2']);
$fields['billing']['billing_company']['placeholder'] = 'Business Name';
$fields['billing']['billing_company']['label'] = 'Business Name';
$fields['billing']['billing_first_name']['placeholder'] = 'First Name';
$fields['shipping']['shipping_first_name']['placeholder'] = 'First Name';
$fields['shipping']['shipping_last_name']['placeholder'] = 'Last Name';
$fields['shipping']['shipping_company']['placeholder'] = 'Company Name';
$fields['billing']['billing_last_name']['placeholder'] = 'Last Name';
$fields['billing']['billing_email']['placeholder'] = 'Email Address ';
$fields['billing']['billing_phone']['placeholder'] = 'Phone ';
return $fields;

}

WOOCOMMERCE - CART: REDIRECT EMPTY CART TO EMPTY CART PAGE

Here it the working code and you need to add this into your functions.php file:

WOOCOMMERCE HOOK- CART: REDIRECT EMPTY CART TO EMPTY CART PAGE


add_action("template_redirect", 'redirection_function');
function redirection_function()
{
global $woocommerce, $woocommerce_errors;
if (is_cart() && sizeof($woocommerce->cart->cart_contents) == 0)
{
wp_safe_redirect(get_permalink(get_page_by_path('cart/cart-empty')));
}
}

WOOCOMMERCE - CART: HIDE COUPON ON CHECKOUT PAGE

Here it the working code and you need to add this into your functions.php file:

remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );

WOOCOMMERCE: REMOVE THE .00 TRAILING ZERO'S FROM PRICES

Here it the working code and you need to add this into your functions.php file:

add_filter( 'woocommerce_price_trim_zeros', 'wc_hide_trailing_zeros', 10, 1 );
function wc_hide_trailing_zeros( $trim ) {
    return true;
}

Custom Queries In laravel

Here are the Custom Queries In laravel, please check it:

1. Date Format in laravel:

DB::raw('DATE_FORMAT(orders.timestamp_order_made, "%m/%d/%Y") as order_date')


2. Case Statement In Laravel

DB::raw("
                    CASE orders.status
                        WHEN '1' THEN 'Order Placed'
                        WHEN '2' THEN 'Allocated'
                        WHEN '3' THEN 'Rejected'
                        WHEN '4' THEN 'Failure'
                        WHEN '5' THEN 'Accepted'
                        WHEN '6' THEN 'Delivered'
                        WHEN '7' THEN 'Accepted by dispensary'
                        WHEN '8' THEN 'Pickup at dispensary'
                        ELSE 'NO'
                        END as order_status

                ")

3. Concatenation in Laravel:

DB::raw("CONCAT_WS(' ',users.first_name, users.last_name) AS customer_name")


Enjoy☺

Google Map Filter Api Example

Here is Google Map Filter Api Example: