Created
May 27, 2021 20:23
-
-
Save alexmigf/384633c5cdb12c6444fce69b29a15e97 to your computer and use it in GitHub Desktop.
Update product _stock meta with locations stock on WP All Import
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
<?php | |
add_action( 'pmxi_saved_post', function( $id ) | |
{ | |
// 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions:
<?php