Add an expiration date to orders based on order items count in WooCommerce

Add an expiration date to orders based on order items count in WooCommerce on your child site.

Snippet Type

Execute on Child Sites

Snippet

add_action( 'woocommerce_checkout_create_order', 'add_expiration' );
function add_expiration( $order, $data ) {
    $items_count  = WC()->cart->get_cart_contents_count();

    $order->update_meta_data('expiration_date', date( 'Y-m-d H:i:s', strtotime( '+'. ( $items_count * 15 ) .' days' ) ) );
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.