php - Setting variation_id for product in Woocommerce -
currently, customising checkout procedure, , need create order using code. tried use following code create order, cannot put variation_id product object. assuming know product_id , variation_id.
$my_order = wc_create_order(array('status'=>'processing','customer_id'=>$customer_id)); $my_product=new wc_product($product_id); $my_product->variation_id=$variation_id; $my_order->add_product( $my_product, 1); $order->set_address( $address, 'billing' ); $order->set_address( $address, 'shipping' ); $order->calculate_totals(); anyone knows how add $variation_id $my_product?
Comments
Post a Comment