I have created the newsletter subscriber group on customer group, so I can apply discount to them, is there anyway to make it automatic, if someone subscribe to newsletter he/she automatically assign to newsletter subscribers group that had created?
1 Answer
What you could do is listen to the event for customer save before customer_save_before
, check to see if they are subscribing to the newsletter, If they are then you can update the group assigned to the customer and they will be saved into this new group.
The attribute for newsletter subscription is is_subscribed
and you can call setCustomerGroupId
on the customer object to update the group.