Skip to content
Snippets Groups Projects

Masowe dodawanie kodu GTU do wszystkich produktów WooCommerce - inFakt

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    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' );
    	}
    
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment