mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/66762269/add-an-expiration-date-to-woocommerce-orders-based-on-order-items-count/66763519
6 lines
297 B
Text
6 lines
297 B
Text
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' ) ) );
|
|
}
|