Created
November 4, 2017 21:06
-
-
Save forsvunnet/d1bf2bc750af45c476b01038122dd9bc to your computer and use it in GitHub Desktop.
Zero dimensions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$wp_did_header = true; | |
require_once 'public/wp-load.php'; | |
$args = [ | |
'post_type' => 'product', | |
'posts_per_page' => -1, | |
'fields' => 'ids', | |
]; | |
$posts = get_posts( $args ); | |
$count = 0; | |
foreach ( $posts as $post_id ) { | |
$product = wc_get_product( $post_id ); | |
// var_dump( get_class_methods( $product ) ); | |
$dims = | |
$product->get_width()+ | |
$product->get_height()+ | |
$product->get_length(); | |
if ( $dims ) { | |
echo $product->get_name(); | |
echo "\n"; | |
$product->set_width( 0 ); | |
$product->set_height( 0 ); | |
$product->set_length( 0 ); | |
$product->save(); | |
$count++; | |
} | |
} | |
echo "Total: $count\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment