Redesigned 'Out of Stock” Notification for WooCommerce Variable Products
P粉604848588
P粉604848588 2023-08-13 12:09:07
0
1
421

We have a WooCommerce store with a lot of variable products and have added custom text for the stock status. I have successfully changed all the different stock statuses when the attribute is selected, but cannot change the status when there aren't any variable products. That is, "This product is currently out of stock and not available" text.

https://sykleriet.no/produkt/specialized-turbo-levo-comp-alloy/

I've added a fragment to control these statuses; in stock, out of stock and pre-order, thanks for the help here, I've also tried various other fixes and only changed the last one as a standalone fragment, the same as we used for Fragments used together with other fragments - deactivated. Currently, it seems I can't change this text.

Is it possible to add a string in this code or create a separate code for this purpose?

This is the code we use for other code:

add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2); function wcs_custom_get_availability( $availability, $_product ) { //Change the in-stock text if ( $_product->is_in_stock() ) { $availability['availability'] = __('På lager', 'woocommerce'); } //Change out-of-stock text if ( ! $_product->is_in_stock() ) { $availability['availability'] = __('Utsolgt', 'woocommerce'); } //Change subscription text if ( $_product->is_on_backorder() ) { $availability['availability'] = __('Bestillingsvare 10-15 dager', 'woocommerce'); } return $availability; } 


P粉604848588
P粉604848588

reply all (1)
P粉982054449

The code you need to customize the text "This product is currently out of stock and cannot be purchased" is as follows:

add_filter('woocommerce_out_of_stock_message', 'custom_wc_out_of_stock_message'); function custom_wc_out_of_stock_message() { return __('该产品缺货且无法购买。请联系我们以获取即将到货的信息。', 'woocommerce'); }

Add this code to your current theme’s functions.php file (or a plugin).

woocommerce_out_of_stock_messageFilter hooklocation in WooCommerce code

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!