OMG it’s scary! I haven’t tested this but asked a simple specification for a WordPress Plugin that pushes new Woocommerce customers to SuiteCRM and this is what I got… (in about 5 seconds)
(I also asked it to create an admin area in WP where I could enter the SuiteCRM credentials in a subsequent request.)
I can already see the field names are not correct, but it has alot of good stuff there.
<?php
/*
* Plugin Name: WooCommerce to SuiteCRM Lead Sync
* Description: This plugin syncs new WooCommerce customers' information to SuiteCRM as leads.
* Author: Your Name
* Version: 1.0
*/
add_action('woocommerce_new_customer', 'sync_customer_to_suitecrm');
function sync_customer_to_suitecrm($customer_id) {
// Get the customer's information
$customer = new WC_Customer($customer_id);
$name = $customer->get_name();
$email = $customer->get_email();
$address = $customer->get_billing_address();
// Get the SuiteCRM access credentials
$username = get_option('suitecrm_username');
$password = get_option('suitecrm_password');
$url = get_option('suitecrm_url');
// Create a new lead in SuiteCRM
$lead = new stdClass();
$lead->name = $name;
$lead->email = $email;
$lead->address = $address;
$login = array(
'user_auth' => array(
'user_name' => $username,
'password' => md5($password),
),
'application_name' => 'WooCommerce',
);
$soapClient = new SoapClient($url);
$login = $soapClient->login($login, 'Leads');
$set_entry_parameters = array(
'session' => $login->id,
'module_name' => 'Leads',
'name_value_list' => array(
array('name' => 'name', 'value' => $lead->name),
array('name' => 'email', 'value' => $lead->email),
array('name' => 'address', 'value' => $lead->address),
),
);
$result = $soapClient->set_entry($set_entry_parameters);
// Handle the result
if ($result->error->number != 0) {
// Log the error
error_log('SuiteCRM error: ' . $result->error->description);
} else {
// Lead was successfully created
}
}
So I can type queries in natural language. Here are a few examples:
-- show all email addresses of a given contact
SELECT email_addresses.email_address
FROM email_addr_bean_rel
INNER JOIN email_addresses ON email_addr_bean_rel.email_address_id = email_addresses.id
WHERE email_addr_bean_rel.bean_id = '<contact_id>'
AND email_addr_bean_rel.bean_module = 'Contacts'
AND email_addr_bean_rel.deleted = 0
AND email_addresses.deleted = 0;
-- show the most expensive product included in any quote, grouped by account
SELECT accounts.name,
products.name,
MAX(products.cost_price)
FROM
accounts
INNER JOIN
aos_quotes
ON
accounts.id = aos_quotes.billing_account_id
INNER JOIN
aos_products_quotes
ON
aos_quotes.id = aos_products_quotes.parent_id
INNER JOIN
aos_products
ON
aos_products_quotes.product_id = aos_products.id
GROUP BY
accounts.name
ORDER BY
MAX(products.cost_price) DESC
LIMIT 10;
As an update on this one. I wanted a WP Plugin to get the SuiteCRM V8 API access key and store it so that I could use it in WP to push form data. The first try at the code didn’t work. But, I was able to work with ChatGPT to keep adding requirements and solving problems and asking it to re-write the code. I eventually ended up with a WP Plugin that had an admin area in WP where I could enter the login credentials which were stored in the DB MD5 encrypted and a cron job that ran to update the API key in the background so I always had access to API key whenever I needed it via a function. It took a few hours to get right, but if I had to try to code all that myself it would have taken me days.
Is it a PRE-GoodBye to the The SuiteCRM Store and to consultants? What will stop companies to assign one of their employees to just star formulating questions until AI gets it right? Very interesting.
You still need to have a good understanding of what you’re trying to do and how the software you’re trying to code for works. Also, ChatGPT doesn’t support the software if it stops working, ChatGPT by itself isn’t going to fix it. Again, you need a degree of expertise to prompt ChatGPT for help. It is a great tool though.