Advertisement
eventsmanager

Trigger WooCommerce product sync

Jul 22nd, 2021
2,451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. <?php
  2. /*
  3. This snippet will create a WooCommerce product for every future event not created after installing the WC add-on.
  4. Delete when synced once, as future events are synced automatically already and this will affect performance of your site.
  5. For installation instructions please see:
  6. http://wp-events-plugin.com/tutorials/how-to-safely-add-php-code-to-wordpress/
  7.  */
  8. function em_create_products_sync(){
  9.     $args = array('scope' => 'future');
  10.     foreach( EM_Events::get( $args ) as $EM_Event ){
  11.         \Events_Manager_WooCommerce\Product::em_event_save( true, $EM_Event );
  12.     }
  13. }
  14. add_action('em_woocommerce_loaded', 'em_create_products_sync');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement