Created
November 9, 2023 06:08
-
-
Save braddalton/bbb0d054ad757708d68bc5010f1b6253 to your computer and use it in GitHub Desktop.
Daily Random Free Product for WooCommerce Changes The Price to Zero for 1 Day Only. Full Code https://wpsites.net/?p=114123
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('init', 'assign_random_free_product'); | |
function assign_random_free_product() { | |
$today = date('Y-m-d'); | |
$assigned_product_date = get_option('random_free_product_date'); | |
if ( $today != $assigned_product_date ) { | |
$random_product_id = get_random_free_product(); | |
if ( $random_product_id ) { | |
update_option('random_free_product_id', $random_product_id); | |
update_option('random_free_product_date', $today); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment