Skip to content

Instantly share code, notes, and snippets.

@Nishadup
Forked from xadapter/functions.php
Created August 16, 2017 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Nishadup/11ed95d620f497db7a9ca7ef6ae1ded5 to your computer and use it in GitHub Desktop.
Save Nishadup/11ed95d620f497db7a9ca7ef6ae1ded5 to your computer and use it in GitHub Desktop.
Alter WooCommerce Product Weight and Dimension Dynamically
function filter_get_hook_prefix_weight($this_weight, $instance) {
if (!$this_weight || $this_weight < 0.6) $this_weight = .6;
return $this_weight;
}
function filter_get_hook_prefix_height($this_height, $instance) {
if (!$this_height || $this_height < 20 ) $this_height = 20;
return $this_height;
}
function filter_get_hook_prefix_width($this_width, $instance) {
if (!$this_width || $this_width < 20 ) $this_width = 20;
return $this_width;
}
function filter_get_hook_prefix_length($this_length, $instance) {
if (!$this_length || $this_length < 20 ) $this_length = 20;
return $this_length;
}
add_filter("woocommerce_product_get_height", 'filter_get_hook_prefix_height', 19, 2);
add_filter("woocommerce_product_get_width", 'filter_get_hook_prefix_width', 19, 2);
add_filter("woocommerce_product_get_length", 'filter_get_hook_prefix_length', 19, 2);
add_filter("woocommerce_product_get_weight", 'filter_get_hook_prefix_weight', 19, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment