跳到内容

Dotix

v1.5

WPDO · 2019年8月22日 上架

Connect your app with WooCommerce credits. Append additional credits for each product in WooCommerce.

正在使用
10 以下
评分
暂无
累计下载
1,872
最近更新
2022年5月28日
需要 WordPress 4.0+已测试到 6.0.19

贡献者

This plugin will enable the connection between your app and WooCommerce orders for digital credits usage. It can be used to check the remaining credits in one order, or consume them.

Usage

Redirect to your app link on order paid page, carring on the order key.

Let’s assume the order_key=wc_order_xQhmRjJ7, your app URL is https://app.EXAMPLE.com/refill, your WordPress URL is https://EXAMPLE.com/

  1. On the order Thank You page, show a button <a href="https://app.EXAMPLE.com/refill?order_key=wc_order_xQhmRjJ7">Go back to app.EXAMPLE</a>.

  2. In https://app.EXAMPLE.com/refill, call https://EXAMPLE.com/wp-json/dotix/v1/order/wc_order_xQhmRjJ7 with $_POST[ 'num' ] = 'max', assume the consumed credits is 42 in returned JSON.

  3. Add 42 credits into the corresponding user account.

REST APIs

1) Show balance:
Method: GET
URL: https://EXAMPLE.com/wp-json/dotix/v1/order/wc_order_xQhmRjJ7
Return: {"_res":"ok", "order_id":45, "status":"completed", "balance":"142"}
// NOTE: only the order with status=completed can be consumed credits.

2) Consume 100 credits:
Method: POST
URL: https://EXAMPLE.com/wp-json/dotix/v1/order/wc_order_xQhmRjJ7
Data: [ 'num' => 100 ]
Return: {"_res":"ok", "order_id":45, "consumed":"100", "balance":"42"}

3) Consume all credits:
Method: POST
URL: https://EXAMPLE.com/wp-json/dotix/v1/order/wc_order_xQhmRjJ7
Data: [ 'num' => 'max' ]
Return: {"_res":"ok", "order_id":45, "consumed":"42", "balance":"0"}

For all errors, will return {“_res”:”err”, “_msg”:”error_msg_tag or content”}

Order Status

If an order contains only items that have valid credit in product detail, once the order is paid, the status will change to completed automatically instead of processing.

The reason to do this is because some unpaid getways (Bank Wire, Cheque, Cash on delivery) will have status processing once the order is placed while not paid. Thus we can’t use processing to detect if the order is paid or not.

To make the credits in the orders with the unpaid gateways available, please update the order status to completed.

Error Message Tag In REST API

Error code: wrong_hash
Description: The order key doesn’t match any order.

Error code: wrong_status
Description: The order isn’t in processing/completed status, maybe not paid yet?

Error code: lack_of_param
Description: Need to specify the ammount to consume. Either numeric or a fixed string max.

Error code: lack_of_bal
Description: Not enough balance left in this order.

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums