3

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?

cvl01
  • 57
  • 1
  • 5

1 Answers1

0

Answer for me: use a custom file with wp-load.php and call it using your hosting's Cron Service.

cvl01
  • 57
  • 1
  • 5