add_action( 'pmxi_saved_post', function( $id )
{
$import_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );
// Only run for import IDs 329 and 212.
if ( $import_id == '329' || $import_id == '212' ) {
// get locations total stock
$locations_total_stock = \SLW\SRC\Helpers\SlwProductHelper::get_product_locations_stock_total( $id );
// update stock
update_post_meta( $id, '_stock', $locations_total_stock );
// update stock status
\SLW\SRC\Helpers\SlwProductHelper::update_wc_stock_status( $id );
}
}, 10, 1 );
Please check the inc/functions.php around line no. 245, this add_action thing “pmxi_saved_post” is already there. Please explain the following condition, is it specifically for your use-case or they recommended it for every user.
if ( $import_id == '329' || $import_id == '212' ) {
Imports DOESN’T WORK with your plugin. It’s possible to update the stock depending on locations with the code _stock_at_[4 number ID], but the product general stock isn’t updated like in there.
These conditions you wrote are for me the only way to apply the custom code depending on the import ID. Because it creates problems for the classic stock imports (when only _stock is updated and not _stock_at).