VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: psm on May 16, 2017, 20:18:52 PM

Title: Confirm email modification
Post by: psm on May 16, 2017, 20:18:52 PM
Dear all,
I am trying to modificate email text after shopper order some product from my eshop.

VM 3.2.0, Joomla 3.6.5, php 5.4.46

I would like to show my payment data like bank account etc, just when shopper chose payment by "bank transfer".

So I add this "condition if" (in components/com_virtuemart/views/invoice/mail_html_shopper.php) before data which I want to show in email. But it is not functional. Please can you advice me why?

<?php if ($this->orderDetails['paymentName']=="bank transfer") { ?>

    <tr>
   <td width="35%" class=""><strong><?php echo "IBAN:"; ?></strong></td>
   <td align="left"><?php echo "XXXXXXXXXXXXXXXXX"; ?></td>
   <td></td>
   </td>
    </tr>
     <tr>
   <td width="35%" class=""><strong><?php echo "SWIFT:"; ?></strong></td>
   <td align="left"><?php echo "XXXXXXXXXXXXXXXXX"; ?></td>
   <td></td>
    </tr>

    <?php } ?>
Title: Re: Confirm email modification
Post by: GJC Web Design on May 16, 2017, 21:40:54 PM
Quote$this->orderDetails['paymentName']=="bank transfer"

what does this test as?  is the name correct?
Title: Re: Confirm email modification
Post by: psm on May 16, 2017, 21:59:40 PM
I would like to test if chosen payment name is the same as text "bank transfer" then it will show information below.

For example when customer will choose option "cash on delivery" this information will not be shown in confirmation email for him, becuase he will pay when he will receive product.

But I want to show this information in confirmation email just when customer wants to pay before he will receive product "payment by bank transfer".
Title: Re: Confirm email modification
Post by: Jörgen on May 17, 2017, 00:20:23 AM
Hello

Are You sure about the name ?

You now talk about "payment by bank transfer".

Find it with it with:

print_r($this->orderDetails['paymentName']);
or
print_r($this->orderDetails);

Then You can see available data.

Jörgen @ Kreativ Fotografi
Title: Re: Confirm email modification
Post by: psm on May 17, 2017, 16:46:49 PM
Hello Jörgen,
I tried to use your suggested command print_r($this->orderDetails['paymentName']); and it print out the same "bank transfer" (in my language "platba prevodom").

I tried also another command print_r($this->orderDetails); nad it print out that it contains array "bank transfer".
[paymentName] => bank transfer

But this condition is still not working.

Do you know why?

thanks
Title: Re: Confirm email modification
Post by: Jörgen on May 17, 2017, 22:42:23 PM
The if statement looks OK, but test with something else instead of the table conetent. Otherwise check that the table syntax is correct for the output. If I remember correctly there is a switch now in VM to echo the order e-mails instead of sending them, but i don´t remember where I saw this mentioned. This could speed up testing.

By the way
<?php echo "IBAN:"; ?> would equal IBAN: wouldn´t it ? Why the echo ?

Jörgen @ Kreativ Fotografi
Title: Re: Confirm email modification
Post by: psm on May 18, 2017, 07:42:39 AM
Thanks. And pls, how to check if table syntax is correct? I am not very good in it. As you can see in 2nd question from you. I used worse option.
But I need to separate this two ways of payment in confirmation email somehow.
Title: Re: Confirm email modification
Post by: Jörgen on May 18, 2017, 08:10:34 AM
Hello

What error Do You get ? blank screen or no output, check the produced html and see if if contains any of Your added text.

You could also test to add:
<?php else 
           echo 
'not bank_transfer or bad test expression';
?>


To see if the if statement works or not

You could use the virtuemart_paymenymethod_id instead for a check, this is not language dependent and You can easily see the used id in the backend under payment methods. Try to see if it is available.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Confirm email modification
Post by: psm on May 18, 2017, 21:37:40 PM
Dear Jörgen,
I get no output on showed page when I use this condition. And I tried else condition and it showed message from it. So condition if is not  met.

And when I use condiotion with "virtuemart_paymentmethod_id"
<?php if ($this->cart->virtuemart_paymentmethod_id == "5") { ?>
it shows me this error:

Notice: Undefined property: VirtuemartViewInvoice::$cart in /html/com_virtuemart/invoice/mail_html_shopper.php on line 67

Notice: Trying to get property of non-object in /html/com_virtuemart/invoice/mail_html_shopper.php on line 67

I do not know what I make wrong.
Title: Re: Confirm email modification
Post by: GJC Web Design on May 18, 2017, 23:36:56 PM
there is no $cart in this view

echo out $this->orderDetails and see whats there
Title: Re: Confirm email modification
Post by: psm on May 19, 2017, 16:20:08 PM
Sorry, I have little bit mess in it. Now I tried this condition and it is working fine.   ;)

<?php if ($this->orderDetails['details']['BT']->virtuemart_paymentmethod_id == "5") { ?>

So maybe I can use this condition. But for future I would like to ask you if there is some possibility how to overcome language problem in database?

Thank you
Title: Re: Confirm email modification
Post by: Jörgen on May 19, 2017, 22:25:05 PM
Overcoming language is not hard. Only check for keys or strings that are not translated. As soon as you use strings that change value depending on language it will fail with another language. Using the key for payment id is not language dependent.

Regards

Jörgen @ Kreativ Fotografi
Title: Re: Confirm email modification
Post by: psm on May 21, 2017, 09:57:36 AM
Thanks, I will maybe need it in near future.