• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / EDD_API::get_products() – Process Get Products API Request

You appear to be a bot. Output may be restricted

Description

Process Get Products API Request

Usage

$array = EDD_API::get_products( $args );

Parameters

$args
( mixed ) optional –

Returns

array $customers Multidimensional array of the products

Source

File name: easy-digital-downloads/includes/api/class-edd-api.php
Lines:

1 to 44 of 44
  public function get_products( $args = array() ) {

    $products = array();
    $error = array();

    if ( empty( $args['product'] ) ) {

      $products['products'] = array();

      $parameters = array(
        'post_type'        => 'download',
        'posts_per_page'   => $this->per_page(),
        'suppress_filters' => true,
        'paged'            => $this->get_paged(),
      );

      if ( isset( $args['s'] ) && !empty( $args['s'] ) ) {
        $parameters['s'] = $args['s'];
      }

      $product_list = get_posts( $parameters );

      if ( $product_list ) {
        $i = 0;
        foreach ( $product_list as $product_info ) {
          $products['products'][$i] = $this->get_product_data( $product_info );
          $i++;
        }
      }
    } else {

      if ( get_post_type( $args['product'] ) == 'download' ) {
        $product_info = get_post( $args['product'] );

        $products['products'][0] = $this->get_product_data( $product_info );

      } else {
        $error['error'] = sprintf( __( 'Product %s not found!', 'easy-digital-downloads' ), $args['product'] );
        return $error;
      }
    }

    return apply_filters( 'edd_api_products', $products, $this );
  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 26th November 2019

Primary Sidebar

Information

Function name: EDD_API::get_products
Class ref: EDD_API
Plugin ref: Easy Digital Downloads
Version: 2.9.26
Sourcefile: includes/api/class-edd-api.php
File ref: includes/api/class-edd-api.php
Deprecated?: No
API Letters: A,E,G,P

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.6.2
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites