1. Home
  2. Knowledge Base
  3. WooCommerce Members Only
  4. Advanced Topics for Members Only
  5. Add expiry date to product page
  1. Home
  2. Knowledge Base
  3. WooCommerce Members Only
  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?

Related Articles