afurculita/woocommerce-api-client

此软件包已被废弃,不再维护。没有推荐替代软件包。

Woocommerce Rest API客户端

v0.2.0 2014-06-06 11:57 UTC

This package is not auto-updated.

Last update: 2020-01-20 03:44:48 UTC


README

WooCommerce REST API的PHP封装器。使用此封装器类轻松与WooCommerce REST API交互。欢迎提供反馈和错误报告。

要求

PHP 5.2.x cURL WooCommerce 2.1至少在商店上

入门

在您想要交互的商店的个人资料页面上生成API凭证(消费者密钥和消费者密钥)。

一个好的起点是查看包含的示例脚本。

初始化类

<?php
    require_once 'src/WC/API/Client.php';

    $consumer_key = 'ck_fcedaba8f0fcb0fb4ae4f1211a75da72'; // Add your own Consumer Key here
	$consumer_secret = 'cs_9914968ae9adafd3741c818bf6d704c7'; // Add your own Consumer Secret here
	$store_url = 'http://store.rhetina.com/'; // Add the home URL to the store you want to connect to here

	// Initialize the class
	$wc_api = new WC_API_Client( $consumer_key, $consumer_secret, $store_url );
?>

使用方法获取数据

<?php
	// Get all orders
	$orders = $wc_api->get_orders();
	print_r( $orders );
?>

默认情况下,所有方法都返回由json_decode()解码的数据,因此您可以访问数据。

可用方法

索引方法

  • get_index()

订单方法

  • get_orders()
  • get_orders( $params = array( 'status' => 'completed' ) )
  • get_order( $order_id )
  • get_orders_count()
  • get_order_notes( $order_id )
  • update_order( $order_id, $data = array( 'status' => 'processing' ) )

优惠券方法

  • get_coupons()
  • get_coupon( $coupon_id )
  • get_coupon_by_code( $coupon_code )
  • get_coupons_count()

客户方法

  • get_customers()
  • get_customers( $params = array( 'filter[created_at_min]' => '2013-12-01' ) )
  • get_customer( $customer_id )
  • get_customers_count()
  • get_customer_orders( $customer_id )

产品方法

  • get_products()
  • get_products( $params = array( 'filter[created_at_min]' => '2013-12-01' ) )
  • get_product( $product_id )
  • get_products_count()
  • get_product_reviews( $product_id )

报告方法

  • get_reports()
  • get_sales_report( $params = array( 'filter[start_date]' => '2013-12-01', 'filter[end_date]' => '2013-12-09' ) )
  • get_top_sellers_report( $params = array( 'filter[limit]' = '10' ) )

自定义端点

如果您通过自己的端点扩展了WooCommerce API,则可以使用以下函数来获取访问该数据的方法

  • make_custom_endpoint_call( $endpoint, $params = array(), $method = 'GET' )

致谢

版权所有 (c) 2013-2014 - Gerhard PotgieterGPL3 许可证 下发布