laravel-woocommerce icon indicating copy to clipboard operation
laravel-woocommerce copied to clipboard

add integration for woocommerce admin

Open bfiessinger opened this issue 3 years ago • 1 comments

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:

  • Adding a new trait for WooCommerce Admin / Analytics to ensure only actions that can be done via the endpoint are reflected
  • Easier access to the endpoint by removing the reports/ part
  • Automatic datetime transitions
  • implementing a working find method
  • Possible ideas that come up in the comments

Let me know what you think.

bfiessinger avatar Feb 25 '22 13:02 bfiessinger

Hello @bfiessinger,

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

maab16 avatar Mar 27 '22 11:03 maab16