Skip to content

Instantly share code, notes, and snippets.

@cargabsj175
Created February 28, 2018 06:11
Show Gist options
  • Save cargabsj175/a739d35654d2c35be2eca1036b4075e2 to your computer and use it in GitHub Desktop.
Save cargabsj175/a739d35654d2c35be2eca1036b4075e2 to your computer and use it in GitHub Desktop.
add_action( 'woocommerce_after_shop_loop_item_title', 'cj_show_dimensions', 9 );
function cj_show_dimensions() {
global $product;
$dimensions = $product->get_dimensions();
if ( ! empty( $dimensions ) ) {
echo '<p style="font-family: CaviarDreams; color: #b3b3b3; text-transform: uppercase; font-weight: bold;" class="dimensions">' . $dimensions . '</p>';
}
}
add_shortcode( 'show_dimensions', 'cj_show_dimensions' );
add_action( 'woocommerce_after_shop_loop_item', 'rs_show_weights', 9 );
function rs_show_weights() {
global $product;
$weight = $product->get_weight();
if ( $product->has_weight() ) {
echo '<p style="font-family: CaviarDreams; color: #b3b3b3; text-transform: uppercase; font-weight: bold;" class="product-meta-label">' . $weight . '&nbsp;' . get_option('woocommerce_weight_unit') . '</p>';
}
}
add_shortcode( 'show_weight', 'rs_show_weights' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment