当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Webhook::get_event方法代码示例

本文整理汇总了PHP中WC_Webhook::get_event方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Webhook::get_event方法的具体用法?PHP WC_Webhook::get_event怎么用?PHP WC_Webhook::get_event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Webhook的用法示例。


在下文中一共展示了WC_Webhook::get_event方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_webhook

 /**
  * Get the webhook for the given ID
  *
  * @since 2.2
  * @param int $id webhook ID
  * @param array $fields
  * @return array
  */
 public function get_webhook($id, $fields = null)
 {
     // ensure webhook ID is valid & user has permission to read
     $id = $this->validate_request($id, 'shop_webhook', 'read');
     if (is_wp_error($id)) {
         return $id;
     }
     $webhook = new WC_Webhook($id);
     $webhook_data = array('id' => $webhook->id, 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'created_at' => $this->server->format_datetime($webhook->get_post_data()->post_date_gmt), 'updated_at' => $this->server->format_datetime($webhook->get_post_data()->post_modified_gmt));
     return array('webhook' => apply_filters('woocommerce_api_webhook_response', $webhook_data, $webhook, $fields, $this));
 }
开发者ID:abcode619,项目名称:wpstuff,代码行数:19,代码来源:class-wc-api-webhooks.php

示例2: create_payload

 /**
  * Setup payload for subscription webhook delivery.
  *
  * @since 2.0
  */
 public static function create_payload($payload, $resource, $resource_id, $id)
 {
     if ('subscription' == $resource && empty($payload) && wcs_is_subscription($resource_id)) {
         $webhook = new WC_Webhook($id);
         $event = $webhook->get_event();
         $current_user = get_current_user_id();
         wp_set_current_user($webhook->get_user_id());
         WC()->api->WC_API_Subscriptions->register_routes(array());
         $payload = WC()->api->WC_API_Subscriptions->get_subscription($resource_id);
         wp_set_current_user($current_user);
     }
     return $payload;
 }
开发者ID:DustinHartzler,项目名称:TheCLEFT,代码行数:18,代码来源:class-wcs-webhooks.php

示例3: check_get_webhook_response

 /**
  * Ensure valid webhook data response.
  *
  * @since 2.2
  * @param array $response
  * @param WC_Webhook $webhook
  */
 protected function check_get_webhook_response($response, $webhook)
 {
     $this->assertEquals($webhook->id, $response['id']);
     $this->assertEquals($webhook->get_name(), $response['name']);
     $this->assertEquals($webhook->get_status(), $response['status']);
     $this->assertEquals($webhook->get_topic(), $response['topic']);
     $this->assertEquals($webhook->get_resource(), $response['resource']);
     $this->assertEquals($webhook->get_event(), $response['event']);
     $this->assertEquals($webhook->get_hooks(), $response['hooks']);
     $this->assertEquals($webhook->get_delivery_url(), $response['delivery_url']);
     $this->assertArrayHasKey('created_at', $response);
     $this->assertArrayHasKey('updated_at', $response);
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:20,代码来源:webhooks.php

示例4: prepare_item_for_response

 /**
  * Prepare a single webhook output for response.
  *
  * @param WP_REST_Request $request Request object.
  * @return WP_REST_Response $response Response data.
  */
 public function prepare_item_for_response($post, $request)
 {
     $id = (int) $post->ID;
     $webhook = new WC_Webhook($id);
     $data = array('id' => $webhook->id, 'name' => $webhook->get_name(), 'status' => $webhook->get_status(), 'topic' => $webhook->get_topic(), 'resource' => $webhook->get_resource(), 'event' => $webhook->get_event(), 'hooks' => $webhook->get_hooks(), 'delivery_url' => $webhook->get_delivery_url(), 'date_created' => wc_rest_prepare_date_response($webhook->get_post_data()->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($webhook->get_post_data()->post_modified_gmt));
     $context = !empty($request['context']) ? $request['context'] : 'view';
     $data = $this->add_additional_fields_to_object($data, $request);
     $data = $this->filter_response_by_context($data, $context);
     // Wrap the data in a response object.
     $response = rest_ensure_response($data);
     $response->add_links($this->prepare_links($post));
     /**
      * Filter webhook object returned from the REST API.
      *
      * @param WP_REST_Response $response The response object.
      * @param WC_Webhook       $webhook  Webhook object used to create response.
      * @param WP_REST_Request  $request  Request object.
      */
     return apply_filters("woocommerce_rest_prepare_{$this->post_type}", $response, $webhook, $request);
 }
开发者ID:tlovett1,项目名称:woocommerce,代码行数:26,代码来源:class-wc-rest-webhooks-controller.php


注:本文中的WC_Webhook::get_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。