Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WooCommerce new order email trigger #15

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions thawani-pay-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ public function process_payment( $order_id ) {
$invoice_id = $response['data']['invoice'];
update_post_meta( $order_id, 'session_id', $session_id);
update_post_meta( $order_id, 'invoice_id', $invoice_id);

$redirect_url = $thawani_api . "/pay/" . $session_id. '?key=' . $publishable_key;
return array(
'result' => 'success',
Expand Down Expand Up @@ -458,7 +457,12 @@ function woocommerce_process_thawani_payment() {
$order->payment_complete();
$order->add_order_note('Thawani payment successful.');
$woocommerce -> cart -> empty_cart();
wc_add_notice( __('Thank you for shopping with us.', 'woothemes') . "order placed successfully", 'success' );

// Trigger WooCommerce new order and order processing email to Client and Customer
$wc_emails = WC()->mailer()->get_emails();
$wc_emails['WC_Email_New_Order']->trigger( $order_id );
$wc_emails['WC_Email_Customer_Processing_Order']->trigger( $order_id );
wc_add_notice( __('Thank you for shopping with us.', 'woothemes') . " Order placed successfully", 'success' );
} else if($payment_status == 'unpaid') {
$order->add_order_note('The Thawani transaction has been declined.');
wc_add_notice( __('Thank you for shopping with us.', 'woothemes') . "However, the transaction has been declined.", 'error' );
Expand Down