• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Get all WooCommerce products within own plugin

phpwordpresswoocommerceproducthook-woocommerce


PHP Snippet 1:

if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
        // Put your plugin code here
        add_action( 'woocommerce_loaded', 'generate_product_qr_codes' );
    }
    
    function generate_product_qr_codes() {
    
        $args        = array( 'post_type' => 'product', 'posts_per_page' => -1 );
        $products    = get_posts( $args );
        echo '<pre>$products:-';
        print_r( $products );
        echo '</pre>';
    }

Related Snippets

How do I refresh a DIV content?

Why does array_map() with null as callback create an "array of arrays"?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

"properties should not be accessed directly" issue during WooCommerce 3.0 checkout

laravel 5.6 bulk inserting json data

How to debug in WooCommerce 3+

PHP array_filter with arguments

Combining a describing and one array with data

Laravel dosen't connect with Oracle

php curl requesting twice

Why does using salted hash on python and php give me different results?

How do I remove this delivery notification from here?

Symfony 4: "Autowire: you should configure its value explicitly."

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

php echo xml documents with header

About Contact Privacy policy Terms and conditions