add_filter( 'woocommerce_get_availability_text', 'customizing_stock_availability_text', 1, 2);
function customizing_stock_availability_text( $availability, $product ) {
if ( ! $product->is_in_stock() ) {
$availability = __( 'Fullbokat!', 'woocommerce' );
}
elseif ( $product->managing_stock() && $product->is_on_backorder( 1 ) )
{
$availability = $product->backorders_require_notification() ? __( 'Endast restnoteringar', 'woocommerce' ) : '';
}
elseif ( $product->managing_stock() )
{
$availability = __( 'Tillgängligt', 'woocommerce' );
$stock_amount = $product->get_stock_quantity();
switch ( get_option( 'woocommerce_stock_format' ) ) {
case 'low_amount' :
if ( $stock_amount <= get_option( 'woocommerce_notify_low_stock_amount' ) ) {
/* translators: %s: stock amount */
$availability = sprintf( __( 'Bara %s platser kvar!', 'woocommerce' ), wc_format_stock_quantity_for_display( $stock_amount, $product ) );
}
break;
case '' :
/* translators: %s: stock amount */
$availability = sprintf( __( '%s platser kvar!', 'woocommerce' ), wc_format_stock_quantity_for_display( $stock_amount, $product ) );
break;
}
if ( $product->backorders_allowed() && $product->backorders_require_notification() ) {
$availability .= ' ' . __( '(Kan beställas via restnotering)', 'woocommerce' );
}
}
else
{
$availability = '';
}
return $availability;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter