Creating a product variable subscription and its variations with PHP
-
Hello,
I am trying to create a WC_Product_Variable_Subscription and the connected
WC_Product_Subscription_Variation(s) via PHPCreating WC_Product_Variable and WC_Product_Variation is simple (the class from which the classes I create inherit) but I am having troubles setting the required
interval,
period and
lengthproperties (e.g make the subscription price 200$ every month for 6 month.
Reviewing generated WC_Product_Subscription_Variation did not help.
It’s no property (via set_props) and it seems to be stored in a differend table
as e.g.$products = wc_get_products(['limit' => -1]); echo '<pre>' . print_r( wc_get_product($products[0]->get_children()[0]) , true) . '</pre>';
to display and review a (via the wordpress backend generated) variations did not (as mentioned) get me any closer
So my question:
$product = new WC_Product_Variable_Subscription();
$variation = new WC_Product_Subscription_Variation();howto / whereto set the required properties via PHP to define the initially named properties ?
thanks a lot (!) for anyone being able to point me into the right direction
btw: had a quick look at https://github.com/wp-premium/woocommerce-subscriptions/blob/master/includes/class-wc-product-subscription-variation.php – the main difference seesm to be an instance of WCS_Array_Property_Post_Meta_Black_Magic
and…
does anyone know where the woocommerce subscription unit tests are ?
- The topic ‘Creating a product variable subscription and its variations with PHP’ is closed to new replies.