Skip to content

Instantly share code, notes, and snippets.

@acanza
Last active October 27, 2017 03:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save acanza/295a6ecc3d09fb41a3c9 to your computer and use it in GitHub Desktop.
Save acanza/295a6ecc3d09fb41a3c9 to your computer and use it in GitHub Desktop.
Modifica el texto de aviso de stock en la ficha de producto
// 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