custom fields for basketItem & orderItem

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
frosty
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Thu Jul 24, 2008 3:22 am

custom fields for basketItem & orderItem

Post by frosty » Thu Jul 24, 2008 4:39 am

Hi, we are creating a product that includes a user generated design. We need to add a custom field to basketItem and orderItem ( we are using kits) From what i've been reading in the forums we have 2 options

1) add an additional field "designId" to the basketItem & orderItem.
Question 1: I'm currently using demo install. When i get the full installation will i get access to basketItemDataSource & orderItemDataSource to recompile this new property? Obviously I'm aware still makes further installations troublesome.

2) Created a custom table/class.
Is this post:
viewtopic.php?f=44&t=6712
There is talk of creating a wrapper around AC classes.

I was wondering if someone could explain how you could create a wrapper that could add the property DesignId to BasketItem. The trouble in my mind is that you need to save the basket with new property in the BasketItem

ie: The code now
Basket basket = Token.Instance.User.Basket;
basket.Items.Add(basketItem);
basket.Save();

thanks,

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: custom fields for basketItem & orderItem

Post by mazhar » Thu Jul 24, 2008 8:21 am

1) add an additional field "designId" to the basketItem & orderItem.
Question 1: I'm currently using demo install. When i get the full installation will i get access to basketItemDataSource & orderItemDataSource to recompile this new property? Obviously I'm aware still makes further installations troublesome.
These classes are inside the CommerceBuilder API. You have to purchase the API as well if you want to have the source code. You can read more about the API at
http://wiki.ablecommerce.com/index.php/ ... uilder_API
2) Created a custom table/class.
Is this post:
viewtopic.php?f=44&t=6712
There is talk of creating a wrapper around AC classes.

I was wondering if someone could explain how you could create a wrapper that could add the property DesignId to BasketItem. The trouble in my mind is that you need to save the basket with new property in the BasketItem

ie: The code now
Basket basket = Token.Instance.User.Basket;
basket.Items.Add(basketItem);
basket.Save();
This discussion sum up that you can't create the wrapper around AbleCommerce class. In fact that is about creating the wrapper around the database table. Read the following link for help
http://wiki.ablecommerce.com/index.php/ ... cess_Layer

frosty
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Thu Jul 24, 2008 3:22 am

Re: custom fields for basketItem & orderItem

Post by frosty » Thu Jul 24, 2008 9:29 am

thanks, i've tried another approach. Not glamourous but should work.
I can added a field to basketItem called ProductId and insert a record

"update ac_BasketItems set DesignId = 5 where BasketItemId = 199"

The next step is to add the designId to ac_OrderItem.

The problem is:

CheckoutResponse checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);

This method adds everything from the basket to the order and then removes it from the basket Thus lose the basket after the order is create. Therefore i can't insert the designId. Any thoughts? Maybe i could save a collection prior to the basket being deleted.

Basket basket = Token.Instance.User.Basket;
List<int> designId = new List<int>();
foreach(BasketItem bi in basket.Items)
{
designId.Add(bi.BasketItemId);
}

CheckoutResponse checkoutResponse = Token.Instance.User.Basket.Checkout(checkoutRequest);

frosty
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Thu Jul 24, 2008 3:22 am

Re: custom fields for basketItem & orderItem

Post by frosty » Thu Jul 24, 2008 11:47 am

Mazhar, Thanks for link. Though don't understand it in the context of adding a custom field to BasketItem and OrderItem.
would you mind giving a further explanation. How can i put a wrapper around a table.

much appreciated.

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: custom fields for basketItem & orderItem

Post by sohaib » Thu Jul 24, 2008 12:49 pm

