How to add Engraving option and Price for it

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

How to add Engraving option and Price for it

Post by Mike718NY » Mon Jul 27, 2009 2:24 pm

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?

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: How to add Engraving option and Price for it

Post by jmestep » Mon Jul 27, 2009 3:11 pm

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.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: How to add Engraving option and Price for it

Post by Mike718NY » Tue Jul 28, 2009 7:22 am

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.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: How to add Engraving option and Price for it

Post by jmestep » Tue Jul 28, 2009 10:52 am

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.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: How to add Engraving option and Price for it

Post by Mike718NY » Tue Jul 28, 2009 1:08 pm

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>

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: How to add Engraving option and Price for it

Post by ZLA » Wed Jul 29, 2009 9:19 am

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.

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: How to add Engraving option and Price for it

Post by Mike718NY » Thu Jul 30, 2009 8:10 am

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

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: How to add Engraving option and Price for it

Post by Mike718NY » Thu Jul 30, 2009 11:24 am

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?

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: How to add Engraving option and Price for it

Post by ZLA » Thu Jul 30, 2009 11:45 am

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

Code: Select all

Session["Engraving"] = "True";
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.

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: How to add Engraving option and Price for it

Post by Mike718NY » Thu Jul 30, 2009 12:17 pm

thanks ZLA, . . I actually had the code right, . . I just made a typo in the post with the " = =" and the missing "".

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: How to add Engraving option and Price for it

Post by Mike718NY » Fri Jul 31, 2009 7:01 am

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.

Post Reply