Skip to content

Instantly share code, notes, and snippets.

View krillo's full-sized avatar
😼
Happy

Kristian Erendi krillo

😼
Happy
View GitHub Profile
@krillo
krillo / Magento2 get cart subtotal formated
Created December 22, 2017 15:31
Magento2 get cart subtotal formated
<?php
$helper = $this->helper('\Magento\Checkout\Helper\Cart');
$subtotal = $helper->getQuote()->getSubtotal();
$subtotalHtml = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency($helper->getQuote()->getSubtotal(), true, true);
$grandtotalHtml = $this->helper('Magento\Framework\Pricing\Helper\Data')->currency($helper->getQuote()->getGrandTotal(), true, true);
?>
Show static block on:
----------------------------
cms-page
{{block class="Magento\\Cms\\Block\\Block" block_id="cpa-usp-block"}}
phtml
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('lilly-infobox-2')->toHtml();?>
Get absolute path via $objectManager
-----------------------------------
@krillo
krillo / Magento2 jquery scroll to
Created January 9, 2018 16:13
Magento2 jquery scroll to
<script type="text/javascript">
require(['jquery'], function (jQuery) {
jQuery(document).ready(function ($) {
$('#cpa-scroll-to-desc').click(function (event) {
event.preventDefault();
$('html,body').animate({
scrollTop: $(".box-collateral").offset().top - 120}, 'slow');
});
});
});
@krillo
krillo / addEventListener.html
Created November 8, 2018 13:28
wait for page to load - vanilla js
<!-- add a function to the event listener of page loded -->
<script>
window.addEventListener("load", function() {
console.log('krillo');
$('#motivation').keypress(function (e) {
console.log('krillo');
}
);
}, true);
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://fb.me/react-with-addons-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.js"></script>
</head>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://fb.me/react-with-addons-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.js"></script>
</head>