Forums › Custom Emails for WooCommerce › Error when using the if option
- Support forum for the WooCommerce Additional Custom Emails & Recipients.
- This topic has 4 replies, 3 voices, and was last updated 1 year, 4 months ago by
Tom Anbinder.
-
AuthorPosts
-
November 30, 2023 at 9:27 pm #129273
Christiaan Grob
ParticipantHi, I’m using this plugin to send a manual email to my user with there order data based on meta field values.
Also, in side this email i display a table with options based on meta field values but for some reason i’m getting an error if i use the If option inside an if option. :
<table cellspacing="0" cellpadding="6" border="1" width="100%" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;width: 100%;font-family: 'Helvetica Neue',Helvetica,Roboto,Arial,sans-serif"> <tfoot> <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Via welk platform huurt huurder?</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Peerby</td> </tr> <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Peerby order #</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">[order_meta key='additional_field_205']</td> </tr> [if value1="{order_meta key='additional_field_501'}" operator="equal" value2="Ja"] <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Borg bedrag in EUR</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">[order_meta key='additional_field_563']</td> </tr> [/if] <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Huurperiode</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">[order_meta key='additional_field_806']</td> </tr> [if value1="{order_meta key='additional_field_681'}" operator="equal" value2="Nee"] <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Afleveren en/of ophalen bij klant?</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Nee</td> </tr> <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Datum en tijd voor ophalen door klant</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">[order_meta key='additional_field_989']</td> </tr> <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Datum en tijd voor terugbrengen door klant</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">[order_meta key='additional_field_630']</td> </tr> [if value1="{order_meta key='additional_field_644'}" operator="equal" value2="Locatie_Amsterdam_Amstel"] <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Locatie van items</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Locatie Amsterdam Amstel</td> </tr> [/if] [if value1="{order_meta key='additional_field_644'}" operator="equal" value2="Locatie_Amstelveen"] <tr> <th scope="row" colspan="2" align="left" style="color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Locatie van items</th> <td align="left" style="min-width: 60px;color: #636363;border: 1px solid #e5e5e5;vertical-align: middle;padding: 12px;text-align: left;border-top-width: 0px;border-left-width: 0px;border-right-width: 0px;border-bottom-width: 1px">Locatie Amstelveen</td> </tr> [/if] [/if] </tfoot> </table>
Everything is working fine but when I’m at the last part of this table then both additional_field_644 > Locatie_Amstel_Amstel and Locatie_Amstelveen are showing up in the mail. And in the email above the table there appears a line with the text: “[/if]”.
Can you explain me why this is happening? And what can i do about it?
December 2, 2023 at 9:14 am #129376Christiaan Grob
ParticipantSolved it myself. You can not use the if inside the if shortcode but you can do &.
[if value1=”{order_meta key=’additional_field_681′}” operator=”equal” value2=”Nee” & if value1=”{order_meta key=’additional_field_644′}” operator=”equal” value2=”Locatie_Amstelveen”]
So it checks of both conditions are applied at the same time
-
This reply was modified 1 year, 5 months ago by
Christiaan Grob.
December 2, 2023 at 6:04 pm #129429Christiaan Grob
ParticipantOh no, I had it wrong, it is not working. It is only checking the first if not the second one, so the & is not working and it is still showing duplicated rows. Would be nice of someone of the support would dive in to this.
December 7, 2023 at 12:36 pm #129976Moshtafizur
ParticipantHi there,
I am really sorry to know you are experiencing problems.
I have escalated this with our development team. They will get back to you as soon as they can.
Kind regards.
December 13, 2023 at 9:11 pm #130450Hi, Christiaan,
You can neste shortcodes, but not with the same name, so one of the solutions would be to create an alias for the
[if]
shortcode with a PHP snippet, e.g.,[my_if]
:add_shortcode( 'my_if', function ( $atts, $content = '' ) { if ( function_exists( 'alg_wc_custom_emails' ) && isset( alg_wc_custom_emails()->core->shortcodes ) ) { return alg_wc_custom_emails()->core->shortcodes->if( $atts, $content ); } } );
Then you can do this:
[if][my_if]...[/my_if][/if]
Please give it a try and let me know what you think.
-
This reply was modified 1 year, 5 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.