Masowe dodawanie kodu GTU do wszystkich produktów WooCommerce - inFakt
The snippet can be accessed without any authentication.
Authored by
Krzysztof Dyszczyk
Edited
gtu-inFakt.php 497 B
add_action( 'init', 'wpdesk_update_gtu_for_all_products', 999 );
function wpdesk_update_gtu_for_all_products() {
$wpdesk_gtu_code = '2';
global $wpdb;
if ( 'yes' !== get_option( 'update_gtu_products' ) ) {
$posts = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE `post_type` = 'product' AND `post_status` = 'publish'" );
foreach ( $posts as $post ) {
update_post_meta( $post->ID, '_infakt_gtu_code', $wpdesk_gtu_code );
}
update_option( 'update_gtu_products', 'yes' );
}
}
Please register or sign in to comment