1. Home
  2. WC Vendors Pro
  3. Reset the Product form for all products to ‘Standard’
  1. Home
  2. Code Snippets
  3. Reset the Product form for all products to ‘Standard’

Reset the Product form for all products to ‘Standard’

WC Vendors Pro provides the ability for you to select three different form types. 

  • Standard
  • Simple
  • Download 

When vendors create products, the form type is stored with the product. If for any reason you change this form type, any existing products will still use the old form template. To reset them you can use the following code snippet. 

Add this to your theme’s functions.php and reload the frontend once. This will reset the products to standard, depending on how many products you have the reload may be quick, or slightly delayed. 

Please Note

Please be sure to test this on your staging site first!

<?php 
 // reset WC Vendors Product form to standard 
 add_action( 'template_redirect', 'reset_product_form_type' ); 
 function reset_product_form_type(){ 
	$args = array ( 
		'post_type'  => 'product',
		'posts_per_page'  => -1,
		'meta_query' => array( 
				array( 
					'key' => '_wcv_product_form_template', 
					'value' => 'simple'
				), 
			),
	); 

	$product_query = new WP_Query( $args ); 

	foreach (  $product_query->get_posts() as $product_id => $product ) {
		update_post_meta( $product->ID, '_wcv_product_form_template', '' );
	}
 }

After you have reset the products back to standard you can remove this code from your themes functions.php

actions

Updated on November 14, 2020

Was this article helpful?