Add Woocommerce Pre-Order availability date under Single Product Short Description in Woocommerce

205 Views Asked by At

I'm trying to reposition the Woocommerce Pre-Order availability date under the Single Product Short Description.

I found an answer here that lets me place text in the correct place, but I can't work out how to call the Pre-Order availability date.

I've tried and failed with this:

// Reposition Woocomerce Pre-Order Availability Date
add_filter( 'woocommerce_short_description', 'woo_add_text_after_excerpt_single_product', 20, 1 );

function woo_add_text_after_excerpt_single_product( $post_excerpt ){
if( is_product() && has_term( array( 'Comic Book Pre-orders', 'DC Comics Pre-orders', 'Marvel Comics Pre-orders', 'Other Publisher Pre-orders' ), 'product_cat' ) ) {
    global $product;
        $message = $product->get_meta( '_wc_pre_orders_availability_datetime', true );
             $post_excerpt .= '<p class="pre-order-date"><strong>Release date: </strong>'.date( 'F d, Y', strtotime( $message ) ).'</p>';
    }
    return $post_excerpt;
}

Any suggestions will be very much appreciated!

*Update: Okay, so I've found the function used in the pre-orders plugin to place the availability messge:

add_action( 'woocommerce_single_product_summary', array( $this, 'add_pre_order_product_message' ), 11 );

However when I switched 'woocommerce_single_product_summary' for 'woocommerce_short_description' as a test, while the details were placed where I wanted them they overwrote the short desription rather than adding to it... haha!

So first, is there a way I can overright the add_action from the plugin via my functions.php file, and if so can I also alter it so it doesn't replace the short description?

Thanks again for any suggestions you might have!

1

There are 1 best solutions below

0
JapeNZ On

I've given up and switched to the free version of Yith Pre Orders as it places the details where I want by default :)