Diff -- /var/www/vhosts/3dshawn.com/affiliate.3dshawn.com/MODS/AffSoft/Onboarding.pm
Diff

/var/www/vhosts/3dshawn.com/affiliate.3dshawn.com/MODS/AffSoft/Onboarding.pm

added on local at 2026-07-01 13:47:29

Added
+45
lines
Removed
-0
lines
Context
0
unchanged
Blobs
from
to 53e5ba499219
Restore this content →
Unified diff
Naive LCS-based line diff. Additions in emerald, deletions in rose. Both sides decompressed live from BLOB_STORE.
1package MODS::AffSoft::Onboarding;
2#======================================================================
3# AffSoft -- new-user sample data seeder
4#
5# Called from signup.cgi after a successful signup. Creates a sample
6# affiliate program (in draft state) so the dashboard isn't empty.
7# Idempotent: skips if the user already has any programs.
8#======================================================================
9use strict; use warnings;
10
11sub new { return bless {}, shift }
12
13sub seed_sample_data {
14 my ($self, $db, $dbh, $DB, $user_id) = @_;
15 return unless $user_id;
16
17 # Skip if user already has programs
18 my $r = $db->db_readwrite($dbh, qq~
19 SELECT COUNT(*) AS n FROM `${DB}`.affiliate_programs WHERE merchant_user_id='$user_id'
20 ~, $ENV{SCRIPT_NAME}, __LINE__);
21 return if $r && $r->{n};
22
23 # Create a single sample program in DRAFT state so the user can edit
24 # before going live. We use a slug-with-userid prefix so multiple
25 # sample programs (one per user) don't collide on the UNIQUE slug.
26 my $slug = "sample-program-u$user_id";
27 $db->db_readwrite($dbh, qq~
28 INSERT INTO `${DB}`.affiliate_programs
29 SET merchant_user_id='$user_id',
30 slug='$slug',
31 name='Welcome Program (example)',
32 description='This is your example affiliate program. Edit it to add your own destination URL, commission, and cookie window -- or delete it and create a new one. Set the status to "active" and "listed" to put it on the public marketplace.',
33 destination_url='https://your-product.example.com/',
34 commission_type='percent',
35 commission_value_cents='2500',
36 currency='USD',
37 cookie_window_days='30',
38 status='draft',
39 auto_approve_affiliates=1,
40 is_listed=0
41 ~, $ENV{SCRIPT_NAME}, __LINE__);
42 return 1;
43}
44
451;
Keyboard: j next diff k previous diff g top G bottom r restore c compile-check ? help