Objective: Hook and perform an action when a valid order is place with payment. This should be done before any emails are sent.
I have a Thirty Bees shop that started as Prestashop in 2012, migrated to Thirty Bees (now using version 1.6.0) and has been used successfully for our club. It includes modifications and custom fields that are stored in the ps_customer table. I use overrides and custom templates so that membership cards with a unique membership number are included in the pdf invoice generated. This pdf is sent with the order email. For existing members, this works great. For new members I need to manually assign the proper member number, then send an email with the paid invoice. I would like to automate the member number assignment before the order confirmation email is sent so it picks up the member number for the email.
I'm thinking that an override to OrderConfirmationController.php in public function displayPaymentReturn() is the best place to do this. Is that correct or is there a better place?
Proposed Approach: Below outlines the action to be performed
Detect when a paid order is placed and get the id_customer as $id_customer
If custom field 'member' in ps_customer table is not empty, exit and continue the normal process
If the order does not include the product reference "MemberDues" or "AssocMembr", exit and continue the normal process
If the order includes the product reference "MemberDues", $sql = 'SELECT MAX(member) from ps_customer WHERE member BETWEEN '1' AND '4999'"
If the order includes the product reference "AssocMembr", $sql = 'SELECT MAX(member) from ps_customer WHERE member BETWEEN '5000' AND '7999' ";
execute the sql query to obtain the largest member number, and add 1 to the result for the next member number to assign as $new_number
execute a sql query to update the member number for the customer, $sql = "UPDATEps_customer SETmember ='$new_number'WHERE id_customer ='$id_customer' ";
continue the normal process
Please comment if there is a better way to accomplish this before I march off and do the code.
Question
Rhapsody
Objective: Hook and perform an action when a valid order is place with payment. This should be done before any emails are sent.
I have a Thirty Bees shop that started as Prestashop in 2012, migrated to Thirty Bees (now using version 1.6.0) and has been used successfully for our club. It includes modifications and custom fields that are stored in the ps_customer table. I use overrides and custom templates so that membership cards with a unique membership number are included in the pdf invoice generated. This pdf is sent with the order email. For existing members, this works great. For new members I need to manually assign the proper member number, then send an email with the paid invoice. I would like to automate the member number assignment before the order confirmation email is sent so it picks up the member number for the email.
I'm thinking that an override to OrderConfirmationController.php in public function displayPaymentReturn() is the best place to do this. Is that correct or is there a better place?
Proposed Approach: Below outlines the action to be performed
Please comment if there is a better way to accomplish this before I march off and do the code.
Edited by Rhapsodymark as solved
10 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now