Add Quoted Line Items out of Bundles with REST API

I have been able to create quotes and Quoted line items with your REST API via PHP following

https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.2/Cookbook/Web_Services/REST_API/PHP/How_to_Manipulate_Quotes/

The documented example places the Quoted Line Items (products) under bundles. But I do not need bundles and would like to customize the documented code to create the Quoted Line items under the Quote, not under a bundle as viewed in the attached image. This is possible to do on the SUGAR website interface but I am unable to make it work with the php code as explained on the link above.

The relevant code I would like to customize is:

$quote = array(
'name' => 'Test Quote',
'quote_stage' => 'Draft',
'date_quote_expected_closed' => $DateTime->format(DateTime::ISO8601),
//Create Product Bundles
'product_bundles' => array(
'create' => array(
array(
"name" => "Product Bundle 1",
"bundle_stage" => "Draft",
"currency_id" => ":-99",
"base_rate" => "1.0",
"shipping" => "0.00",
"products" => array(
//Create Product in Bundle 1
"create" => array(
array(
"tax_class" => "Taxable",
"quantity" => 1000.00,
"name" => "Test Product 1",
"description" => "My Test Product",
"mft_part_num" => "mft100012021",
"cost_price" => "100.00",
"list_price" => "200.00",
"discount_price" => "175.00",
"discount_amount" => "0.00",
"discount_select" => 0,
"product_template_id" => "",
"type_id" => "",
"status" => "Quotes"
)
)
),
//Create Product Bundle Note in Bundle 1
"product_bundle_notes" => array(
"create" => array(
array(
"description" => "Free shipping",
"position" => 1
)
)
)
),
array(
"name" => "Product Bundle 2",
"bundle_stage" => "Draft",
"currency_id" => ":-99",
"base_rate" => "1.0",
"shipping" => "25.00",
"products" => array(
//Create Products in Bundle 2
"create" => array(
array(
"quantity" => 1000.00,
"name" => "Test Product 2",
"description" => "My Other Product",
"mft_part_num" => "mft100012234",
"cost_price" => "150.00",
"list_price" => "300.00",
"discount_price" => "275.00",
"discount_amount" => "0.00",
"discount_select" => 0,
"product_template_id" => "",
"type_id" => "",
"status" => "Quotes"
),
array(
"quantity" => 500.00,
"name" => "Test Product 3",
"description" => "My Other Other Product",
"mft_part_num" => "mft100012123",
"cost_price" => "10.00",
"list_price" => "500.00",
"discount_price" => "400.00",
"discount_amount" => "0.00",
"discount_select" => 0,
"product_template_id" => "",
"type_id" => "",
"status" => "Quotes"
)
)
)
)
),
)
);

Thanks

  • Hi, 

    In creation sugar creates a default bundle group, that can be achieved like below:

    $quote= array(
        'name' => 'Test Quote',
        'quote_stage' => 'Draft',
        'date_quote_expected_closed' => '2020-12-12',
        'product_bundles' => array(
            'create' => array(
                array(
    		"postion"=> 0,
    		"default_group"=> true,   
                    "products" => array(
                
                        "create" => array(
                            array(
                                "tax_class" => "Taxable",
                                "quantity" => 1000.00,
                                "name" => "Test Product 1",
                                "description" => "My Test Product",
                                "mft_part_num" => "mft100012021",
                                "cost_price" =>  "100.00",
                                "list_price" =>  "200.00",
                                "discount_price" =>  "175.00",
                                "discount_amount" =>  "0.00",
                                "discount_select" =>  0,
                                "product_template_id" =>  "",
                                "type_id"  =>  "",
                                "status"  =>  "Quotes"
                            )
                        )
                    ),
         
                ),
            ),
        )
    );

    Hope it helps.
    Thanks.