Created
August 9, 2021 20:04
-
-
Save Niloys7/885ea0b97339298fdce129359219e69c to your computer and use it in GitHub Desktop.
Update preorder date programmatically for Variable products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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