This script set sales promotions for choosing X number of items for the price of Y
1. Add a new product “Choice 5” with promotional price and copy paste the below code in Properties:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <entry key="group">CHOICE5</entry> <entry key="count">5</entry> </properties>
2. For all the products allowed under this promotion, copy paste the below code in Properties:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> <entry key="CHOICE5"/> </properties>
Administrator Menu > Maintenance > Resources
3. Copy paste the below code in event.addline:
if(line.getProperty("group")!=null && line.getProperty("count")!=null) { ticket.setGlobalValue("GROUP-"+line.getProperty("group")+"-"+line.getProperty("count")); } else if(ticket.getGlobalValue()!=null && ticket.getGlobalValue().contains("GROUP")) { String[] values= ticket.getGlobalValue().split("-"); if(values.length==3) { i = ticket.parseInt(values[2]); if(i>0) { if(line.getProperty(values[1])!=null) { line.setSalePrice(0); line.setProperty("product.name", "--"+line.getProperty("product.name")); i=i-1; if(i==0) { ticket.setGlobalValue(null); } else { ticket.setGlobalValue("GROUP-"+values[1]+"-"+i); } } else { JOptionPane.showMessageDialog(null, "Add "+values[2]+" more items for "+ values[1], "Error", JOptionPane.PLAIN_MESSAGE); return "cancel"; } } } } Save & restart
Leave a Reply