Codexshaper / laravel-woocommerce

WooCommerce Rest API for Laravel
MIT License
198 stars 57 forks source link

add integration for woocommerce admin #82

Closed bfiessinger closed 2 years ago

bfiessinger commented 2 years ago

Since WooCommerce Admin is a part of WooCommerce for a while now. It would be helpful to integrate it in laravel-woocommerce.

Since the reports you will get from .../wc/v3/reports/ include very little data they are not that useful for most users.

Integrating the analyses we get from WooCommerce Admin could help here.

For example: I have created a new Coupon via laravel-woocommerce like

$data = [
    'code' => '10off',
    'discount_type' => 'percent',
    'amount' => '10',
    'individual_use' => true,
    'exclude_sale_items' => true,
    'minimum_amount' => '100.00'
];

$coupon = Coupon::create($data);
$coupon_id = $coupon->id;
YourModel::

and the server responds with the coupon

{
  "id": 719,
  "code": "10off",
  ...
}

now using the ID we can easily track the coupon from outside like

$coupons = WooAnalytics::all('reports/coupons', [
  'coupons'   => $coupon_id,
  'before'     => date('Y-m-d\T00:00:00', time()),
  'after'    => $coupon->date_created,
  ...
]);

If this is something you are willing to merge I would add some changes to this PR.

This would include:

Let me know what you think.

maab16 commented 2 years ago

Hello @bfiessinger,

Thanks for your PR. Currently, I'm behind the schedule. I'll evaluate your request.