I have moved the product description before the variations (customized) and before the "Add to Cart" button with the hook "woocommerce_before_add_to_cart_form". good results.
The problem is that if the product is not in stock by me, then this hook does not fire at all and the product description never displays.
How to add description before variations and on out of stock products?
P粉2036487422024-03-30 11:46:00
I solved this problem now with two different codes. But the idea is to achieve this using only one hook. To use only woocommerce_single_product_summary, place the description below the "Add to Cart" button.
This code adds product descriptions for out-of-stock products:
add_action( 'woocommerce_single_product_summary', 'visa_produktbeskrivning', 40 ); function visa_produktbeskrivning() { global $product; if ( ! $product->is_in_stock() ) { echo '<div itemprop="description">'; echo apply_filters( 'the_content', $product->description ); echo '</div>'; } }
This code adds product descriptions for in-stock products:
add_action( 'woocommerce_before_add_to_cart_button', 'display_custom_field' ); function display_custom_field() { global $product; echo '<div itemprop="description">'; echo apply_filters( 'the_content', $product->description ); echo '</div>'; }