Last active
October 27, 2017 03:59
-
-
Save acanza/295a6ecc3d09fb41a3c9 to your computer and use it in GitHub Desktop.
Modifica el texto de aviso de stock en la ficha de producto
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
// Personaliza texto stock bajo | |
add_filter( 'woocommerce_stock_html', 'custom_stock_message', 10, 3 ); | |
function custom_stock_message( $availability_html, $stock, $product ){ | |
$num_items_in_stock = $product->total_stock; | |
$availability = $product->get_availability(); | |
if ( $product->total_stock <= get_option( 'woocommerce_notify_low_stock_amount' ) ) { | |
$new_availability_html = '<p class="stock" style="color: #EA4242;margin-top: 5px;"> ¡Date prisa! Solo nos quedan ' . $num_items_in_stock . ' unidades</p>'; | |
}else{ | |
$new_availability_html = empty( $stock ) ? '' : '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $stock ) . '</p>'; | |
} | |
return $new_availability_html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment