And*_*rus 0 plugins filtering woocommerce
正在寻找一种方法来消除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' );
Run Code Online (Sandbox Code Playgroud)