• 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

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

Unit (real unit test) of test laravel relationship

WooCommerce Additional Information - if empty, hide

Access relation of pivot table in Laravel

Inserting data into SQL Server Db An Invalid direction was specified

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

Why rand() every time I refresh the page?

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Saving Data from form to database using AngularJS and php

Insert a DIV after the 6th product only once in WooCommerce category archives

Split a string array into pieces

Get WooCommerce products from specific category

Apply filter array/return terms

Adding the custom page with add_menu_page function on Wordpress

Additional price based on cart item count in WooCommerce

About Contact Privacy policy Terms and conditions