• 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

Whats the point of running Laravel with the command 'php artisan serve'?

Edit product hook WooCommerce

How to send upload image through email

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

PHP each() function replacement

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

How to show a popup modal in codeIgniter?

How to separate letters and digits from a string in php

PHP Download MP3 files from directory on server

php code to send checkbox form results to email

Make survey at laravel 5.4 and MySQL

Unable to get password for the instance created from AMI

Converting array to string and then back in PHP

How to send image,audio or video through the WhatsApp API - PHP

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

About Contact Privacy policy Terms and conditions