Page 1 of 1

Custom Fields / ac_CustomFields table

Posted: Fri Oct 24, 2008 11:48 am
by laramp
Hello,
Hopefully someone has some ideas on this...I need to display a message (taxation message) on the receipt page that would be displayed according to the state of the person buying the this product (cigars).
Tobacco has a different taxation scheme than what can be utilized in the default AbleCommerce 7.0.
The taxation varies from state to state. One state charges a percentage of the total cost, other states charge a flat fee per cigar.
That being the case, my client wants to display just a message telling the buyer that an additional charge will be added to the order.
This message has to be custom for each state because I need to display the tax license number for each state and the fee whether it is per
stick or percentage.

I did create a custom table and have linked it to the ac_taxrules table but I thought it might be better to utilize an existing structure...
if at all possible... for the ease of updates...etc.

There is a table called ac_CustomFields, my question is...What is this table used for and can I use it with the ac_TaxRules table?
Is there documentation for the use of this table?
Thanks in Advance!

Re: Custom Fields / ac_CustomFields table

Posted: Fri Oct 24, 2008 12:11 pm
by mazhar
Yes you can use the ac_CustomFields to store your own information. This table is reserved and may be used in future version. There are three classes related to this table.

Stores.CustomField
Stores.CustomFieldCollection
Stores.CustomFieldDataSource

Custom field table can be used to store arbitrary data without having to create a table. The general idea is that in CustomField.TableName you will put the name of the table the data is associated with (e.g. ac_Affiliates for custom data about an affiliate). Then the ForeignKeyId value would be the affiliate ID. Then you can set FieldName (e.g. Favorite Color) and the
Field Value (e.g. Blue).

One note is that you cannot have multiple values using the same FieldName because internally it uses a dictionary structure. There can only be one instance of each "key". Here is a post with something similar as your case and also makes use of the ac_CustomFields table. Please have a look at it.
viewtopic.php?f=42&t=8651

Re: Custom Fields / ac_CustomFields table

Posted: Sun Oct 26, 2008 7:56 am
by AbleMods
mazhar wrote:Yes you can use the ac_CustomFields to store your own information. This table is reserved and may be used in future version.
That sounds a bit contradictory. Can you be more specific?

Should we not be using the table at all?

Re: Custom Fields / ac_CustomFields table

Posted: Mon Oct 27, 2008 11:57 am
by sohaib
I would think that users can safely use this table the way Mazhar has described ... but we will need to confirm from Logan whether it could cause any upgrade issues in future.

Re: Custom Fields / ac_CustomFields table

Posted: Mon Oct 27, 2008 12:02 pm
by AbleMods
sohaib wrote:I would think that users can safely use this table the way Mazhar has described ... but we will need to confirm from Logan whether it could cause any upgrade issues in future.
Let's all use it for really weird stuff and see how good he is :)

I've been very interested in leveraging the table. But with so little talk about it, I've been hesitant to commit any clients to the use of it. I appreciate you checking into it to see the impact it would have on future updates.

Re: Custom Fields / ac_CustomFields table

Posted: Mon Oct 27, 2008 12:39 pm
by Logan Rhodehamel
Everything Mazhar said was true. Just take out the part about it being "reserved". The table is there for developers to take advantage of. The primay goal of this table was to provide a place to put custom data that would not interfere with upgrades or require custom code to access.

Re: Custom Fields / ac_CustomFields table

Posted: Mon Oct 27, 2008 1:57 pm
by AbleMods
Suweet.

Thanks Logan!