Hi, we are creating a product that includes a user generated design. We need to add a custom field to basketItem and orderItem ( we are using kits) From what i've been reading in the forums we have 2 options
What I understand is that each product of yours will have an additional piece of information associated with it that you call the 'Design'. The established (and proposed) way of handling such additional information is to add them as custom fields to the products. Once you are using custom fields you do not need to worry about how your additional piece of information will be carried over in the basket and the order. When you add a product with a custom field to the basket the corresponding order item created for the product already includes the custom field information. Similarly when the basket gets converted into an order the custom field information is transfered to the order.
To my understanding the problem you are trying to solve should be tackled with product custom fields.
1) add an additional field "designId" to the basketItem & orderItem.
Question 1: I'm currently using demo install. When i get the full installation will i get access to basketItemDataSource & orderItemDataSource to recompile this new property? Obviously I'm aware still makes further installations troublesome.
Addition of additional fields to ac_Tables and then managing them would require a great deal of effort. You will most probably need to purchase the source of AC7 class files. Given the problem at hand I am so far not able to understand why you would like to go for this approach.
2) Created a custom table/class.
Is this post:
viewtopic.php?f=44&t=6712
There is talk of creating a wrapper around AC classes.
The post you are referring is actually not using the word 'wrapper' in correct sense. Actually you do not 'wrap' existing Ablecommerce db access classes. If you want to make database changes to existing tables you will have difficulty managing them without the AC7 source. If you want to add new tables you do not need the source. Here is the best reference for this purpose http://wiki.ablecommerce.com/index.php/ ... cess_Layer
thanks, i've tried another approach. Not glamourous but should work.
I can added a field to basketItem called ProductId and insert a record

"update ac_BasketItems set DesignId = 5 where BasketItemId = 199"

The next step is to add the designId to ac_OrderItem.

The problem is:
Once Basket.Checkout is called, it will convert all basket items to order items and remove them. So you have no chance of moving the value of your new field to order items table after calling the Basket.Checkout ... You can't do it before calling Basket.Checkout because by that time no order exists ... What you can probably do is keep the data in some temporary object, call Basket.Checkout(), if the checkout is successful and order is created, set the values from temporary object to the order items in the new order.
But before going through this hassle please do check the use of custom fields. I think they should be sufficient to handle your requirements.

frosty
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Thu Jul 24, 2008 3:22 am

Re: custom fields for basketItem & orderItem

Post by frosty » Thu Jul 24, 2008 1:57 pm

thanks, let me be more specific.

we are using a Kit which consist of 1 -> unlimited products
ie
- T-shirt
- design 1 (Guid)
- design 2 (Guid)
- design 3 (Guid)

each of the designs needs a unique id.

When you mention adding custom fields to product, are you referring to varients. I don't see anything in the admin that adds custom fields.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: custom fields for basketItem & orderItem

Post by mazhar » Fri Jul 25, 2008 6:32 am

In fact you can add custom fields to product using product templates. See the Catalog-> Product Templates. You can add two types of custom fields either Merchant or Customer. For merchant fields the merchant will provide a value and for customer fields the customer can provide a value.
After creating a Product Template you need to apply that template to the product. For this edit a product and from left side menu select Product Template and then select and apply your product template to the product.

frosty
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 32
Joined: Thu Jul 24, 2008 3:22 am

Re: custom fields for basketItem & orderItem

Post by frosty » Mon Jul 28, 2008 8:46 am

wow, thats its. Really appreciate your response. Very useful feature..

ok, now for bonus point. Is there a way to set up a category that will always use a product templete?

ie everything put in category Tshirt will use the product template called "ShirtTemplate"

thanks again.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: custom fields for basketItem & orderItem

Post by mazhar » Mon Jul 28, 2008 10:16 am

wow, thats its. Really appreciate your response. Very useful feature..

ok, now for bonus point. Is there a way to set up a category that will always use a product templete?

ie everything put in category Tshirt will use the product template called "ShirtTemplate"

thanks again.
You have to apply Product Template foreach product one by one there is no support for Category level.

User avatar
sohaib
Developer
Developer
Posts: 1079
Joined: Fri Jan 23, 2004 1:38 am

Re: custom fields for basketItem & orderItem

Post by sohaib » Mon Jul 28, 2008 1:33 pm

You have to apply Product Template foreach product one by one there is no support for Category level.
Could be a nice enhancement if this facility is provided.

Post Reply