Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.