How To Change Out Of Stock Text in Avada Theme
In case you wish to change out of stock message for WooCommerce in Avada Theme, the usual method of adding code snippet similar to one given below will not work for Avada Theme
Code To Change Out of Stock Text in Normal Usual WordPress Theme
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
// Change In Stock Text
if ( $_product->is_in_stock() ) {
$availability['availability'] = __('Available!', 'woocommerce');
}
// Change Out of Stock Text
if ( ! $_product->is_in_stock() ) {
$availability['availability'] = __('Sold Out', 'woocommerce');
}
return $availability;
}
Code to Change Out of Stock Text for WooCommerce in Avada Theme
In case you wish to change the out of stock tet specially for Avada Theme, you need to edit Avada Template files. You can create a Child Theme as well for Avada Theme and add the following file to location
wp-content/themes/Avada/templates/wc-product-loop-outofstock-flash.php
The edited php file code will be
<?php
/**
* Out of stock flash template
*
* @author ThemeFusion
* @copyright (c) Copyright by ThemeFusion
* @link https://theme-fusion.com
* @package Avada
* @subpackage Core
* @since 5.1.0
*/
global $product;
?>
<?php if ( ! $product->is_in_stock() ) : ?>
<div class="fusion-out-of-stock">
<div class="fusion-position-text">
<?php esc_attr_e( 'Sold', 'Avada' ); ?>
</div>
</div>
<?php endif; ?>
The text ‘Sold’ Avada can be modified/ replaced with whatever out of stock text message you want for Avada Theme.