This topic is set to expire on Jul 12 2025 ×

Affiliates DB table update missing?

Merchant
From United States
Member since Apr 2023

Greetings Tim,

Recently attempted to update to Affiliates v1.0.1 and get error:

Fatal error: 1054 - Unknown column 'collect_parameters' in 'SET' update lcry_affiliates set status = 1, name = '*****', description = 'https://backwoodswizards.com/store/?affiliate_id=XXX', collect_parameters = '', webhook = '{\"method\":\"GET\",\"url\":\"\",\"data\":\"\"}', cookie_lifetime = '90', date_updated = '2025-04-09 22:23:08' where id = 2 limit 1; in ~/includes/library/lib_database.inc.php (Line 199)
Warning: Undefined array key "cookie_lifetime" in ~/admin/affiliates.app/affiliates.inc.php (Line 72)  

Wondering if the README is missing some of the original and/or enhanced steps to create/update the column name in the table?

All the Best,
Rorik

tim
Founder
From Sweden
Member since May 2013
tim

What LiteCart version are you on?
These should have been automated by the vmod for you. Upgrades also. I think this could be caused by the version numbering moving from dates to incremental numbers.

Can you run the following query in phpmyadmin?

ALTER TABLE `lcry_affiliates`
ADD COLUMN `collect_parameters` VARCHAR(256) NOT NULL DEFAULT '' AFTER `description`,
ADD COLUMN `webhook` TEXT NOT NULL DEFAULT '{}' AFTER `collect_parameters`,
ADD COLUMN `cookie_lifetime` VARCHAR(64) NOT NULL DEFAULT '+30 days' AFTER `webhooks`;
Merchant
From United States
Member since Apr 2023

We're running LiteCart v 2.6.2, softlicious usually updates within a few days of a new release.

SQL command output

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0095 seconds.)
ALTER TABLE `lcry_affiliates` ADD COLUMN `collect_parameters` VARCHAR(256) NOT NULL DEFAULT '' AFTER `description`, ADD COLUMN `webhooks` TEXT NOT NULL DEFAULT '{}' AFTER `collect_parameters`, ADD COLUMN `cookie_lifetime` VARCHAR(64) NOT NULL DEFAULT '+30 days' AFTER `webhooks`;

Columns added (see attached).

Error message after attempting to edit the Affiliate Cookie Lifetime was observed.

Fatal error: 1054 - Unknown column 'webhook' in 'SET' update lcry_affiliates set status = 1, name = '*****', description = 'https://backwoodswizards.com/store/?affiliate_id=2', collect_parameters = '', webhook = '{\"method\":\"GET\",\"url\":\"\",\"data\":\"\"}', cookie_lifetime = '+90 days', date_updated = '2025-04-10 11:42:47' where id = 2 limit 1; in ~/includes/library/lib_database.inc.php (Line 199)

Ran SQL

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0079 seconds.)
ALTER TABLE `lcry_affiliates` ADD COLUMN `webhook` TEXT NOT NULL DEFAULT '{}' AFTER `collect_parameters`;

So that looks all set, thanks Tim!

Now I need to troubleshoot the customer vmod for "Repeat Customer" indicator for affiliate sales page :)

tim
Founder
From Sweden
Member since May 2013
tim

Man, so sorry. Indeed the word "webhooks" should be singular "webhook". You did the right thing👍

Merchant
From United States
Member since Apr 2023

No worries, Tim, I enjoy learning new things!

  $affiliate_options = database::query(
    "select * from ". DB_TABLE_PREFIX ."affiliates
    order by name;"
  )->fetch(function($affiliate) {
    return [$affiliate['name'], $affiliate['id']];
  });

This bit of code benefits greatly from fetch_all instead of fetch

tim
Founder
From Sweden
Member since May 2013
tim

Ooh thank you. Very good I will take it :)

tim
Founder
From Sweden
Member since May 2013
tim

While we are diving into this. Can you also change this line in vmod:

    $order->data['affiliate_id'] = (int)$_COOKIE['affiliate_id'];

To

    $order->data['affiliate_id'] = (int)$affiliate_cookie['id'];
Merchant
From United States
Member since Apr 2023

I have updated my vmod section for page pages/ajax/checkout_summary.inc.php to include the new code!

Thanks Tim!

You
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.