Author Topic: How to manipulate shown prices  (Read 13820 times)

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
How to manipulate shown prices
« on: December 10, 2008, 04:46:42 AM »
Hello,

First fo all: Please excuse my terrible english, its not my native language.


Here are my Questions:

1.)
I need to manipulate the shown prices everywhere in the Shop depending on the User. When I took a look in the .jsp's I found some methods like getPriceIncTax(), getPriceExTax(), formatPrice()... is it possible to edit these Methods? I couldn't find the .java files containing these methods.

If this is not possible (what I am expecting) is there another way to manipulate the price that is shown to the User, without replacing every call of getPriceIncTex()/getPriceExTax()? Notice: I don't want to manipulate the Price in the Database!!!

2.)
If I manipulated the price that is shown to the user, and the user decides to buy the product, i need to insert the user-depending-price into my list of orders and not the price that is in the database. After a while of searching through the custom/ Folder i found the class CheckoutConfirmationSubmitAction.java, is this the one i need to modify for my purpose?
If this is the one could anyone tell me what I need to do to modify the price that is saved for the order?

Beside I would be very pleased If anyone could give a link to my where I can find a little Tutorial, that explains how I tell KonaKart to use my modified CheckoutConfirmationSubmitAction.class .

Big thanks for all answers,

I hope my Purpose is possible :)


trevor

  • Administrator
  • Hero Member
  • *****
  • Posts: 530
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #1 on: December 10, 2008, 06:33:29 AM »
Hi,

1) What you could do is to use the custom engine ( http://www.konakart.com/engine_customization_faq.php ) and do some post processing on the API calls that get products to change the price.

2) Yes, you have to change the prices on the order products before saving the order. The actual order is created in CheckoutDeliveryAction but at this point it hasn't been saved yet and will show the prices of the products from the DB.

The action classes are in konakart_custom.jar . During development you can put your edited classes under konakart/WEB-INF/classes/com/konakart etc. since they will get picked up before the ones in the jar. Once you are happy, you could create your own jar. Try running .\bin\ant -p from the custom directory. There will be an ant target to build the custom jars.

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #2 on: December 10, 2008, 08:46:04 AM »
Hi,

thank you for the very fast and good help! I played around with the KKCustomEng, modifiyed GetProductsPerCategory.java and it worked. Now I have one more Question:

I could solve my Problem by editing GetProductsPerCategory, GetProductsPerManufacturer, ... etc. , but I would really like only to modify one single method or class that reads a product from the database. Can you tell me if such a class exists, so that I only modify one class that is used by GetProductsPerCategory, GetProductsPerManufactuerer, ... etc. to get a Product from the database? Because if I have only one class modified it should be much easier to upgrade to newer versions of KonaKart without much Problems.

Sorry for asking such simple things, but I don't know any other way to check if such a Class exists.

Thanks for each answer!


trevor

  • Administrator
  • Hero Member
  • *****
  • Posts: 530
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #3 on: December 10, 2008, 09:06:43 AM »
No, you have to do it in the 3 or 4 API calls that get products. However, as long as your actual processing code isn't duplicated in each method, then the customisation just consists of a method call to your code in each KK API call. This should be easy to maintain.

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #4 on: December 12, 2008, 07:15:41 AM »
Hello,

I have another simple Question:

To change the Price everywhere it gets displayed I edited the following classes:

- GetAllProducts
- GetAllSpecials
- GetAlsoPurchased
- GetBestSellers
- GetProduct
- GetProductNotificationsPerCustomer
- GetProductsPerCategory
- GetProductsPerCategoryPerManufacturer 
- GetProductsPerManufacturer
- GetRelatedProducts
- GetSpecialsPerCategory
- SearchForProducts

and it works well so far.

But there is one place where my modifications take no effect, the customers shopping cart. Does anyone know which method/class gets called when KonaKart asks for the prices of the cart-items?

I tried it with 'GetBasketItemsPerCustomer'. I tried to getProduct(), manipulateIt() and setProduct() for each item in BasketIf[] but that took no effect.

Thanks for all answers!

julie

  • Administrator
  • Hero Member
  • *****
  • Posts: 539
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #5 on: December 12, 2008, 09:15:40 AM »
Try changing the finalPrice attributes of the basket items. These prices take into account the quantity and also whether any product options have been selected.

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #6 on: December 12, 2008, 09:45:29 AM »
My Problem is, that I don't know where I have to manipulate the Price, that its shown in the Shopping cart. I figured out that GetBasketItemsPerCustomer is called when a new Item gets added to the cart, but it seems not to get called when I klick on 'cart contents'.

