• 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

Laravel 5 session not persisting after user is logged in

Class AppHttpControllersUserController Does Not Exist

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

Valet, Xdebug after reboot Big Sur not working

Can I use a WooCommerce function without any WooCommerce page?

How to display table header in every page using FPDF library?

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

how to insert data into select2 search input after scan using qrcode

PHP file_get_contents function

Log a user out of a website when they put their computer to sleep

How to Make Laravel Eloquent "IN" Query?

Laravel get user data with profile

file_get_contents() without "Http" to access external URL [closed]

Using spatie/media-library, how to rename a collection of uploaded files?

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

About Contact Privacy policy Terms and conditions