Skip to content

Instantly share code, notes, and snippets.

@bavington
bavington / translate-fix-mage.xml
Created January 11, 2015 14:57
Magento Local Development Translate Inline Fix
<!-- Add to Local.xml -->
<default>
<reference name="footer">
<block type="core/text" name="translatefix">
<action method="setText">
<text>
<![CDATA[
<script>
if(Object.__defineGetter__)
{
@bavington
bavington / magento-bits.php
Created December 17, 2014 22:46
Magento PHP Bits
<?php
$_product->getData('width'); // Get Attribute value (numeric)
$_product->getAttributeText('range'); // Get Attribute value (dropdown)
?>
@bavington
bavington / woo_reg_price.php
Created December 15, 2014 20:47
WooCommerce Getting the Regular Price
$regular_price = get_post_meta( get_the_ID(), '_regular_price', true);
if ($regular_price == ""){
$available_variations = $product->get_available_variations();
$variation_id=$available_variations[0]['variation_id'];
$variable_product1= new WC_Product_Variation( $variation_id );
$regular_price = $variable_product1 ->regular_price;
}
echo $regular_price;
@bavington
bavington / magento-layout.xml
Last active August 29, 2015 14:09
Magento Layout XML Snippets
<!-- Adding JS or CSS -->
<reference name="head">
<!-- Using add Method -->
<action method="addCss"><stylesheet>css/styles.css</stylesheet></action>
<action method="addJs"><script>prototype/prototype.js</script></action>
<!-- Using addItem Method -->
<action method="addItem"><type>skin_css</type><name>css/styles-ie.css</name><params/><if>lt IE 8</if></action>
<action method="addItem"><type>skin_js</type><name>js/ie6.js</name><params/><if>lt IE 7</if></action>
</reference>
@bavington
bavington / gist:b7d3fd2e321770beecdd
Created September 30, 2014 10:38
Magento Multi-site htaccess
RewriteCond %{HTTP_HOST} ^.*orderofficefurniture\.co\.uk
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.orderofficefurniture.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^.*orderbeds\.co\.uk
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.orderbeds.co.uk/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^.*big-av\.co\.uk
RewriteCond %{THE_REQUEST} ^.*/index.php
@bavington
bavington / woo-checkout-fields.php
Last active May 25, 2021 09:56
Reorder Checkout Fields in WooCommerce
// Reorder Checkout Fields
add_filter('woocommerce_checkout_fields','reorder_woo_fields');
function reorder_woo_fields($fields) {
$fields2['billing']['billing_email'] = $fields['billing']['billing_email'];
$fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name'];
$fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name'];
$fields2['billing']['billing_country'] = $fields['billing']['billing_country'];
$fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1'];
$fields2['billing']['billing_address_2'] = $fields['billing']['billing_address_2'];
@bavington
bavington / jw-video-sitemap.xml
Last active August 29, 2015 14:03
JW Player supporting Video XML Sitemap
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url>
<loc>http://example.com/page-with-video.html</loc>
<video:video>
<video:thumbnail_loc>http://example.com/uploads/myPoster.jpg</video:thumbnail_loc>
<video:title>Video Name or Title</video:title>
<video:description>The description of your video content goes here.</video:description>
<video:content_loc>http://example.com/uploads/myVideo.mp4</video:content_loc>
<video:duration>153</video:duration>
@bavington
bavington / jw-schema.html
Last active August 29, 2015 14:03
Schema.org Video Markup for JW Player
<div id="myElement" itemprop="video" itemscope itemtype="http://schema.org/VideoObject">
<h2 itemprop="name">Video Name or Title</h2>
<meta itemprop="duration" content="00:02:33" />
<meta itemprop="thumbnailUrl" content="http://example.com/uploads/myPoster.jpg" />
<meta itemprop="contentUrl" content="http://example.com/uploads/myVideo.mp4" />
<meta itemprop="uploadDate" content="2014-01-03T08:00:00+08:00" />
<span itemprop="description">The description of your video content goes here.</span>
<script>
jwplayer("myElement").setup({
file: "http://example.com/uploads/myVideo.mp4",
@bavington
bavington / retinize.scss
Created May 1, 2014 12:16
Retinize SASS Mixin
$is-hidpi:" (-webkit-min-device-pixel-ratio: 1.5),
(min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(min-device-pixel-ratio: 1.5),
(min-resolution: 1.5dppx)";
@mixin retinize($file, $type){
background-image: url('images/' + $file + '.' + $type);
@media #{$is-hidpi}{
@bavington
bavington / universal-analytics-event-tracking.js
Created January 11, 2014 14:24
How to use jQuery to track Custom Events like Phone Number and Button clicks with Google Universal Analytics.
jQuery(document).ready(function ($) {
$('#quote').on('click', function() { // Tracks clicks for the <a> tag with id="quote"
ga('send', 'event', 'button', 'click', 'Quick Form Lightbox Impressions');
});
$('#phonenumber').on('click', function() { // Tracks clicks for the <a> tag with id="phonenumber"
ga('send', 'event', 'link', 'click', 'Header Phone Clicks/Touches');
});