Page 1 of 1
How to add Engraving option and Price for it
Posted: Mon Jul 27, 2009 2:24 pm
by Mike718NY
About 2,000 products have "Engraving Available".
The charge is $9.99 for it.
So when someone chooses Engraving, I need to charge $9.99 for it.
How do I set this up in AC7?
I played around with Product Templates and Options and Variants but can't figure it out?
Re: How to add Engraving option and Price for it
Posted: Mon Jul 27, 2009 3:11 pm
by jmestep
Out of the box, you would have to add an option- no fun for that many products.
Or you would have to custom code a template to do that. You would have to change code on the product page, the basket page, wishlist page.
Re: How to add Engraving option and Price for it
Posted: Tue Jul 28, 2009 7:22 am
by Mike718NY
thanks Judy,
>> Out of the box, you would have to add an option - no fun for that many products.
If I add a product Option, the user would have to select it, otherwise $9.99 won't be charged
if I just have a textbox displayed (from a Product Template).
If I added an "Engraving" item product for $9.99, . .
is it possible to check for an empty string in the textbox, and if not empty,
add the "Engraving" to the cart?
>> Or you would have to custom code a template to do that.
Not sure where to even begin with that.
Re: How to add Engraving option and Price for it
Posted: Tue Jul 28, 2009 10:52 am
by jmestep
Yes, that would work in a product template, but you would have to change the code when it gets added to the basket and wishlist and a move from wishlist to basket.
Re: How to add Engraving option and Price for it
Posted: Tue Jul 28, 2009 1:08 pm
by Mike718NY
I think I might need to add an "Engraving" field to the Products table.
Then in BuyProductDialog:
if (_Product.Engraving)
{
pnl1.Visible = true;
}
<asp:Panel runat="server" ID="pnl1" Visible="false">
ENGRAVING AVAILABLE
Then add a button for "Add Engraving" and then show a
text box and add some code to flag it somehow to charge $9.99
</asp:Panel>
Re: How to add Engraving option and Price for it
Posted: Wed Jul 29, 2009 9:19 am
by ZLA
I just posted a purely javascript idea in a thread linked to this one:
viewtopic.php?f=45&t=11879&p=51060#p51060. My idea uses an option field and a product template text field and javascript to enable / disable the text box.
I did not write the code or implement this. It is just a concept at this point. HTH.
Re: How to add Engraving option and Price for it
Posted: Thu Jul 30, 2009 8:10 am
by Mike718NY
I found a possible way to do this but I don't know how to check for it.
When adding the product to the Cart, I can check for the Product Template
"Personalization" (ID 4 in the database):
Code: Select all
if (_Product.ProductTemplateId == 4)
{
// find the TextBox when adding to cart and check if
// it is not empty
// If TextBox has text:
// add a product : "Engraving - $9.99" to cart
}
I need to somehow check to see if the TextBox is NOT empty. If it is not,
I would need to add another product, the $9.99 for the Engraving charge, to the Cart.
I know this can be done because if you add a product with Personalization (a TextBox)
to the Cart and you DON'T add text to it, it will increase the Quantity of that same product
if it is already in the cart. But if there is text, it will be a different item with a Quantity of one.
The name of the Product Template is shown in the Cart like: "Personalization:", . .
so there has to be some way to check for the contents of that textbox.
I'll need the help of AbleCommerce developers here because this code is kind of complicated.
I really need to solve this because it is holding me back. Thanks
Re: How to add Engraving option and Price for it
Posted: Thu Jul 30, 2009 11:24 am
by Mike718NY
I think this might do it (in ProductHelper.cs):
Code: Select all
public static void CollectProductTemplateInput(OrderItem item, Control container)
{
.....
ProductTemplate template = item.Product.ProductTemplate;
if (template != null)
{
......................
//SEE IF WE CAN LOCATE THE CONTROL
WebControl inputControl = (WebControl)PageHelper.RecursiveFindControl(container, input.UniqueId);
if (inputControl != null)
{
OrderItemInput itemInput = new OrderItemInput();
itemInput.Name = input.Name;
itemInput.InputValue = input.GetControlValue(inputControl);
********* ADDED ***************************************
if (product.ProductTemplateId == 4)
{
if (itemInput.InputValue.Trim() != "")
{
// **** NEED TO SET A FLAG TO ADD "ENGRAVING $9.99" TO CART
// Session[Engraving] == "True";
}
}
item.Inputs.Add(itemInput);
}.........
I tried using a Session variable but they are not working here.
Gave "Object not found" when I tried to read it. I even tried this:
System.Web.HttpContext.Current.Session["Engraving"] = itemInput.InputValue.Trim();
I need someway of flagging this and then adding "Engraving $9.99" to cart.
Any ideas?
Re: How to add Engraving option and Price for it
Posted: Thu Jul 30, 2009 11:45 am
by ZLA
Mike718NY wrote:
Code: Select all
********* ADDED ***************************************
if (product.ProductTemplateId == 4)
{
if (itemInput.InputValue.Trim() != "")
{
// **** NEED TO SET A FLAG TO ADD "ENGRAVING $9.99" TO CART
// Session[Engraving] == "True";
}
}
item.Inputs.Add(itemInput);
}.........
I think you want
or
Code: Select all
System.Web.HttpContext.Current.Session["Engraving"] = "True";
Single = is for assignment, Double == is for conditional.
Also, you will need to watch the type of value. You're assigning a string "True" as opposed to the boolean value of true.
Re: How to add Engraving option and Price for it
Posted: Thu Jul 30, 2009 12:17 pm
by Mike718NY
thanks ZLA, . . I actually had the code right, . . I just made a typo in the post with the " = =" and the missing "".
Re: How to add Engraving option and Price for it
Posted: Fri Jul 31, 2009 7:01 am
by Mike718NY
This is not going to work after all.
I figured out how to add the "Engraving $9.99" product to the cart when the Personalization template is used (detected), but the user could just delete it from the cart and that would be a problem.
I'm stuck now. I can't go any further with this new cart.
The Engraving feature is a must with this cart.