Jump to content

Send email notification when customer adds product to cart


Maosan

Recommended Posts

Hi! Im in a pickle. I need to recieve an email notification when a product is added to the cart. I was using oscommerce before, and when the product was added I simply made a php mail() function with all the parameters i needed. But since prestashop (incredibly better) uses ajax to add the product, i dont want the page to reload (process my mail() function) and screw up the beautifull add to cart effect.
I need to modify the mailalerts module, and add a new function to it, but im lost on how to aproach the subject.

Any ideas??

thanks!!!

Link to comment
Share on other sites

So if I wanted to include in the mail, for example, the product that was added to the cart, I would just need to call the $id_products variable that is used in the ajax add to cart page?
I mean, i need it to send the email, but with all the pertinent information (product, atribute, qty, etc)

Thanks for the reply btw!

Link to comment
Share on other sites

you can load all this information like in other place.
but it is better put your send mail code on the top of the /cart.php so it will always be done.

You can check similar function inside PaymentModule.php for more detail.

but of course, if you have any other way do it without modifying code, that will be best.

Link to comment
Share on other sites

Thanks for the help!
I already have the mail working and everything. I can get the product name, and the qty on the email, but for some reason, the id_product_attribute is not showing. I mean, the product.tpl is suppoused to send that info through "post" method. and with that, i am able to compare it to the ps_product_combinations to get the actual "id_attribute" and from there compare to "ps_attribute_lang" to get the attribute name. All of that is sound in theory, but the ACTUAL $_POST['id_product_attribute'] is not coming through!! im stuck!!
any further input would be greatly apreatiated


Thanks a lot!

  • Like 1
Link to comment
Share on other sites

If you just load Product object from ps_product table, the attributes related is not loaded automatically.
You have manage to load this data manually.

You can refer the code in /controllers/ProductController.php on how to load the data.
look for code starting from

                /* Attributes / Groups & colors */
               $colors = array();
               $attributesGroups = $this->product->getAttributesGroups((int)(self::$cookie->id_lang));
               if (is_array($attributesGroups) AND sizeof($attributesGroups))
               {
                   $combinationImages = $this->product->getCombinationImages((int)(self::$cookie->id_lang));
                   foreach ($attributesGroups AS $k => $row)
                   {

AND KEEP GOING .....

Link to comment
Share on other sites

  • 3 years later...

Thanks for the help!

I already have the mail working and everything. I can get the product name, and the qty on the email, but for some reason, the id_product_attribute is not showing. I mean, the product.tpl is suppoused to send that info through "post" method. and with that, i am able to compare it to the ps_product_combinations to get the actual "id_attribute" and from there compare to "ps_attribute_lang" to get the attribute name. All of that is sound in theory, but the ACTUAL $_POST['id_product_attribute'] is not coming through!! im stuck!!

any further input would be greatly apreatiated

 

 

Thanks a lot!

 

Maosan would you mind sharing exactly what code you used to achieve this?

I need the exact same function!

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...