send mail when a customer choose a feature

  • Posts: 71
  • Thank you received: 0
11 years 8 months ago #91590

Hi

How I can do when a customer buys a product and you have chosen a feature (or an option), send an email to a third party.

That is, I have a product "A" with features 1,2,3. If the customer buys the product with the feature 2, send customer data to an email address. In addition to the store address, of course.

I have hikashop bussines

Thanks

Last edit: 11 years 8 months ago by vaughan.

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 8 months ago #91729

Hi,

You can edit the email order status notification via the menu System->Emails and add custom code for that in it after the line:
if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;

It would be something like that:

if( $item->order_product_code == 'variant option product code'){
 $mailer = JFactory::getMailer();
 $config =& hikashop_config();
 $sender = array(
  $config->get('from_email'),
  $config->get('from_name') );
 $mailer->setSender($sender);
 $mailer->addRecipient('email@domain.com');
 $mailer->setSubject('subject of the email');
 $mailer->setBody('message to the recipient');
 $mailer->Send();
}

The following user(s) said Thank You: vaughan

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
11 years 8 months ago #92655

Its possible send the email ONLY if the status is confirmed?

Thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 8 months ago #92810

Hi,

You can add the following if condition around "$mailer->Send();" like:

if($data->mail_status == 'confirmed'){
    $mailer->Send();
}

Last edit: 11 years 8 months ago by Xavier.

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
11 years 6 months ago #100064

Hi thanks for all!!

How I can do it for a custom field? A custom field in the item table

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 6 months ago #100130

Hi,

Instead of checking the product code:

if( $item->order_product_code == 'variant option product code'){
you can check the custom field value.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: vaughan

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
11 years 6 months ago #100378

Thanks for your help, but something i'm doing wrong.

This is the code:

if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                          if( $item->segurorodada == 'Seguro Rodada'){
                      $mailer = JFactory::getMailer();
                      $config =& hikashop_config();
                      $sender = array(
                      $config->get('from_email'),
                      $config->get('from_name') );
                      $mailer->setSender($sender);
                      $mailer->addRecipient('*****@gmail.com');
                      $mailer->setSubject('Seguro para Rodada');
                      $mailer->setBody('message to the recipient');
                      if($data->mail_status == 'confirmed'){
                      $mailer->Send();
                      }
                      }

segurorodada = the custom column name field in Item table
'Seguro Rodada' = The value i want to send mail with all data when a customer choose it

Last edit: 11 years 6 months ago by vaughan.

Please Log in or Create an account to join the conversation.

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #100610

I think that the issue is with :
if($data->mail_status == 'confirmed'){

instead, try like that:
if($data->order_status == 'confirmed'){

The following user(s) said Thank You: vaughan

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
11 years 6 months ago #100651

Works!!! great!! thanks a lot!! :woohoo: :woohoo: :woohoo:

Finally, how I can do that in the message body will customer data and product?
I suppose it is modifying the code:

$mailer->setBody('Message body');
but I am not able to put the right code, I am new programming

Thanks again, great support

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 6 months ago #100980

Hi,

Can you tell me what do you exactly want to put in your mail body ? :)

The following user(s) said Thank You: vaughan

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
11 years 6 months ago #100986

Thanks Mohamed

I need the product name and data from the customer's address

Regards

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
11 years 6 months ago #100997

Ok,
then all the information you need are in the "$item" and "$data" object, like for example :
- the product name : $item->order_product_name
- your customer billing address : $data->cart->billing_address which is an object containing all your address field.
- ...

Last edit: 11 years 6 months ago by Mohamed Thelji.
The following user(s) said Thank You: vaughan

Please Log in or Create an account to join the conversation.

  • Posts: 71
  • Thank you received: 0
11 years 6 months ago #102356

Hi again

The product name works fine, but the billing address no.
When y add the code for customer billing address i have this error:

Catchable fatal error: Object of class stdClass could not be converted to string in /home/zdvjkbel/public_html/demo/libraries/joomla/mail/helper.php on line 49
This is the code:
<p>
                      <?php echo $item->order_product_name;
                      if($group){
                        $display_item_price=false;
                        foreach($data->cart->products as $j => $optionElement){
                          if($optionElement->order_product_option_parent_id != $item->order_product_id) continue;
                          if( $item->segurorodada == '20'){
                      $mailer = JFactory::getMailer();
                      $config =& hikashop_config();
                      $sender = array(
                      $config->get('from_email'),
                      $config->get('from_name') );
                      $mailer->setSender($sender);
                      $mailer->addRecipient('apelado@indra.es');
                      $mailer->setSubject($item->order_product_name);
                      $mailer->setBody($data->cart->billing_address);
                      if($data->order_status == 'confirmed'){
                      $mailer->Send();
                      }
                      }
                          if($optionElement->order_product_price>0){
                            $display_item_price = true;
                          }

                        }
                        if($display_item_price){
                          if($config->get('price_with_tax')){
                            echo ' '.$currencyHelper->format($item->order_product_price+$item->order_product_tax,$data->order_currency_id);
                          }else{
                            echo ' '.$currencyHelper->format($item->order_product_price,$data->order_currency_id);
                          }
                        }
                      } ?>
                    </p>


What can i do?

Thanks again for all

Last edit: 11 years 6 months ago by vaughan.

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 6 months ago #102372

Hi,

$data->cart->billing_address

is an object, not a string.
That's why Joomla mailer returns you an error.
It can't send an email using an object, it requires some string content.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.094 seconds
Powered by Kunena Forum