Index: openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 6 Sep 2005 04:39:23 -0000 1.20 +++ openacs-4/packages/dotlrn-ecommerce/www/ecommerce/shopping-cart-add.tcl 14 Sep 2005 02:42:32 -0000 1.21 @@ -211,6 +211,52 @@ } +# If the product_id is worth $0 and free registration is allowed, skip +# the shopping cart and add the user immediately to the associated community +if { [info exists section_id] } { + set price [dotlrn_ecommerce::section::price $section_id] + + if { $price < 0.01 && [parameter::get -parameter AllowFreeRegistration -default 0] } { + dotlrn_community::add_user $community_id $participant_id + } + + # Adding these for correctness, taken from the after-checkout + # callback + + if { [lsearch [parameter::get -parameter WelcomeEmailRecipients] purchaser] != -1 } { + if {$user_id != $participant_id} { + # if they are the participant, then + # they will get the welcome email for the community + dotlrn_community::send_member_email -community_id $community_id -to_user $participant_id -type "on join" -email_send_to $user_id -override_enabled + } + } + + if { [db_0or1row member_rel { + select rel_id + from dotlrn_member_rels_full + where community_id = :community_id + and user_id = :participant_id + limit 1 + }] } { + set patron_rel_id [db_exec_plsql relate_patron { + select acs_rel__new (null, + 'membership_patron_rel', + :rel_id, + :user_id, + null, + null, + null) + }] + } + + if { [exists_and_not_null return_url] } { + ad_returnredirect $return_url + } else { + ad_returnredirect [ad_conn package_url] + } + ad_script_abort +} + # added default values to above params so that this page works # when a post from a form to shopping-cart-add originates from another domain.