1. Home
  2. Knowledge Base
  3. WooCommerce Members Only
  4. Add expiry date to product page
  1. Home
  2. Knowledge Base
  3. Advanced
  4. Add expiry date to product page

Add expiry date to product page

You can use the following snippet to display details of a product’s expiration date:

<?php
/**
* Add expiry date to product page
*/
function prefix_show_expiration_period() {
$product_id = get_the_ID();
$expires_after_value = get_post_meta( $product_id, 'wcmo_product_expires_after_value', true );
$expires_after_period = get_post_meta( $product_id, 'wcmo_product_expires_after_period', true );
if( $expires_after_value && $expires_after_period ) {
echo 'Expires after ' . $expires_after_value . ' ' . $expires_after_period;
}
}
add_action( 'woocommerce_single_product_summary', 'prefix_show_expiration_period', 15 );

How to add a snippet.

Was this article helpful?

Need More Support?

If you can't find the answer that you're looking for, then please use the link below to raise a support ticket.
Contact Support

Related Articles