I have different suppliers for my woocommerce store. I update my suppliers prices once per day in a custom field.
I have a function to test which supplier is cheapest and update the price accordingly.
$args = array(
'category' => array( 'inkt-supplies', 'plotters', 'plotter-onderdelen' ),
'limit' => 700,
'page' => $page
);
$products = wc_get_products( $args );
foreach($products as $product ){
// Get custom fields, calculations
$product->set_regular_price($cheapest_price);
$product->save();
}
Apperently this code doesn't work when I set it to run on WP Cron. As also noted in this question
What can I do to execute this function on a daily basis?
I am able to use cron jobs, so is it possible to make a seperate file with this function?