I gave it a go, and I can’t seem to get it to work.
I have the form submission making an AJAX call to a method in my functions.php file (successfully making the call to that function). Everything seems to be functioning, until I make the call to the $contact_form_submissions object. This is what my method in my functions.php file looks like:
function save_simple_pay_dbsubmission() {
global $contact_form_submissions;
// Get current timestamp for database submission
$d = new DateTime('', new DateTimeZone('America/Edmonton'));
$timestamp = $d->format('Y-m-d [G:i:s]');
$submission = array(
'form_id' => 0,
'body' => '',
'sender' => '',
'subject' => $sess['product-desc'],
'recipient' => '',
'additional_headers' => '',
'attachments' => array(),
'fields' => array(
'bill-first-name' => $sess['bill_first_name'],
'bill-last-name' => $sess['bill_last_name'],
'email' => $sess['email'],
'bill-phone' => $sess['bill_phone'],
'bill-address' => $sess['bill_address_one'],
'bill-city' => $sess['bill_city'],
'bill-province' => $sess['bill_state_or_province'],
'bill-country' => $sess['bill_country'],
'bill-postal-code' => $sess['bill_postal_code'],
'product-description' => $sess['product-desc'],
'product-single-price' => $sess["price1"],
'product-quantity' => $sess['quantity1'],
'subtotal' => $sess['subtotal1'],
'charge-total' => $sess['charge_total'],
'timestamp' => $timestamp
)
);
$db_submission = $contact_form_submissions->save($submission);
return 'SUCCESSFUL DATABASE SUBMISSION';
}
Like I said, I’m able to make the AJAX call to that function. If I comment out the $db_submission variable, I can get the successful return (I’ve been able to log it to the console).
Is there something that you can see that is inherently wrong with this plan or my code?