We do not currently have in-depth developer documentation available, but here are some useful code snippets and resources for developers.
The plugin does have its own database tables that you can get certain data from:
wcusage_activity – Activity log.
wcusage_campaigns – Referral URL campaigns.
wcusage_clicks – Referral URL clicks log.
wcusage_directlinks – Direct link tracking domains.
wcusage_mlainvites – Multi-Level affiliates invites.
wcusage_payouts – Commission Payouts
wcusage_register – Affiliate registration applications.
Get all affiliate orders for a coupon, without certain data range. This returns an array of data, including order IDs.
$orders = wcusage_wh_getOrderbyCouponCode( $coupon_code, $start_date, $end_date, '', 1 );
You can get an array of affiliate related data for a certain order via this function. This returns an array of data including the commission earnings.
$order_data = wcusage_calculate_order_data( $order_id, $coupon_code, 0, 1 );
To get the commission from the order for example:
$commission = $order_data['totalcommission'];
Get the affiliate URL for a coupon.
$coupon_code = ""; // Set the coupon code name here. $prefix = wcusage_get_setting_value('wcusage_field_urls_prefix', 'coupon'); $affiliate_url = get_home_url() . "?" . $prefix . "=" . $coupon_code;
Total Sales and Commission
Get the total sales and commission earned by a certain coupon, without a certain date range. Leave $start_date empty to get all sales.
$orders = wcusage_wh_getOrderbyCouponCode( $coupon_code, $start_date, $end_date, '', 1 ); $total_orders = $orders['total_orders']; // Total Sales $total_discounts = $orders['full_discount']; // Total Discounts $total_commission = $orders['total_commission']; // Total Commission $order_count = $orders['total_count']; // Orders Count
Get the total unpaid commission for an affiliate coupon.
$coupon_id = ""; // Set the coupon code ID here. $unpaid_commission = get_post_meta( $coupon_id, 'wcu_text_unpaid_commission', true );