Skip to content

Instantly share code, notes, and snippets.

@Niloys7
Created August 9, 2021 20:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Niloys7/885ea0b97339298fdce129359219e69c to your computer and use it in GitHub Desktop.
Update preorder date programmatically for Variable products
add_action('wp_head','bp_preorder_script');
function bp_preorder_script() {
$args = array(
'post_type' => 'product_variation',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
foreach ( $query->posts as $key => $vp ) {
update_post_meta( $vp->ID, '_is_pre_order', 'yes' );
update_post_meta( $vp->ID, '_pre_order_date', '2021-04-15' ); // change date with same format
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment