-
-
Save navalon/3f5dba3b34d8fa9ba8d340665b65e541 to your computer and use it in GitHub Desktop.
Modifica el texto de aviso de stock en la ficha de producto
This file contains 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