Im using Composer autoload in my plugin to make it easier to manage all the files and classes instead of writing everysingle time require_once
However Im having trouble trying to access native woocommerce classes. My classes are defined with namespaces as for example:
<?php
namespace IncApi;
class RestClientApi
{
....
}
If I try to call a woocommerce class within this class for example:
<?php
namespace IncApi;
class RestClientApi
{
public $example = new WC_product();
}
I get the error Class Inc/Api/WC_product not found
I know what the error means, but I don't have idea how to use Woocommerce classes from my custom plugin, considering I'm using autoload and namespaces in my custom plugin classes.
UPDATE
As requested I added my autoload configuration, it is pretty simple, Im just calling my /inc folder
"autoload": {
"psr-4": {"Inc": "./inc"}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…