Make price widget draggable on touch devices

Grab this script and save it to the js folder in your theme directory.

Add the following code to your themes functions.php file (remember to make sure the path matches your theme structure) to enqueue it:

[php]
add_action( ‘wp_enqueue_scripts’, ‘load_touch_punch_js’ , 35 );
function load_touch_punch_js() {
global $version;

wp_enqueue_script( ‘jquery-ui-widget’ );
wp_enqueue_script( ‘jquery-ui-mouse’ );
wp_enqueue_script( ‘jquery-ui-slider’ );
wp_register_script( ‘woo-jquery-touch-punch’, get_stylesheet_directory_uri() . "/js/jquery.ui.touch-punch.min.js", array(‘jquery’), $version, true );
wp_enqueue_script( ‘woo-jquery-touch-punch’ );
}
[/php]

Problem solved!

Sticky header jQuery

In order to have a sticky header you need these elements:

[html]

nav here

[/html]

and …

[css]

#header_nav {
width:100%;
height:100px;
background-color:#666;
position:fixed;
top:0;
left:0;
}

[/css]

… and …

[js]

$(function(){
$(‘#header_nav’).data(‘size’,’big’);
});

$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($(‘#header_nav’).data(‘size’) == ‘big’)
{
$(‘#header_nav’).data(‘size’,’small’);
$(‘#header_nav’).stop().animate({
height:’40px’
},600);
}
}
else
{
if($(‘#header_nav’).data(‘size’) == ‘small’)
{
$(‘#header_nav’).data(‘size’,’big’);
$(‘#header_nav’).stop().animate({
height:’100px’
},600);
}
}
});

[/js]

 

Guess what!? It works!

Fix broken product links – found for Mestergull

On 20140711 Mestergull broken product links were reported.

They are saved okay in wp_postmeta table on “_product_attributes” field, but for some reason, when using

[php]

woocommerce_get_product_terms( $product->id, ‘pa_product-link’, ‘names’ );

[/php]

the link was truncated to 168 characters.

So, I coded this:

[php]

$xxx = get_post_meta( $product->id, ‘_product_attributes’);
foreach ($xxx[0] as $pa){
if ($pa[‘name’] == ‘pa_product-link’){
$product_link = $pa[‘value’];
break;
}
}

[/php]

Which fetches the entire product link value.

Move grid list buttons higher

In order to move the two grid/list buttons on top right corner of product listing page I had to edit plugins/woocommerce-grid-list-toggle/grid-list-toggle.php file:

[php]

add_action( ‘woocommerce_before_shop_loop’, array(&$this, ‘gridlist_toggle_button’), 1);

[/php]

Instead of “1” was “30”…