Add custom placeholder to WP eCommerce Emails

If you need to customize your WP eCommerce mails you should have a look at the free WordPress plugin WP eCommerce Shop Styling. This plugins offers many placeholders for any type of dynamic values out of the box.

  • Shipping data
  • Payment details
  • Purchase date
  • Prices
  • Any kind of customer details
  • Individual checkout fields
  • Tracking ID
  • Tax

If you need to add your own placeholder try the new filters in version 2.7.

Add placeholder to the editor menu

Add the following code to your (child-) themes functions.php

function register_my_shopstyling_placeholders($invoice_placeholders){
    $invoice_placeholders[] = array(
        'fieldvalue' => 'my_placeholder',
        'fieldname'  => 'My Placeholder'
        );
    return $invoice_placeholders;
}
add_filter( 'shopstyling_editor_placeholders', 'register_my_shopstyling_placeholders');

This will add your placeholder to the editor menu

custom-placeholder-menu-entry

 

Set the placeholder content in emails and invoices

Add another piece of code to your functions.php

function my_shopstyling_placeholder_values($params){
 // you may need the purchase_id to create dynamic content
   foreach ($params as $param) {
       if( $param['unique_name'] == 'purchase_id' )
            $purchase_id = $param['value'];       
    }
   

    $params[]= array(
       'unique_name' => 'my_placeholder',
       'value'           => 'My replaced value'
     ); 
 return $params;     
}
add_filter( 'shopstyling_placeholders', 'my_shopstyling_placeholder_values');

 

2 Responses to “Add custom placeholder to WP eCommerce Emails”

  1. App Web

    Hi
    I and using e-commerce and coupons
    How can i get the “coupon-name” in my placeholder

    Regards
    AppWeb
    Denmark

    Reply
    • hannes

      Hello,
      I’m sorry this plugin doesn’t exist any more. WP E-Commerce has hardly any users now so my own focus is now on WooCommerce

      Reply

Leave a Reply