I have just very nearly completed a custom theme for a client of mine. However he wants to set the price of 0.50eur and a minimum order price for these products here
The problem I have is that all products are being imported from an eternal site using WP All Import Pro. I have 2 feeds running, 1 that brings in the products 4 times a day and one that updates the prices every hour.
Obviously there is some sort of filter I need to add to my functions.php file but where to start on this I have no idea. Many thanks for any help.
Based on your comments i guess you would need to take a look at this first from Wp All Import documentation
After that you can see you have multiple hooks, one of them is pmxi_saved_post, going on with the example you could do something like:
function fix_price_after_import( $post_id, $xml_node, $is_update ) {
if ( ! empty( $post_id ) ) {
$current_prod = wc_get_product( $post_id );
if ( ! empty( $current_prod ) && $current_prod instanceof WC_Product ) {
$categories_to_update = array(100,200); // product_cat IDS
if (!empty(array_intersect($categories_to_update,$current_prod->get_category_ids()))){
// Current prod has at least one of the categories you have to update
$current_prod->set_price(0.5);
$current_prod->save();
}
}
}
}
add_action( 'pmxi_saved_post', 'fix_price_after_import', 10, 3 );
I didn't test the code but it should give you a starting point