1. Home
  2. Knowledge Base
  3. WooCommerce Wholesale Prices Premium
  4. Product Visibility
  5. How To Automatically Run The Re-Initialize Visibility Meta Button After Every Import Using WP All Import
  1. Home
  2. Knowledge Base
  3. Known Compatibility Issues
  4. How To Automatically Run The Re-Initialize Visibility Meta Button After Every Import Using WP All Import

How To Automatically Run The Re-Initialize Visibility Meta Button After Every Import Using WP All Import

When you import products with a third-party plugin like WP All Import, the products are not re-saved the normal way. This can leave their wholesale visibility meta out of date, as explained in this article. The fix is to click Re-Initialize Product Visibility Meta on the Help tab of your Wholesale Prices settings. This saves the correct wholesale meta values to the database.

If you update your products often, usually through a scheduled import on a CRON job, clicking that button by hand every time is a chore. The snippet below runs the same re-initialize routine automatically after each import.

Add this snippet to your child theme’s functions.php file, or to a code snippets plugin:

function wwpp_reinitialize_visibility_after_import() {
    // Fire Wholesale Prices Premium's supported trigger for the
    // "Re-Initialize Product Visibility Meta" routine.
    do_action( 'wwp_trigger_initialize_product_visibility_meta' );
}
add_action( 'pmxi_after_xml_import', 'wwpp_reinitialize_visibility_after_import' );

pmxi_after_xml_import is a WP All Import hook that runs after an import finishes, so the visibility meta is rebuilt every time your products are imported. The wwp_trigger_initialize_product_visibility_meta action is the supported way to run the re-initialize routine in code. You do not need to load or set up any plugin classes yourself.

If you use a different third-party import plugin, hook the same do_action( 'wwp_trigger_initialize_product_visibility_meta' ); call to whatever action that plugin fires when an import completes. If you’re not sure which hook to use, contact that plugin’s author or a developer.

Need Help?

If you have a question or run into any issues, we’re here to help.

Was this article helpful?

Related Articles

Contents

Need Support?

Can't find the answer you're looking for?
Contact Support
Complete Your Purchase