FANDOM


THIS MY EDITED VERSION OF ANOTHER SCRIPT POSTED HERE

It is available under the Creative Commons Share and Share Alike Licence

This script allows Buy One Get One Free on selected products. If you enter 2 of the same product it Discounts one to free with the addition of an extra line.

If you Change the variable it allows Buy 2 Get 1 Free etc etc.

Add this to the Product Property PageEdit

Set it to 0 for no discount, 2 for "BOGOF", & 3 for "buy 2 get one free".

<?xml version="1.0" encoding="UTF-8" standalone="no"?>  
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <entry key="BOGO">2</entry>
</properties>

Add this to the event.change scriptEdit

//BUY ONE GET ONE FREE SCRIPT
//Built from script - http://wiki.openbravo.com/wiki/POS_-_Buy_One_Get_One_Free_Discount
import com.openbravo.pos.ticket.TicketLineInfo;


index = sales.getSelectedIndex();
if (index != -1) {
	line = ticket.getLine(index);
	/* Buy One Get One Discount */
	int bogo = Integer.parseInt(line.getProperty("BOGO","0"));
	if (bogo > 0) {
		int product_count = 0;
		String productID = line.getProductID();
		for (i = 0; i < ticket.getLinesCount(); i++) {
			if ((productID.equals(ticket.getLine(i).getProductID())) &&
					(Integer.parseInt(ticket.getLine(i).getProperty("BOGO","0")) > 0)) {
				product_count++;
			}
		}
		if (bogo == product_count) {
			line = ticket.getLine(index);
			ticket.insertLine(ticket.getLinesCount(),
					new TicketLineInfo(
						"FREE - "+line.getProductName(),
						line.getProductTaxCategoryID(),
						1.0,
						-line.getPrice(),
						line.getTaxInfo()));
			/* Remove BOGO property to start fresh */
			for (i = 0; i < ticket.getLinesCount(); i++) {
				if (productID.equals(ticket.getLine(i).getProductID())) {
					ticket.getLine(i).setProperty("BOGO","0");
				}
			}
		}
		sales.setSelectedIndex(ticket.getLinesCount()-1);
	}
}
//END BOGOF

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.