Monday, 9 April 2018

How to set min height by Jquery

$j(document).ready(function(){
$j('.progrdCol').each(function() {
        startListHeight($j('.progrdCol > .productRap'));
    });
});

function startListHeight($tag) {
 
    function setHeight(s) {
        var max = 0;
        s.each(function() {
            var h = $j(this).height();           
            max = Math.max(max, h);
        }).height('').height(max);
    }
 
    $j(window).on('ready load resize', setHeight($tag));
}

Friday, 6 April 2018

How to Add Social Sharing Links for a Product in Magento 2

How to Add Social Sharing Links for a Product in Magento 2


<div class="wdm-social-icons" data-role="wdm-social-icons">

<!-- FACEBOOK -->
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo urlencode($_product->getProductUrl());?>&t=<?php echo urlencode($_product->getName())?>" onclick='javascript:window.open(this.href,"","width=640,height=480,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes");return false' title="Share on FaceBook">
<img src="<?php echo $this->getViewFileUrl('images/fb-med.png'); ?>" alt="FaceBook" width="5%">
</a>

<!-- TWITTER -->
<a href="http://twitter.com/home/?status=<?php echo urlencode($_product->getProductUrl());?>(<?php echo urlencode($_product->getName())?>)" onclick='javascript:window.open(this.href,"","width=640,height=480,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes");return false' title="Share on Twitter">
<img src="<?php echo $this->getViewFileUrl('images/tw.png'); ?>" alt="Twitter" width="5%">
</a>

</div>

Tuesday, 3 April 2018

How to Increase / decrease qty directly on cart page in magento 1.9

How to Increase / decrease qty directly on cart page in magento 1.9

First, I give an id (form-update-post) to the form of the cart page : (app/design/frontend/rwd/default/template/checkout/cart.phtml)

<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="form-update-post">

    Then, I add two buttons, and I add an id to the qty field of the items : (checkout/cart/item/default.phtml)

<a href="javascript:decreaseQty(<?php echo $_item->getId() ?>)" class="decrement_qty"><span class="fa fa-minus">-</span></a>
<input id="quantity-item-<?php echo $_item->getId() ?>" name="cart[<?php echo $_item->getId() ?>][qty]"
   data-cart-item-id="<?php echo $this->jsQuoteEscape($_item->getSku()) ?>"
   value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />
<a href="javascript:increaseQty(<?php echo $_item->getId() ?>)" class="increment_qty"><span class="fa fa-plus">+</span></a>

The last step is to add those Javascript functions in the cart page : (checkout/cart.phtml)

<script type="text/javascript">
    function increaseQty(id){
        var input = jQuery("#quantity-item-"+id);
        input.val(parseInt(input.val())+1);
        var form = jQuery("#form-update-post");
        if(form !== undefined){
            form.submit();
        }
    }

    function decreaseQty(id){
        var input = jQuery("#quantity-item-"+id);
        if(input.val() > 1){
            input.val(input.val()-1);
        }
        var form = jQuery("#form-update-post");
        if(form !== undefined){
            form.submit();
        }
    }
</script>

Increment and decrement qty button on shopping cart page in magento 1.9

Increment and decrement qty button on shopping cart page in magento 1.9

        <div class="qty-wrapper">
            <label for="qty"><?php echo $this->__('Quantity:') ?></label>
            <div class="qty-box">
                 <?php if(!$_product->isGrouped()): ?>
                    <a class="minus" id="<?php echo $_product->getId() . "minus" ?>" href="javascript:void(0);">-</a>
                    <input type="text" readonly="true" name="qty" id="qty<?php echo $_product->getId() ?>" maxlength="12" value="<?php echo ($_product->getStockItem()->getMinSaleQty() ? $_product->getStockItem()->getMinSaleQty() : 1) ?>" />
                    <a class="plus" id="<?php echo $_product->getId() . "plus" ?>"  href="javascript:void(0);">+</a>
                <?php endif; ?>
            </div>
        </div>


----------------------------------------------------
<script type="text/javascript">
$j(document).ready(function() {
    $j(".minus").click(function() {
        var id = this.id;
        var value = $j('#' + id).next('input').val();
        var fieldID = $j(this).next('input').attr("id");
        if (value > 1) {
            value = value - 1;
            $j('#' + fieldID).val(value);
        }
    });
    $j(".plus").click(function() {
        var id = this.id;
        var value = $j('#' + id).prev('input').val();
        var fieldID = $j(this).prev('input').attr("id");
        ++value;
        $j('#' + fieldID).val(value);
    });
});
</script>



Thursday, 29 March 2018

How to remove compare, adto wishlist, sku in magento 2

<referenceBlock name="catalog.compare.sidebar" remove="true"/>
    <referenceBlock name="view.addto.compare" remove="true" />
    <referenceBlock name="view.addto.wishlist" remove="true" />

    <referenceBlock name="product.info.sku" remove="true"/>


================= All remove sidebar =============
<referenceContainer name="sidebar.additional" remove="true" />

================== wishlist remove sidebar============
<referenceBlock name="wishlist_sidebar" remove="true" />


Move short description below page product detail title via XML magento 2


app/design/frontend/webguru/mifitness/Magento_Catalog/layout/catalog_product_view.xml

Move short description below page product detail title via XML magento 2
<move element="product.info.overview" destination="product.info.main" before="product.info"/>

Magento 2: Safe and easiest way to disable Compare products & Wishlist Module

Magento 2: Safe and easiest way to disable Compare products & Wishlist Module
<referenceBlock name="view.addto.compare" remove="true" />