Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Optional Product Options View modes: 
User avatar
Member
Member
RobJeremy - 1/28/2014 5:53:42 PM
   
Optional Product Options
Hi everyone,

I have been utilizing the Product Options feature for products in my Kentico eCommerce website.

I have been tasked with applying a Gift Wrapping option for all products. The problem is, that this product option needs to be optional or a boolean (true/false) upon user selection, essentially rendering a Check box at a certain step during the checkout process.

As far as I can tell, the only choices are to have product options that are textboxes/textareas, which are not optional.

I would imagine that someone else has done something similar to this in Kentico. If anyone has any suggestions that would be awesome.

Thanks!
Rob

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 1/29/2014 2:15:57 AM
   
RE:Optional Product Options
Hi Brandon,

Thank you for your message.

To utilize Kentico you could eventualyl create Product option as a Dropdown list and in the product options create options for Yes and No. Which woudl represent if the wrapping will be set for the given product.

Let us know for further assistance.

Kind regards,
Richard Sustek

User avatar
Member
Member
RobJeremy - 1/29/2014 10:16:23 PM
   
RE:Optional Product Options
Hi,

Thank you for your response. I think that is a great idea and I got that ready to go.

I've been looking over the ShoppingCartItemSelector.ascx file a lot to see how product options work, and it is really cool to see how they are dynamically added in.

I have one follow up question to this. Let me ask this question in terms of a scenario.

Lets say a customer adds an item to their cart that has product options, and does not choose any of the options since they are optional.
They make their way into the Shopping Cart, and end up at a custom shopping cart step. This step essentially is an ASP Repeater which is Data Bound by the ShoppingCart.ContentTable, and is filtered by only showing cart items with product options.
Each row in the Repeater has a checkbox. If they check the box, they are essentially saying that they would like to add a specific product option.

Is there a way to update that specific shopping cart item with the product option without removing it and re-adding it to the cart? On my ProcessStep function, I have it looping through the repeater and checking to see the checkbox is checked. At this point in time I can only get it to add the product option as its own item in the cart. I would prefer it to be associated with the specific cart item that was checked.

I hope this makes sense and you are able to provide me with some insight/advice in this type of situation.

Thanks again!

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 1/30/2014 3:13:25 AM
   
RE:Optional Product Options
Hi,

Thank you for your message.

Sadly I was not able to find any suitable documentation for this scenario. I have been looking through our API and came across a property which might be what you are looking for. In ShoppingCartItemInfo class try setting the ParentProduct property. This way you should be telling that this item, which is representing the product option belong to the given Parent product.

Kind regards,
Richard Sustek

User avatar
Member
Member
RobJeremy - 1/30/2014 8:00:38 AM
   
RE:Optional Product Options
Hi again.

Thank you so much for your response. You have been very helpful.

Unfortunately, the ParentProduct property comes up with an error when I try to set it becaues it is read only. This thought though pointed me in the right direction to solve what I was tasked with.

I was browsing the COM_ShoppingCartSKU and saw the field, CartItemParentGuid. This is my golden ticket right here. I am able to set this property and it works great.

The only downfall/problem is that this new product option doesn't get deleted when I delete the parent item, on step 1 for example. Maybe there is something I can add the btnUpdate to loop through and see if the parent exists in the "remove" conditional part of that function.

I am going to post my code snippet, in case someone else is looking to accomplish some type of similar functionality.
foreach (RepeaterItem item in rptr_gift_wrap.Items)
{
System.Web.UI.WebControls.HiddenField hdn_giftWrap = (System.Web.UI.WebControls.HiddenField)item.FindControl("hdn_giftWrap");
System.Web.UI.WebControls.HiddenField hdn_giftWrapGuid = (System.Web.UI.WebControls.HiddenField)item.FindControl("hdn_giftWrapGuid");
System.Web.UI.WebControls.CheckBox cb_giftWrap = (System.Web.UI.WebControls.CheckBox)item.FindControl("cb_giftWrap");

if (cb_giftWrap.Checked)
{

ShoppingCartItemInfo addedItem = ShoppingCartItemInfoProvider.GetShoppingCartItemInfo(new Guid(hdn_giftWrapGuid.Value));

if (addedItem != null)
{
// Get cart item parameters
ShoppingCartItemParameters cartItemParams = GetGiftWrapShoppingCartItemParameters();

// Add item to shopping cart
addedItem = ShoppingCart.SetShoppingCartItem(cartItemParams);

//this sets this new item's parent
addedItem.CartItemParentGUID = new Guid(hdn_giftWrapGuid.Value);

foreach (ShoppingCartItemInfo option in addedItem.ProductOptions)
{
ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(option);
}

// Update shopping cart item in database
ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(addedItem);

ShoppingCartInfoProvider.SetShoppingCartInfo(ShoppingCart);
}

}
}

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 2/4/2014 1:33:00 AM
   
RE:Optional Product Options
Hi,

Im glad I was able to point you in the right direction.

Thank you very much for sharing this.

Let me know if you need anything else.

Kind regards,
Richard Sustek