Andrew Ho

MySQL Timestamp in PHP

 

Check if current user has role in WordPress

 

Woocommerce change quantity of product in cart

 

Javascript formatted valuta with a comma as decimal seperator

 

Get posts meta compare WordPress

 

Get price of product in Woocommerce

if( $product->is_type( 'variable' ) ){
				$available_variations = $product->get_available_variations();
				}
				else {
				
				}
				$regularprice = $available_variations[0]['display_regular_price'];
					
				if (!empty( $regularprice)	){
					
				}
				else {
					$regularprice = $product->regular_price;
				}
					$from = $regularprice;
			        $to = $product->price;
			   if ( $product->price > 0 ) {
			      if ( $from <> $to ) {
			       
			        echo '
'.( ( is_numeric( $to ) ) ? woocommerce_price( $to ) : $to ) .'
van '. ( ( is_numeric( $from ) ) ? woocommerce_price( $from ) : $from ) .'
' ; } else { $to = $product->price; echo '
' . ( ( is_numeric( $to ) ) ? woocommerce_price( $to ) : $to ) . '
'; } } else { //NO PRICE }

Nonce in an AJAX request WordPress



var data = {
		action: 'my_action',
		security: '',
		my_string: 'Hello World!'
	};
	$.post(ajaxurl, data, function(response) {
		alert("Response: " + response);
	});




/*AND IN AJAX.php FILE*/
	check_ajax_referer( 'my-special-string', 'security' );


WordPress sql count meta values and group by meta keys

Grayscale image and color on hover

Thanks to this answer: http://stackoverflow.com/questions/7273927/image-greyscale-with-css-re-color-on-mouse-over
[cc lang=”css” escaped=”true” width=”100%” theme=”default” line_numbers=”on” lines=”-1″]
img.grayscale {
filter: url(“data:image/svg+xml;utf8,#grayscale”); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */

/*ANIMATION */
-webkit-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
transition: all 0.3s ease;
}

img.grayscale:hover {
filter: none;
-webkit-filter: grayscale(0%);
}