16 January 2020

How to Hide WooCommerce Product Quantity Field from Product Pages?

Hide WooCommerce Product Quantity Field from Product Pages


www.wpcodekit.com


function quantity_wp_head() {
 
if ( is_product() ) {
    ?>
<style type="text/css">.quantity, .buttons_added { width:0; height:0; display: none; visibility: hidden; }</style>
<?php
    }
}
    add_action( 'wp_head', 'quantity_wp_head' );


Or



add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields');
function cw_remove_quantity_fields( $return, $product ) {
switch ( $product->product_type ) :
case "grouped":
return true;
break;
case "external":
return true;
break;
case "variable":
return true;
break;
default:
return true;
break;
endswitch;
}




Or




function cw_remove_quantity_fields( $return, $product ) {
    return true;
}
add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields', 10, 2 );




How to Hide WooCommerce Product Quantity Field from Product Pagesd_individually', 'cw_remove_quantity_fields', 10, 2 );

04 January 2020

How to fetch file name, extension and basename from url in php?

Fetch file name, extension and basename from url in php

<?php
$file = 'http://localhost/brrrr/wp-content/uploads/2019/11/New-Business-card-4.jpg';
$ext = pathinfo($file);

echo $ext['dirname'] . '<br/>';   // Returns folder/directory
echo $ext['basename'] . '<br/>';  // Returns file.html
echo $ext['extension'] . '<br/>'; // Returns .html
 echo $ext['filename'] . '<br/>';  // Returns file 
?>

How to accept image extension from url in php?

Accept image extension from url in php



<?php
 $file_name = 'http://localhost/brrrr/wp-content/uploads/2019/11/New-Business-card-4.jpg';
echo $file_name."<br>";
$allowed = array('gif', 'png', 'jpg');
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
if (!in_array($ext, $allowed)) {
    echo 'error';
}
else{
echo "this is ok";
}
 

?>

03 January 2020

How to remove spinners from number field(quantity fields ) in woocommerce?

WooCommerce quantity fields without spinners



/* Disable input[type=number] buttons until the world is ready */
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
    display:none;
}


OR




<input type="text" pattern="[0-9]*" ... />

02 January 2020

How to download pdf file on browser instead of saving it on the server in fpdf?

fpdf Output('filename.pdf','F'); downloading file on browser instead of saving it on the server



Output('D','filename.pdf');

How to create elementor popup with code in wordpress?

Create elementor popup with code in wordpress


Use in main-function file

// Add Shortcode
function elementor_poup( $atts ) {

// Attributes
$atts = shortcode_atts(
array(
'id' => '',
),
$atts
);
$etid = $atts['id'];


echo '<div class="elementor-popup-'.$etid.'"><div class="e-popup-content"><div class="eclose"><svg viewBox="0 0 10.6 11"><polygon points="6.3,5.4 10.4,1.4 9.2,0.3 5.3,4.2 1.3,0.3 0.2,1.4 4.3,5.4 0.2,9.5 1.3,10.7 5.3,6.8 9.2,10.7 10.4,9.5 "></polygon></svg></div>';
echo do_shortcode("[elementor-template id=$etid]");
echo '</div></div>';

echo'<style>
.epopup-'.$etid.'
{
cursor:pointer;
}
.elementor-popup-'.$etid.' .eclose
{

    z-index: 99999;
    position: absolute;
    top: 1em;
    right: 1em;
    cursor: pointer;
    line-height: 0;
    border-radius: 50%;
    padding: 10px;
    background: #DDE2EB;
    width: 40px;
    height: 40px;
    fill: #999999;
    -webkit-transition: fill .3s ease-in-out;
    transition: fill .3s ease-in-out;
}
.elementor-popup-'.$etid.'
{
width:100%;
position:fixed;
left:0px;
top:0px;
height:100%;
background:rgba(0, 22, 58, 0.89);
display:none;
align-items:center;
    z-index: 999990000;
}
.elementor-popup-'.$etid.' .e-popup-content section
{
width:100% !important;
}
.e-popup-content
{
width: 100%;
    margin: auto;
position: relative;
}
.eclose svg {
    width: 14px;
    margin: 3px auto;
    display: table;
}

</style>
';
echo '<script>jQuery(document).ready(function($){';
?>

function validateEmail<?php echo $etid; ?>($email) {
  var emailReg = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  return emailReg.test( $email );
}

$('.epopup-<?php echo $etid; ?>').click(function(){
$('.elementor-popup-<?php echo $etid; ?>').css("display","flex");
});



$('.elementor-popup-<?php echo $etid; ?> .eclose').click(function(){
$('.elementor-popup-<?php echo $etid; ?>').css("display","none");
});

$('.epopup-<?php echo $etid; ?> .infusion-recaptcha').click(function(){
alert("before");
var epopemailemail<?php echo $etid; ?> = $('.epopup-<?php echo $etid; ?> .infusion-field-input').val();

if( !validateEmail<?php echo $etid; ?>(epopemailemail<?php echo $etid; ?>)) {
$('.epopup-<?php echo $etid; ?> .infusion-field-input').css("border","1px solid red");
return false;
}
});

<?php
echo '});</script>';

}
add_shortcode( 'elementor-popup', 'elementor_poup' );


Copy only elementor section id 
Design a section


[elementor-template id="6165"]

                    Paste elementor section id in shortcode  


[elementor-popup id="6165"]


          Add class which give you below this line(in elementor)

epopup-6165

31 December 2019

How to fetch instagram posts data?

Fetch Instagram posts data by pasting this code in browser console. (() => { /* ====================================================...