Last active
August 29, 2015 14:26
-
-
Save flistefliste/03850acea5391e71bf11 to your computer and use it in GitHub Desktop.
Prepend "0" to product weight in WooCommerce when product weight notation is ie. ".19 kg" instead of "0.19 kg"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//prepend "0" to product weight in WooCommerce | |
add_filter( 'woocommerce_product_get_weight', 'prepend_zero' ,100, 1 ); | |
if(!function_exists('prepend_zero')){ | |
function prepend_zero($weight){ | |
//check if first char is a dot "." | |
if (substr($weight, 0, 1) === '.'){ | |
$weight = "0".$weight ; | |
} | |
return $weight ; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment