Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AshlinRejo/798d3e18ef2f3cdb0f59c3cceaa53084 to your computer and use it in GitHub Desktop.
Save AshlinRejo/798d3e18ef2f3cdb0f59c3cceaa53084 to your computer and use it in GitHub Desktop.
Email customizer: adding additional shortcode for custom data
/**
* To load the additional shortcode in Woo Email Template
*
* @param $shortcodes array
* @return array
* */
function woo_email_drag_and_drop_builder_load_additional_shortcode_method($shortcodes){
$shortcodes['wec_delivery_method_1'] = "To load delivery method 1 value";
$shortcodes['wec_delivery_method_2'] = "To load delivery method 2 value";
return $shortcodes;
}
add_filter('woo_email_drag_and_drop_builder_load_additional_shortcode', 'woo_email_drag_and_drop_builder_load_additional_shortcode_method', 10);
/**
* To send the additional shortcode value
*
* @param $shortcodes array
* @param $order object //might be empty for email template which doesn't has order
* @param $sending_email boolean
* @return array
* */
function woo_email_drag_and_drop_builder_load_additional_shortcode_data_method($shortcodes, $order, $sending_email){
$shortcodes['wec_delivery_method_1'] = '';
$shortcodes['wec_delivery_method_2'] = '';
if(!empty($order)){
if(method_exists($order, 'get_total')){
$total = $order->get_total();
$shortcodes['wec_delivery_method_1'] = 300+($total/100*4);
$shortcodes['wec_delivery_method_2'] = 300+$total;
}
}
return $shortcodes;
}
add_filter('woo_email_drag_and_drop_builder_load_additional_shortcode_data', 'woo_email_drag_and_drop_builder_load_additional_shortcode_data_method', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment