• Welcome to KonaKart Community Forum. Please login or sign up.
 

how to get product price according to customer group

Started by ssharma, October 24, 2008, 12:16:02 pm

Previous topic - Next topic

ssharma

Hi,
      I want to develop code which returns price according to cutomer and its
Group. I insert price1,price2,price 3 and  also in products table and  in products_attribute table OPTIONS_VALUES_PRICE_1, OPTIONS_VALUES_PRICE_2, OPTIONS_VALUES_PRICE_3.
                I also passed that customer in baseapiexample for connection but I am geeting 
The price1 instead of price1 and price2.
I wrie this code
package org.argus.konakart;

import com.konakart.app.Basket;
import com.konakart.app.OrderStatusHistory;
import com.konakart.appif.BasketIf;
import com.konakart.appif.OptionIf;
import com.konakart.appif.OrderIf;
import com.konakart.appif.OrderStatusHistoryIf;
import com.konakart.appif.PaymentDetailsIf;
import com.konakart.appif.ProductIf;
import com.konakart.appif.ShippingQuoteIf;

/**
* This class shows how to call the KonaKart API to insert an order. Before running you may
* have to edit BaseApiExample.java to change the username and password used to log into the engine.
* The default values are root@localhost / password .
*/
public class InsertOrder extends BaseApiExample
{
   
    private static int PROD_WITH_OPTIONS_ID = 72057;

    private static int PROD_ID = 70840;

    private static int PENDING = 1;

    private static int PROCESSING = 2;

    public static void main(String[] args)
    {
        try
        {
            init();
           
            ProductIf prod = eng.getProduct(sessionId, PROD_WITH_OPTIONS_ID, DEFAULT_LANGUAGE);

            if (prod.getOpts() != null && prod.getOpts().length >= 5)
            {
               
                BasketIf item = new Basket();

                item.setProductId(PROD_WITH_OPTIONS_ID);
               
                item.setQuantity(1);
             
                //item.setOpts(opts);

                eng.addToBasket(sessionId, 0, item);
               
            }

            BasketIf item1 = new Basket();
            item1.setProductId(PROD_ID);
            item1.setQuantity(1);
            eng.addToBasket(sessionId, 0, item1);
            BasketIf[] items = eng.getBasketItemsPerCustomer(sessionId, 0, DEFAULT_LANGUAGE);
           
            System.out.println("Yhe length is :;" +items.length);
           
            OrderIf order = eng.createOrder(sessionId, items, DEFAULT_LANGUAGE);
            //System.out.println("The id isd ::" +order.getId());
           //order.getOrderProducts()[0].getProduct().setPriceExTax(arg0);
            ShippingQuoteIf[] sQuotes = eng.getShippingQuotes(order, DEFAULT_LANGUAGE);
            if (sQuotes != null && sQuotes.length > 0)
            {
                order.setShippingQuote(sQuotes[0]);
            }

            PaymentDetailsIf[] pGateways = eng.getPaymentGateways(order, DEFAULT_LANGUAGE);
            if (pGateways != null && pGateways.length > 0)
            {
                order.setPaymentDetails(pGateways[0]);
            }
            order = eng.getOrderTotals(order, DEFAULT_LANGUAGE);

           
            order.setStatus(PENDING);

           
            OrderStatusHistoryIf status = new OrderStatusHistory();
            status.setOrderStatusId(PENDING);
            status.setComments("Waiting for Payment");

            OrderStatusHistoryIf[] statusArray = new OrderStatusHistoryIf[]
            { status };
            order.setStatusTrail(statusArray);

            order.setCustom1("custom1");
            order.setCustom5("custom5");

         
            int orderId = eng.saveOrder(sessionId, order, DEFAULT_LANGUAGE);
            System.out.println("<<<<<<<<<<<<<<<<The order id is :: " +orderId);
           
            eng.changeOrderStatus(sessionId, orderId, PROCESSING,false,
            "We've got the dosh, now let's ship it");
   
            order = eng.getOrder(sessionId, orderId, DEFAULT_LANGUAGE);
           // order.setCouponCode("001");
            System.out.println(order.toString());
      } catch (Exception e)
        {
            e.printStackTrace();
        }

    }

}