baselbers / woocommerce-pdf-invoices

Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
http://wcpdfinvoices.com
GNU General Public License v3.0
73 stars 40 forks source link

Credit Note email sent twice #240

Closed DoreenChan closed 6 years ago

DoreenChan commented 6 years ago

Hi,

Credit note trigger from the 'Order action' by admin will sent twice to customer, this might cause by 2 $_POST actions will be trigger by 'Update' button being clicked.

After dig into the 'send_credit_note' function, found that duplicate email can be avoid by checking the 'post_id' instead of 'post_ID'.

if (empty($_POST['wc_order_action']) || empty($_POST['post_id'])) { // @codingStandardsIgnoreLine return; }

instead of

if ( empty( $_POST['wc_order_action'] ) || empty( $_POST['post_ID'] ) ) { // @codingStandardsIgnoreLine return; }

Please do have a check. Thanks.

baselbers commented 6 years ago

I do not get any duplicate emails. Code seems fine to me to since it is only triggering the email when the action is 'send_customer_credit_note'. Action is getting triggered when sending email within the edit order page.