KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: unic1988 on January 28, 2009, 12:27:36 pm

Title: defaultCustomer.getDefaultAddr() doesn't work
Post by: unic1988 on January 28, 2009, 12:27:36 pm
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!
Title: Re: defaultCustomer.getDefaultAddr() doesn't work
Post by: unic1988 on January 28, 2009, 12:46:52 pm
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!
Title: Re: defaultCustomer.getDefaultAddr() doesn't work
Post by: trevor on January 28, 2009, 12:51:32 pm
http://www.konakart.com/configurationfaq.php#What_is_a_default_customer_

Title: Re: defaultCustomer.getDefaultAddr() doesn't work
Post by: unic1988 on January 28, 2009, 01:42:59 pm
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?
Title: Re: defaultCustomer.getDefaultAddr() doesn't work
Post by: unic1988 on January 30, 2009, 11:25:33 am
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() ?