Magento 2 icons not showing on frontend and backend

It seems that some css and fonts files are not generated properly. You need to do the folowing

Remove entire files and folder under pub/static except .htaccess file

Open up app/etc/di.xml find the path

Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink

and replace it with

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy
Advertisements

Update cart in magento using update button

jQuery(“.btn-update”).click(function(){
var baseUrl = ‘<?php echo Mage::getBaseUrl(); ?>’;
var id = “#c”+this.id;
var quan = jQuery(id).val();
var lastChar = id.substr(id.length – 1);
var pagename = jQuery(this).attr(‘data-page’);
var onepageUrl = ‘<?php echo Mage::getBaseUrl(); ?>onepage’;
jQuery.ajax({
url: “<?php echo Mage::getBaseUrl(); ?>checkout/cart/updatePosts/”,
data: “cart[“+lastChar+”][qty]=”+quan,
async: false,
beforeSend: function(){

jQuery(‘.btn-update’).html(‘<img src=”‘+baseUrl+’ip-loader.gif”>’);
//jQuery(‘.btn-update’).css(‘top’,’-4px’);
},
success: function(html){
if(pagename==’onepage’){
sendonpage();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {

if(textStatus==’error’){
if(pagename==’onepage’){
sendonpage();
}
}

}
});
});

Update cart using Ajax in Magento

var form = jQuery(“.cart-products form”);
jQuery.ajax({
url: form.attr(‘action’),
method: form.attr(‘method’),
data: form.serializeArray(),
async:false,
beforeSend: function(){
jQuery(“.cart-amount #chkbtn”).html(‘<img src=”‘+baseUrl+’ip-loader.gif”>’);
},
success: function(res){
var totalval =  jQuery(res).find(“.cart-amount input[name=’total’]”).val();
jQuery(“.cart-amount input[name=’total’]”).val(totalval);
jQuery(“.cart-final-price .right .price”).html(totalval);
jQuery(“.cart-amount #chkbtn”).html(‘CHECKOUT’);

}
});

How to use word limit


<?php
echo mb_strimwidth("Hello World", 0, 10, "...");

//Output: Hello W...

Note:- if intl extension is commented in php.ini file then You need to enable the intl extension in php just as the error says. In your php.ini file, uncomment the line extension=php_mbstring.dll or something like this.

How to get price amount in words


<?php
$f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
echo $f->format(311.45);

//Output: three hundred eleven point four five

Note:- if intl extension is commented in php.ini file then You need to enable the intl extension in php just as the error says. In your php.ini file, uncomment the line extension=ext/php_intl.dll or something like this.

How to Show Parent with child Categories

<?php

$args = array(
‘orderby’       => ‘term_order’,
‘order’         => ‘ASC’,
‘hide_empty’    => true,
‘show_count’ => true,
‘parent’         => 0);
$terms = get_terms(‘eventcategory’, $args);
if(!empty($terms)):
foreach($terms as $cat):
echo ‘<h6>’ . $cat->name . ‘</h6><ul class=”large-block-grid-1 medium-block-grid-1 small-block-grid-1″>’;
$args2 = array(
‘orderby’       => ‘term_order’,
‘order’         => ‘ASC’,
‘show_count’ => true,
‘hide_empty’    => true,
‘parent’         => $cat->term_id);
$terms2 = get_terms(‘eventcategory’, $args2);

foreach($terms2  as $child_cat):
echo ‘<li><a href=”‘.get_term_link( $child_cat->slug, $child_cat->taxonomy).'”>’.ucfirst($child_cat->name).'</a></li>’;
endforeach;
echo “</ul>”;
endforeach;
endif;

?>

How to Use Ajax in WordPress

jQuery(‘#quick_enquiry_form’).submit(function(e){

var ajaxurl = “<?php echo admin_url(‘admin-ajax.php’); ?>”;
var quickfrm = jQuery(“#quick_enquiry_form”).serialize();

var name = jQuery(‘#name’).val();
var cname = jQuery(‘#cname’).val();
var email = jQuery(‘#email’).val();
var quick = jQuery(‘#quick’).val();
var error = false;

e.preventDefault();

jQuery.ajax({
type: ‘post’,
url: ajaxurl,
data: quickfrm+’&action=quick_enquiry’,
async: false,
beforeSend: function(){
jQuery(‘.btn’).html(‘Sending…’);
},
success: function(data) {
data = data.substring(0,data.length-1);
jQuery(“#quick_enquiry_form”).fadeOut(‘ease’,function(){
jQuery(“#quick_enquiry_form”).html(data);
jQuery(“#quick_enquiry_form”).fadeIn(‘ease’);
});
}
});
})

/************Function.php**************************/

add_action(‘wp_ajax_quick_enquiry’, ‘quick_enquiry’);
add_action(‘wp_ajax_nopriv_quick_enquiry’, ‘quick_enquiry’);

function quick_enquiry()
{

echo $_POST[’email’];

}