I need one single Class / Method where I can make my pricemanipulations, like the ones I have when I call getProduct() or getProductPerCategory() etc. and beside its important that I don't have to make modifications in the jsp's.

julie

  • Administrator
  • Hero Member
  • *****
  • Posts: 539
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #7 on: December 12, 2008, 09:51:38 AM »
That's because it is saved in the session. Try modifying the attributes I mentioned in the previous post.

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #8 on: December 12, 2008, 11:08:24 AM »
Ok, it works, thank you!

But every solution brings a new Problem  :-\

When the User is not logged in "Sub-Total" shows the correct value that equals the sum of all modified product prices. But when the User is logged in it equals the sum of the product prices that are in the database.

I saw that "kkEng.getBasketMgr().getBasketTotal()" in CartTile.jsp is the method that prints Sub-Total.
Can you tell me which API call I have to modify to get the the Sub-total value that equals the sum of all modified prices, or why this method returns another value when the user is logged in?

julie

  • Administrator
  • Hero Member
  • *****
  • Posts: 539
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #9 on: December 12, 2008, 11:27:05 AM »
Take a look at ShowCartItemsAction.java .

A temporary order is created with the customer details if he is logged in or with the details of a "default" customer if he isn't logged in. If no default customer is present, then no temp order is created which is what is happening in your case when you get the correct sub total. You should see an exception in the log.

This temporary order is used to get shipping costs and any promotion discounts etc. so that a customer is aware of these before starting the checkout process. All you need to do is to comment out the line where createTempOrder() is called and you should just see your sub total .

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #10 on: December 17, 2008, 03:37:08 AM »
Ok that seems to work,thank you very much, but what happens when I klick on "checkout"?

I took a look at the URL and saw that EditCartSubmit.do gets called, so In checked EditCartSubmitAction.java for where Checkout-information is gathered, but i found nothing. Then I saw that
Code: [Select]
...

if (ecf.getGoToCheckout().equalsIgnoreCase("true"))
{
    return mapping.findForward("CheckoutDelivery");
}

...
seems to redirect to CheckoutDeliveryAction if "checkout" is klicked. Is that right? Because I can't find the place where to edit the final Price Information for the Order, please help me

julie

  • Administrator
  • Hero Member
  • *****
  • Posts: 539
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #11 on: December 17, 2008, 03:43:55 AM »
Quote
seems to redirect to CheckoutDeliveryAction if "checkout" is klicked. Is that right?

Yes

unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #12 on: December 17, 2008, 04:42:37 AM »
Well, can you tell me where I have to manipulate an OrderIf or a BasketIf? I looked through CheckoutDeliveryAction.java, CheckoutPaymentAction.java and CheckoutConfirmationAction.java but I can't figure out where to do that.
Or is there maybe the possibility to do that in an API call, that would be much better for me.

I think then it should be fnished.


unic1988

  • Jr. Member
  • **
  • Posts: 30
    • View Profile
Re: How to manipulate shown prices
« Reply #13 on: December 17, 2008, 11:00:12 AM »
If someone has the same problem: I solved it by editing createOrder.java and createOrderWithOptions.java.
Now everything seems to work  :)
____________________________________________________________

Next Question:

I want to manipulate the Prices according to the actual Customer and it works well in most cases by calling kkEng.getCustomer(sessionId);
There are only two places where it doesn't work and I can't figure out why: GetAllProducts.java and GetAllSpecials.java .

As you know the sessionId is passed as an parameter into those classes as in many other of those API-Calls too, such as GetProduct.java or GetOrder.java. Apart from GetAllSpecials/GetAllProducts, I have access to the Customer by calling kkEng.getCustomer(sessionId) if the User is logged in. So I really don't know what I am making wrong... or is it a bug that the sessionId is not available in those two classes?

Please help me


julie

  • Administrator
  • Hero Member
  • *****
  • Posts: 539
    • View Profile
    • KonaKart
Re: How to manipulate shown prices
« Reply #14 on: December 17, 2008, 12:39:39 PM »
The session id should be set to a valid value if the customer is logged in.