Print Page | Close Window

Custom page add to cart with options

Printed From: ProductCart E-Commerce Solutions
Category: ProductCart
Forum Name: Customizing ProductCart
Forum Description: Exchange messages with other users that are customizing ProductCart.
URL: https://forum.productcart.com/forum_posts.asp?TID=463
Printed Date: 23-November-2024 at 6:20pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Custom page add to cart with options
Posted By: Greg Dinger
Subject: Custom page add to cart with options
Date Posted: 23-September-2006 at 10:21pm

I created this page, and the last 2 items have options for "size".
http://www.opakallc.com/bosstin.asp - http://www.opakallc.com/bosstin.asp

I find that "add to cart" (for those 2 items, the others work fine) results in a redirect to the home page instead of adding the qty to the cart.

Comparing the code to the normal detail page, I don't see a difference in terms of the form action or the input fields:
http://www.opakallc.com/store/pc/viewPrd.asp?idproduct=18 - http://www.opakallc.com/store/pc/viewPrd.asp?idproduct=18

Would someone mind shedding some light upon what I might be overlooking?

Thanks much,
Greg

 

 




Replies:
Posted By: Matt
Date Posted: 17-October-2006 at 1:29am

You will need to create on validation function for each form on the page, or modify the function to receive the form's name as a parameter.

For example , the first product with options is contained within a form named "additem6".

Therefore the function will not work unless "additem6" is part of its path.

function cdd(choice, option) {

       if (choice== 0) {

              alert ("The product cannot be added to the shopping cart.\n"+ option + " is a required option.\n");

       } else {

               document.additem6.action="/store/pc/instPrd.asp";

               document.additem6.method="POST";

               document.additem6.submit();

       }

}

 

Therefore your next product can not use the same function "cdd", since this function only works with the form "additem6".  So if the next form on the page is called "additem7" you will need a new function.

For a better, more compact alternative you could just pass the name of the form into one dynamic function.  That would look something like this:

Function Call

 

cddMulti(additem6.idOptionA.selectedIndex,'Size','additem6') ;

 

 

Function

 

function cddMulti(choice, option, formname) {

var targeForm = eval("document." + formname + "");

if (choice== 0) {

       alert ("The product cannot be added to the shopping cart.\n"+ option + " is a required option.\n");

       } else {

       targeForm.action="/store/pc/instPrd.asp";

       targeForm.method="POST";

       targeForm.submit();

       }

}

 

We hope this helps!




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net