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 2 for £3 or Buy 2 get one half price etc etc



This example uses buy 2 for £5

Add this to the Product Property PageEdit

MULTI = the number of products to apply the discount

MULTI2 = The total price of the discounted products

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

Add this to the event.change scriptEdit

//Multi Buy Deal

//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);
 int bogo = Integer.parseInt(line.getProperty("MULTI","0"));
 Double newPrice1 = new Double(line.getProperty("MULTI2", "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("MULTI","0")) > 0)) {
    product_count++;
   }
  }
  if (bogo == product_count) {
   newPrice2 = -(line.getPriceTax() * product_count) + newPrice1;



   ticket.insertLine(ticket.getLinesCount(),
     new TicketLineInfo(
      "Buy " + product_count + " for £" + (line.getProperty("MULTI2")),
      line.getProductTaxCategoryID(),
      1,
      0,
      line.getTaxInfo()));



    sales.setSelectedIndex(ticket.getLinesCount()-1);
    index = sales.getSelectedIndex();
    line = ticket.getLine(index); 
    line.setPriceTax(newPrice2);
    sales.setSelectedIndex(ticket.getLinesCount()-2);



   /* Remove BOGO property to start fresh */
   for (i = 0; i < ticket.getLinesCount(); i++) {
    if (productID.equals(ticket.getLine(i).getProductID())) {
     ticket.getLine(i).setProperty("MULTI","0");
    }
   }
  }



  sales.setSelectedIndex(ticket.getLinesCount()-1);
 }
}
//END MULTI BUY


Use with more than one product name If you want to use this script for different products - i.e. Buy any 2 products with that attribute for £X then change each:

if ((productID.equals(ticket.getLine(i).getProductID())) 

to

if ((productID.equals(ticket.getLine(i).getProductID()) != null) {

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.