Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AshlinRejo/c9f311a4d066dfe4773b93e175ecbc08 to your computer and use it in GitHub Desktop.
Save AshlinRejo/c9f311a4d066dfe4773b93e175ecbc08 to your computer and use it in GitHub Desktop.
Email customizer: custom code to load payment url based on payment type
<?php
/**
* Custom code shortcode
*
* This template can be overridden by copying it to yourtheme/plugin-folder-name/woo_mail/custom_code.php.
* @var $order WooCommerce order
* @var $email_id WooCommerce email id (new_order, cancelled_order)
* @var $sent_to_admin WooCommerce email send to admin
* @var $plain_text WooCommerce email format
* @var $email WooCommerce email object
* @var $attr array custom code attributes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if(isset($attr['type']) && $attr['type'] == 'payment_url'){
$payment_method = $order->get_payment_method();
//Here we are checking for bank transfer
if($payment_method == 'bacs'){
if($order->get_total() > 0){
$payment_url = 'https://www.paypal.me/hawaiianchoice/'.$order->get_total();
?>
<a href="<?php echo $payment_url ?>"><?php echo $payment_url ?></a>
<?php
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment