This topic is set to expire on 12 júl. 2025 ×

Affiliates DB table update missing?

Merchant
Tól től United States
Tagság ápr. 2023 óta

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
Tól től Sweden
Tagság máj. 2013 óta
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
Tól től United States
Tagság ápr. 2023 óta

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
Tól től Sweden
Tagság máj. 2013 óta
tim

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

Merchant
Tól től United States
Tagság ápr. 2023 óta

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
Tól től Sweden
Tagság máj. 2013 óta
tim

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

tim
Founder
Tól től Sweden
Tagság máj. 2013 óta
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
Tól től United States
Tagság ápr. 2023 óta

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

Thanks Tim!

Te
Ez a weboldal nem használ cookie-kat és nem használ harmadik féltől származó nyomkövetési technológiát. Úgy gondoljuk, hogy jobban tudjuk csinálni, mint mások, és tényleg gondolunk az Ön magánéletére.