寻找一种方法来删除woocommerce中所有产品的销售价格。管理员的视野有限,因此对于拥有10,000多种产品的网站而言,手动取消销售价格可能是一项非常繁琐的任务。
能做到吗?
您可以在产品管理员上批量修改销售价格。
或者,您可以将其暂时放入您的functions.php中。...加载一次管理员,然后将其删除。(未经测试,使用后果自负)
function so_28048702_update(){
// in theory this will grab all variations FIRST
$args = array( 'post_type' => array( 'product','product-variation' ), 'nopaging' => true, 'sortby' => 'post_type', 'order' => 'desc' );
$all_products = new WP_Query( $args );
if ( $all_products->have_posts() ) :
while ( $all_products->have_posts() ) :
$all_products->the_post();
$id = get_the_ID();
update_post_meta( $id, '_sale_price', '' );
$regular_price = get_post_meta( $id, '_regular_price', true );
update_post_meta( $id, '_price', $regular_price );
// we're on a variable product
if( has_term( 'variable', 'product_type', $id ) ){
variable_product_sync( $id );
}
endwhile;
endif;
wp_reset_postdata();
}
add_action( 'admin_init', 'so_28048702_update' );
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句