• 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 to to send mail using gmail in Laravel?

Laravel views are showing from cache on one server but works fine on other server

How to add a custom field to all Woocommerce attribute terms using add_action

PHP array stringify

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

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

Minimum order amount except for specific shipping method in WooCommerce

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

Can I write PHP code across multiple lines per statement?

api response laravel doesn't show

PHP mail sending empty mails

"cannot list resources" error from WooCommerce REST API

How to get the total hour from starting time to end time in php

Getting values for an enum?

Modify microseconds of a PHP DateTime object

About Contact Privacy policy Terms and conditions