I'm trying to add a customizable product to the woocommerce cart.
I have all details calculated and ready to be able to add it to the cart.
Looking into the woocommerce api, it looks like I can use REST, but I'm just thinking there must be an easier way with regular php.
I'm thinking something like this:
function add_product_to_wc(){
global $woocommerce;
$product_id = $name;
$variationid = $type;
$spec = array();
$spec['Dimension'] = $dimension; //user select Dimension
$spec['ColorOne'] = $colorOne; //user select color 1
$spec['ColorTwo'] = $colorTwo; //user select color 2
$woocommerce->cart->add_to_cart( $product_id, $variationid, $spec, null );}
Am I totally off ? or how can I do this ?