asciisd / zoho

Zoho package for Laravel
36 stars 36 forks source link

Creating a quote and adding relation to contact #26

Closed jk-1001 closed 3 years ago

jk-1001 commented 3 years ago

Hello,

How can I create a quote and add the relation to a contact?

Thanks

jk-1001 commented 3 years ago

I got it working through the php sdk with the line items but just wondering if there's a way to achieve the same thing through your package or not? Either way I have it working.

` $contact = ZohoManager::useModule('Contacts')->getRecordInstance();

    // fill contact data
    $contact->setFieldValue('First_Name', $request->input('First_Name'));
    $contact->setFieldValue('Last_Name', $request->input('Last_Name'));
    $contact->setFieldValue('Email', $request->input('Email'));
    $contact->setFieldValue('Phone', $request->input('Phone'));

    // create the record into zoho crm then return contact
    $contact = $contact->create()->getData();
    $contact_id = $contact->getEntityId();

    //create a new quote
    $quote = ZohoManager::useModule('Quotes')->getRecordInstance();

    //fill quote data
    $quote->setFieldValue('Subject', $request->input('Subject'));
    $quote->setFieldValue('Pet_Gender', $request->input('Pet_Gender'));
    $quote->setFieldValue('Animal_Type', $request->input('Animal_Type'));
    $quote->setFieldValue('Breed', $request->input('Breed'));
    $quote->setFieldValue('Pet_DOB', $request->input('Pet_DOB'));
    $quote->setFieldValue('Quote_Stage', 'Draft');
    $quote->setFieldValue('Contact_Name', $contact_id);

    //line items
    $line_item = ZCRMInventoryLineItem::getInstance(null);
    $line_item->setProduct(ZCRMRecord::getInstance('Products', 'xxxxxxxx'));
    $line_item->setQuantity(1);
    $quote->addLineItem($line_item);

    //create quote
    $quote->create();`