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

Set option price dynamically

Started by rkonakart, July 17, 2012, 06:18:16 pm

Previous topic - Next topic

rkonakart

Dears,

I want to set option price dynamically. I am trying to set it by this way but it is not working:

In AddToCartSubmitAction:

OptionIf[] opts = null;
            if (acf.getNumOptions() > 0)
            {
                OptionIf[] localOpts = new OptionIf[acf.getNumOptions()];
                for (int i = 0; i < acf.getNumOptions(); i++)
                {
                    OptionIf o = new Option();
                    o.setId(acf.getOptionId(i));
                    o.setValueId(acf.getValueId(i));

                    o.setPrice0(new BigDecimal(acf.getSelectedRatePlanPrice()));
                    o.setPriceExTax(new BigDecimal(acf.getSelectedRatePlanPrice()));
                    o.setPriceIncTax(new BigDecimal(acf.getSelectedRatePlanPrice()));
                    localOpts = o;
                }
                opts = localOpts;
            }

any help plssss

rkonakart

BTW I don't want to use basket.setFinalPriceExTax(new BigDecimal("7777"));

I need to send option price not the the basket price.

ryan

We allow you to set the final price to be whatever you want it to be.  If you want to set your own price then you should calculate it yourself based on your own option prices and just set it. We don't save the option price in the database but just the option id and the option value id which is why your code doesn't work.


rkonakart

Thanks ryan for your answer. But is it means that each time I will need to calculate all products added to the bag and set the basket price??

I mean for example if the user needs to see each product price in the checkout page, how I will view it?

My problem is that I have many options that reflect in the product price in a not linear way. which means that I am getting options price using another way. I need when user chooses some options I set the price for the selected options, as if i will set option (+/-) value with my price, do you understand me?

ryan

You only need to set the price yourself for the basket items where you use the non linear option prices. For other basket items, KK will set the price. Whether you set the price or KK sets the price, the total is always calculated by KK.

rkonakart

thanks ryan, I think my problem is solved. I am trying different scenarios.

Thanks alot for your help:)