Skip to content

Instantly share code, notes, and snippets.

@navalon
Forked from acanza/wc-custom-stock-message.php
Created October 29, 2016 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navalon/3f5dba3b34d8fa9ba8d340665b65e541 to your computer and use it in GitHub Desktop.
Save navalon/3f5dba3b34d8fa9ba8d340665b65e541 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