J-B Posted November 22, 2018 Share Posted November 22, 2018 Hi, I have a hook (its not from me) that disable sending 0.00 invoices. <?php use Illuminate\Database\Capsule\Manager as Capsule; function disable_00_invoices($vars) { $email_template_name = $vars['messagename']; # Email template name being sent $relid = $vars['relid']; # Related ID it's being sent for - client ID, invoice ID, etc... //Checking for certain template name, if so - this is our case if ($email_template_name == "Invoice Created" || $email_template_name == "Invoice Payment Confirmation") { //getting total of the invoice $data = Capsule::table('tblinvoices')->where('id',$relid)->first(); //if it is equal to '0.00' we disable email sending if (isset($data->total) && $data->total == '0.00') $merge_fields['abortsend'] = true; } return $merge_fields; } add_hook("EmailPreSend",1,"disable_00_invoices"); ?> This hook works great, but it disable invoice that is paid via credit too. I have try ... if (isset($data->total) && $data->total == '0.00') && (isset($data->credit) && $data->credit == '0.00') But this code isnt working. Anyone a idea how I can disable only 0.00 total invoices and not invoices that is paid via credit? 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted November 22, 2018 Share Posted November 22, 2018 (edited) Your condition is wrong. This one should work. if (isset($data->total) && $data->total == '0.00' && $data->credit != '0.00') Edited November 22, 2018 by Kian 0 Quote Link to comment Share on other sites More sharing options...
J-B Posted November 22, 2018 Author Share Posted November 22, 2018 Hey @Kian thanks for your Support! I will try it. 0 Quote Link to comment Share on other sites More sharing options...
J-B Posted November 27, 2018 Author Share Posted November 27, 2018 On 11/22/2018 at 3:59 PM, Kian said: Your condition is wrong. This one should work. if (isset($data->total) && $data->total == '0.00' && $data->credit != '0.00') This code is not working too. Zero Invoices is sending again to the customers. Any other solution? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted November 27, 2018 Share Posted November 27, 2018 change your if statement to the following: if ($data->total == '0.00' && $data->credit == '0.00') so it will prevent invoices with total equal "0.00" from being sent, while allow invoices paid with credit to be sent normally 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.