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

defaultCustomer.getDefaultAddr() doesn't work

Started by unic1988, January 28, 2009, 12:27:36 pm

Previous topic - Next topic

unic1988

hello,

I want to get the default taxrate/tax from an API-Call, so I thougt it would be the best way to use the KKEngIf.getTax() method.

now there is the problem, that this method requires some parameters, so I tried it this way:

CustomerIf customer = (sessionId == null) ? this.eng.getDefaultCustomer() : this.eng.getCustomer(sessionId);
AddressIf addr = customer.getDefaultAddr();
BigDecimal taxrate = this.eng.getTaxRate(addr.getCountryId(), addr.getZoneId(), taxClassId);


the sessionId and taxClassId are always available, but I get an exception when calling customer.getDefaultAddr(); if the user is not logged in. I'm a bit confused, because the exceptionmessage is 'null'. So is the problem that the default customer doesn't have an address or is something other? Is there maybe another way to get the tax/taxrate?

I hope someone has a solution for me,

thanks for all answers!

unic1988

I found the problem: In this case the defaultCustomer is null. But that is anotherproblem, why is the defaultCustomer null? I really don't know what to do here.

please help me!


unic1988

Well I have set a default customer in Admin App: KKAdminAppliaction -> Customers ->Customers -> [new] -> set the 'Type' to 'default customer'. Then I have entered some Information that doesn't belong to any other customer I could imagine and I made one taxarea for the whole world and mapped it to 'All countries', 'All zones'. Now an defaultCustomer exists, but I still can't get the defaultCustomers address  :-\.

Any Idea?

unic1988

I solved the Problem doing the following:

KKEngIf kkEng = new KKEng();

CustomerIf customer = (sessionId == null) ? kkEng.getDefaultCustomer() : kkEng.getCustomer(sessionId);
AddressIf addr = customer.getAddresses()[0];


Now it works for the default customer, but it doesn't work if the user is logged in. customer.getDefaultAddr()  is neither working if the is not logged in nor if the user is logged in. So I tried it with CustomerIf.getAddresses() but if the user is logged in this method returns null.

Does anyone have an idea what I am making wrong?

And another Question: what is the method CustomerIf.getDefaultAddrId() for? Does it return the id of the default address in the array of addresses thats returned from CustomerIf.getAdresses() ?