rest-api icon indicating copy to clipboard operation
rest-api copied to clipboard

Creating a Deal With Products

Open 0Neji opened this issue 5 years ago • 1 comments

Hi,

I'm trying using the API (PHP) to create a new Deal when someone makes a purchase on my WooCommerce site.

I've got this working nicely, but I'd like to assign a product to the Deal at the same time. I can't see any documentation showing how this is done.

Is this possible and if so, how would I go about doing it?

This is the code I'm currently using to create the deal:

$opportunity_json = array(
	"name" => $deal['name'],
	"expected_value" => $order_meta['_order_total'][0],
	"milestone" => "Open",
	/*"custom_data"=> array(
		array(
			"name" => "dataone",
			"value" => "xyz"
		),
		array(
			"name" => "datatwo",
			"value" => "abc"
		)
	),*/
	//"probability" => 50,
	//"close_date" => 1414317504,
	"contact_ids" => array($contact['id'])
);

$opportunity_json = json_encode($opportunity_json);

curl_wrap("opportunity", $opportunity_json, "POST", "application/json");

Thanks,

Ben

0Neji avatar Mar 12 '19 18:03 0Neji

hi @0Neji yes we can create a Deal when a user purchase a product For example please look in below post man example to create Deal

URL :- https://{domain}.agilecrm.com/dev/api/opportunity

METHOD :- POST

HEADRES :- Content-Type : application/json Accept : application/json

place this json in data in body section as RAW

{ "name": "Deal-Tomato", "expected_value": "500", "probability": "75", "close_date": 1455042600, "milestone": "Proposal", "contact_ids": [ "5758948741218304" ], "custom_data": [ { "name": "Group Size", "value": "10" } ] }

this will create a deal in ur domain , so please pass the PRODUCT details to Json data then the deal will add

Hope this will help you , please let us if you need any further help.

Thanks, Agile Crm Support Team .

rammohan-agile avatar Mar 28 '19 12:03 rammohan-agile