close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple cart buttons for a product using same quantity field

Thread began 2/10/2010 11:27 pm by hcijun384863 | Last modified 4/06/2010 8:46 am by Jason Byrnes | 3272 views | 14 replies |

hcijun384863

Multiple cart buttons for a product using same quantity field

I am trying to use three buttons such as "Buy Now", "Add to Cart", and "Wish List". Is it possible to implement such buttons for a product using same quantity field? For example, if a user enters 2 in the quantity field and clicks Wish List button, products will be saved in DB for future shopping, and if a user clicks Buy Now button, he/she sees a check out page, and if a user clicks Add to Cart button, he/she sees a normal display page.

Sign in to reply to this post

Jason ByrnesWebAssist

The add to cart and wishlist buttons should be fairly easy to accomplish, but you will have difficulties with the quantity for the buy now button since the buy now button will need to be in a separate form.


you could make the quantity field of the buy now form a hidden element and update it using javascript that is applied to the onchange event of the quantity field.


the code would look like:
onChange="document.<formName>.<hiddenQuantityField>.value = document.<formName>.<QuantityField>.value">


replace <formName> with the name of the form, remember, you will have 2 of them, so you will need to get the right one for the regular quantity field and the hidden quantity field. also replace <hiddenQuantityField> and <QuantityField> with the correct names for the form elements.

Sign in to reply to this post

hcijun384863

How to pull out wish list?

Thanks for your information about how to implement three buttons.
I am not clear about how to pull out wish list after I implement three buttons.
Could you please explain this?

Sign in to reply to this post

Jason ByrnesWebAssist

what do you mean by "pull out wish list", please clarify.

Sign in to reply to this post

hcijun384863

I mean how to create a wish list page.
Can it be done easily using ecart?

Sign in to reply to this post

Jason ByrnesWebAssist

for a wishlist, you need to use SecurityAssist to add user log in, and DataAssist to store the items into a wishlist table.


when the user logs in, a session variable is created with their ID. you will need to create a new wishlist table that is used to relate the wishlist products with the users that added them.


the structure is fairly simply:
wishlistID -Primary Key
wishlistProdID - foreign key relation to productID in products table
wishlistUserID - foregn key relation to UserID in users table.


when the wishlist button is pressed, the productID and UserID are stored in the wishlist table.

to display the wishlist, create a join query on the products and wishlist table:
SELECT products.*
FROM products
INNER JOIN wishlist
ON products.productID = wishlist.wishlistProdID
WHERE wishlist.wishlistUserID = $_SESSION['UserID']

you will need to substitute the column names in your database and the session variable name as well, this is just an example of how the query will work.

the wishlist is really just another product catalog page, the only difference is that the products are related to the user who added them to the wishlist.

Sign in to reply to this post

hcijun384863

Can't redirect to previous page

I have implemented wish list button in product detail page and it is working as expected.
For the users who has logged in, I can redirect to wish list page.
For the users who has not logged in, I am asking to log in and trying to redirect to product detail page again for wish list but it is not working. It always redirects to Profile.php page.
Could you please help me how to resolve this issue?
Partial of login.php page is as follows:

<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
$WA_Auth_Parameter = array(
"connection" => $cwconn,
"database" => $database_cwconn,
"tableName" => "dim_customer",
"columns" => explode($WA_Auth_Separator,"Email".$WA_Auth_Separator."Password"),
"columnValues" => explode($WA_Auth_Separator,"".((isset($_POST["username"]))?$_POST["username"]:"") ."".$WA_Auth_Separator."".((isset($_POST["userpassword"]))?$_POST["userpassword"]:"") .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"Customer_Code"),
"sessionNames" => explode($WA_Auth_Separator,"Customer_Code"),
"successRedirect" => "Profile.php",
"failRedirect" => "Emailpwd.php",
"gotoPreviousURL" => TRUE,
"keepQueryString" => TRUE
);

WA_AuthenticateUser($WA_Auth_Parameter);
}
?>

Sign in to reply to this post

Jason ByrnesWebAssist

the login success redirect is set by this code:
"successRedirect" => "Profile.php",


if you want to go to the detail page after login, change that to the detail page name.

Sign in to reply to this post

hcijun384863

My questions is similar to return to previous url after login.
I changed login link from product detail page to the following:
<a href="login.php?accesscheck=<?php echo (urlencode($_SERVER["PHP_SELF"].(isset($_SERVER["QUERY_STRING"])?"?".htmlentities($_SERVER["QUERY_STRING"]):"")));?>">Login</a>
as you recommended from Pickle's post.

And I changed the form tage login.php page to the following:
<form action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>" method="post" id="WAATKLogInForm">
as you recommended from Piclke's post.

But I got the page not found error.
The url is as follows:
login.php?accesscheck=%2F%7Eclothw5%2FDetail%2FDress_Jumpsuit%2F12572.php%3F

Could you please help me?

Sign in to reply to this post

Jason ByrnesWebAssist

looks like you login page is a folder down from the detail page:
login.php


try changing the login link to:
<a href="/~clothw5/login.php?accesscheck=<?php echo (urlencode($_SERVER["PHP_SELF"].(isset($_SERVER["QUERY_STRING"])?"?".htmlentities($_SERVER["QUERY_STRING"]):"")));?>">Login</a>

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...