img

PaperCut Print Script of the Month #14 – Black Friday


In between internal training on Presto and KPAX I sat down with John and collaborated on the next idea for our famous PaperCut Print Script Of The Month.

Is it always left to the last minute? No, yes, maybe…sometimes real work gets in the way of the fun things and if we do not get any inspiration from support emails/calls for SOTM we have to start using our imagination.

With Paul enjoying £30 off a Sonos Play:1 from John Lewis and some of the support team buying cheap Amazon Echo Dots to play their Spotify playlists at home we thought a Black Friday themed Script Of The Month should be made (long live consumerism)!

Grab a cup of coffee and a biscuit (we suggest these) and we shall begin. The idea behind this script is to offer (but not advertise) discounted printing in a “flash sale” style. With different discounts applied throughout the day.

First thing to do is create a bunch of variables these will cover the discount to give, messages to show and the time to start the “flash sale”.

// Normal Discount Amount - default 5%
var DISCOUNT_PERCENT = 0.95;
// Discount Amount for "Flash sales" - default 10%
var FLASH_SALE_PERCENT = 0.90;
// Comment to show in job log
var JOB_COMMENT = "Black Friday Discount";
// Message to show the users for normal sale
var SALE_MESSAGE = "Black Friday Deal - This print job will only cost you '" + inputs.job.cost * DISCOUNT_PERCENT + "'";
// Message to show the users when the flash sale is on
var FLASH_SALE_MESSAGE = "Black Friday Flash Sale - This print job will only cost you '" + inputs.job.cost * FLASH_SALE_PERCENT + "'";
// Hour to start flash sale - Default 12pm
var FLASH_START = 16;
// Hour to end flash sale - Default 1pm
var FLASH_END = 17;
// Set flash sale to false
var FLASH_SALE = false;

Now we will need to work out if the “flash sale” is on by checking the hour the job was sent and making sure it isn’t over the end hour. To do this we will use inputs.job.date.getHours() you can also use getDays() and getMinutes() if you really wanted to. Once we have worked that out, we can change the value of FLASH_SALE to true for the next part.

// Work out if it is time for a flash sale
if (inputs.job.date.getHours() >= FLASH_START && inputs.job.date.getHours() < FLASH_END) {
  // Enable the flash sale
  FLASH_SALE = true;
}

We have a variable set that we can use to tell us if the “flash sale” is on so we can put that in an if statement then use actions.client.prompOK() to inform the user and change the cost of the job to the discounted rate using inputs.job.cost().

// If flash sale time
if (FLASH_SALE) {
  // Display the Flash Sale Message
  actions.client.promptOK(FLASH_SALE_MESSAGE,{'hideJobDetails': true});
  // Set the new cost of the job
  actions.job.setCost(inputs.job.cost * FLASH_SALE_PERCENT);
} else {
  // Display normal deal Message
  actions.client.promptOK(SALE_MESSAGE,{'hideJobDetails': true});
  // Set the new cost of the job
  actions.job.setCost(inputs.job.cost * DISCOUNT_PERCENT);
}

All that is left to do now is to add a note to the job so that we don’t forget why the discount was applied, to do this we use actions.job.addComment().

// Add comment to job so we remember why there was as discount
actions.job.addComment(JOB_COMMENT);

That is it for this month and as always the complete print script is below. If you have your own requirements for a print script and you don’t have the time or in-house experience to make it then simply contact us.

Get in touch today | sales@selectec.com

/*
* Black Friday
*
* Read more at https://www.selectec.com/papercut-print-script-of-the-month-14-black-friday/
*/

function printJobHook(inputs, actions) {
  
  // Make sure analysis is complete
  if (!inputs.job.isAnalysisComplete) {return;}
  
  // Normal Discount Amount - default 5%
  var DISCOUNT_PERCENT = 0.95;
  // Discount Amount for "Flash sales" - default 10%
  var FLASH_SALE_PERCENT = 0.90;
  // Comment to show in job log
  var JOB_COMMENT = "Black Friday Discount";
  // Message to show the users for normal sale
  var SALE_MESSAGE = "Black Friday Deal - This print job will only cost you '" + inputs.job.cost * DISCOUNT_PERCENT + "'";
  // Message to show the users when the flash sale is on
  var FLASH_SALE_MESSAGE = "Black Friday Flash Sale - This print job will only cost you '" + inputs.job.cost * FLASH_SALE_PERCENT + "'";
  // Hour to start flash sale - Default 12pm
  var FLASH_START = 16;
  // Hour to end flash sale - Default 1pm
  var FLASH_END = 17;
  // Set flash sale to false
  var FLASH_SALE = false;
  
  // Work out if it is time for a flash sale
  if (inputs.job.date.getHours() >= FLASH_START && inputs.job.date.getHours() < FLASH_END) {
    // Enable the flash sale
    FLASH_SALE = true;
  }
  
  // If flash sale time
  if (FLASH_SALE) {
    // Display the Flash Sale Message
    actions.client.promptOK(FLASH_SALE_MESSAGE,{'hideJobDetails': true});
    // Set the new cost of the job
    actions.job.setCost(inputs.job.cost * FLASH_SALE_PERCENT);
  } else {
    // Display normal deal Message
    actions.client.promptOK(SALE_MESSAGE,{'hideJobDetails': true});
    // Set the new cost of the job
    actions.job.setCost(inputs.job.cost * DISCOUNT_PERCENT);
  }
  
  // Add comment to job so we remember why there was as discount
  actions.job.addComment(JOB_COMMENT);
  
}
sotm_14_black_friday
Latest News from Ross Malyon
img

What card reader do I need for PaperCut MF?

Good question, my friends! Without knowing much about the customer's cards/fob...

Written by: Ross Malyon

More
img

Upgrading to PaperCut v20 from (really) old versions

Along with a host of impressive features, any new release of PaperCut MF also ...

Written by: Ross Malyon

More

img

We have worked with Selectec for a number of years now and they are the perfect PaperCut partner for us. The support team is fantastic and knowledgeable and the sales staff are superb. With the high level of service we get from Selectec we have no reason to consider using anyone else.

Martin Croft Direct-tec Group Ltd
Back to Top ↑