本文整理汇总了PHP中wc_get_customer_available_downloads函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_customer_available_downloads函数的具体用法?PHP wc_get_customer_available_downloads怎么用?PHP wc_get_customer_available_downloads使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_get_customer_available_downloads函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_items
/**
* Get all customer downloads.
*
* @param WP_REST_Request $request
* @return array
*/
public function get_items($request)
{
$downloads = wc_get_customer_available_downloads((int) $request['customer_id']);
$data = array();
foreach ($downloads as $download_data) {
$download = $this->prepare_item_for_response((object) $download_data, $request);
$download = $this->prepare_response_for_collection($download);
$data[] = $download;
}
return rest_ensure_response($data);
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:17,代码来源:class-wc-rest-customer-downloads-controller.php
示例2: get_customer_downloads
/**
* Get the available downloads for a customer
*
* @since 2.2
* @param int $id the customer ID
* @param string $fields fields to include in response
* @return array
*/
public function get_customer_downloads($id, $fields = null)
{
$id = $this->validate_request($id, 'customer', 'read');
if (is_wp_error($id)) {
return $id;
}
$downloads = array();
$_downloads = wc_get_customer_available_downloads($id);
foreach ($_downloads as $key => $download) {
$downloads[$key] = $download;
$downloads[$key]['access_expires'] = $this->server->format_datetime($downloads[$key]['access_expires']);
}
return array('downloads' => apply_filters('woocommerce_api_customer_downloads_response', $downloads, $id, $fields, $this->server));
}
开发者ID:unfulvio,项目名称:woocommerce,代码行数:22,代码来源:class-wc-api-customers.php
示例3: get_downloadable_products
/**
* Gets a customer's downloadable products.
* @return array Array of downloadable products
*/
public function get_downloadable_products()
{
$downloads = array();
if ($this->get_id()) {
$downloads = wc_get_customer_available_downloads($this->get_id());
}
return apply_filters('woocommerce_customer_get_downloadable_products', $downloads);
}
开发者ID:tlovett1,项目名称:woocommerce,代码行数:12,代码来源:class-wc-customer.php
示例4: get_customer_downloads
/**
* Get the available downloads for a customer
*
* @since 2.2
* @param int $id the customer ID
* @param string $fields fields to include in response
* @return array
*/
public function get_customer_downloads($id, $fields = null)
{
$id = $this->validate_request($id, 'customer', 'read');
if (is_wp_error($id)) {
return $id;
}
$downloads = wc_get_customer_available_downloads($id);
if (empty($downloads)) {
return array('downloads' => array());
}
return array('downloads' => apply_filters('woocommerce_api_customer_downloads_response', $downloads, $id, $fields, $this->server));
}
开发者ID:anagio,项目名称:woocommerce,代码行数:20,代码来源:class-wc-api-customers.php
示例5: get_downloadable_products
/**
* Gets a user's downloadable products if they are logged in.
*
* @return array Array of downloadable products
*/
public function get_downloadable_products()
{
$downloads = array();
if (is_user_logged_in()) {
$downloads = wc_get_customer_available_downloads(get_current_user_id());
}
return apply_filters('woocommerce_customer_get_downloadable_products', $downloads);
}
开发者ID:nightbook,项目名称:woocommerce,代码行数:13,代码来源:class-wc-customer.php
示例6: test_customer_get_downloadable_products
/**
* Test getting a customer's downloadable products.
* @since 2.7.0
*/
public function test_customer_get_downloadable_products()
{
$customer = WC_Helper_Customer::create_customer();
$customer_id = $customer->get_id();
$this->assertEquals(wc_get_customer_available_downloads($customer_id), $customer->get_downloadable_products());
}
开发者ID:pelmered,项目名称:woocommerce,代码行数:10,代码来源:crud.php
示例7: downloads
/**
* View customer downloads.
*
* ## OPTIONS
*
* <customer>
* : The customer ID, email or username.
*
* [--field=<field>]
* : Instead of returning the whole customer fields, returns the value of a single fields.
*
* [--fields=<fields>]
* : Get a specific subset of the customer's fields.
*
* [--format=<format>]
* : Accepted values: table, json, csv. Default: table.
*
* ## AVAILABLE FIELDS
*
* * download_id
* * download_name
* * access_expires
*
* ## EXAMPLES
*
* wp wc customer downloads 123
*
* @since 2.5.0
*/
public function downloads($args, $assoc_args)
{
try {
$user = $this->get_user($args[0]);
$downloads = array();
foreach (wc_get_customer_available_downloads($user['id']) as $key => $download) {
$downloads[$key] = $download;
$downloads[$key]['access_expires'] = $this->format_datetime($download['access_expires']);
}
$downloads = apply_filters('woocommerce_cli_customer_downloads', $downloads, $user, $assoc_args);
if (empty($assoc_args['fields'])) {
$assoc_args['fields'] = $this->get_customer_download_fields();
}
$formatter = $this->get_formatter($assoc_args);
$formatter->display_items($downloads);
} catch (WC_CLI_Exception $e) {
WP_CLI::error($e->getMessage());
}
}
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:48,代码来源:class-wc-cli-customer.php
注:本文中的wc_get_customer_available_downloads函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论