Hi,
I tried to add an existing product to an invoice.
But the system doesn’t load correctly the product.
Can you help me?
$new_invoice = BeanFactory::newBean('AOS_Invoices');
$new_invoice->id = create_guid();
$new_invoice->new_with_id = true;
$new_invoice->billing_account_id = "299d5425-ecd6-b7f9-99f6-5be2e9dfc610";
$new_invoice->save();
//1d7ad393-3dd2-0fd2-e151-5be5714e732e = exixting product id
$aosProducts = BeanFactory::getBean('AOS_Products','1d7ad393-3dd2-0fd2-e151-5be5714e732e');
$aosProductsQuotes = BeanFactory::newBean('AOS_Products_Quotes');
$aosProductsQuotes->parent_type = 'AOS_Invoices';
$aosProductsQuotes->parent_id = $new_invoice->id;
$aosProductsQuotes->maincode = $aosProducts->maincode;
$aosProductsQuotes->part_number = $aosProducts->part_number;
$aosProductsQuotes->product_id = $aosProducts->id;
$aosProductsQuotes->product_total_price = 100;
$aosProductsQuotes->save();
Thanks
Marco