close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

creating a wish list for ecommerce

Thread began 3/12/2015 11:02 am by Christopher West | Last modified 1/18/2016 2:19 pm by Ray Borduin | 1728 views | 5 replies |

Christopher WestCommunity Expert

creating a wish list for ecommerce

Hi there, I was wondering if you could detail the process or if its possible with the mysqli extension.

I have an ecommerce website and my client wants a wish list page. So I assume, that the way it would work if if the customer views a product the ID of that product will be saved to a cookie on page load. And every subsequent product view the additional product ids will also be saved to a cookie - for this part I assume it would be ONE cookie and that all these product ids will be inside an array.

Then on the actual wish list page the recordset would then look at the cookie array and load them all in.

Is this process one way of doing developing this feature? are there any other way?

And could you point me in the direction to :
(a) saving a product id into a cookie array
(b) loading the cookie array into a recordset

Regards

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

for a wish list, you wouldn't save the info to a cookie, i wouldn't do it that way, i would saver the info to a wishlist database table.

first off, before they can add an item to a wishlist, they would need to be logged in. the Security Assist Authentication will save the logged in users ID to a session variable.

on the product page, add ash Add to Wish list button. And add an insert record behavior. the insert record behavior should be set to save the items ID to the wish list table, and the users ID

on the page to display the wishlist, you can use a recordset to search the wishlist table based o the users ID and join the products table to show the products for the logged in user.

Sign in to reply to this post

Christopher WestCommunity Expert

My apologies...(lack of sleep) I should have mentioned it to be a "recently viewed products" section (that will be displayed at the bottom throughout the website). So this would work on the basis that its not a logged in user. So is my understanding still correct for that feature? and if so what would be the processing in terms of loading the product ids into a cookie array and then loading them into the recordset?

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

ok, well thats a totally different can of works.

use the Set Cookie value server behavior on the item details page.

on the bindings panel, make sure there is a URL variable binding for the variable used to populate the details page. for example, if the variable that passes the ID is named id:
details.php?id=12

make sure to have a URL variable named id

in the Set Cookie value behavior, click the lightning bolt next to trigger and select the id URL variable.

set the cookie name to viewedItems

and for the value, use the following code:
<?php echo(isset($_COOKIE['viewedItems'])?$_COOKIE['viewedItems'].", ":""); ?><?php echo $_GET['id']; ?>

this will set the cookie with a comma separated list of the ID's.

now using the MySQLi recordset, use the advanced query builder to create the recently Viewed recordset using the IN comparison on the ID column and select the viewedItems cookie as the variable

Sign in to reply to this post

Christopher WestCommunity Expert

Hi, got round to trying this but having problems.

Just so that you know in the URL I am using the product name (for SEO value) but its only displaying 1 product from the cookies (also I need to find a way to only store the cookie if the product doesnt already exist in the cookie...otherwise there will be many of the same product in the cookie array as a custom could repeatedly go to the same product)

ok heres the code I have at the moment:

php:
<?php

if ((isset($_GET['Product']) && $_GET['Product'] != "")) {
    
setcookie("viewedProducts""".(isset($_COOKIE['viewedProducts'])?$_COOKIE['viewedProducts'].", ":"")  ."".$_GET['Product']  .""time()+(60*60*24*30), "/"""0);
}
?>



php:
<?php

$rsProduct 
= new WA_MySQLi_RS("rsProduct",$ecartdb,1);
$rsProduct->setQuery("SELECT * FROM products WHERE ProductName = ?");
$rsProduct->bindParam("s""".(isset($_GET['Product'])?$_GET['Product']:"")  ."""-1"); //colname
$rsProduct->execute();?>



php:
<?php

$rsViewedProducts 
= new WA_MySQLi_RS("rsViewedProducts",$ecartdb,1);
$rsViewedProducts->setQuery("SELECT * FROM products WHERE ProductName = ?");
$rsViewedProducts->bindParam("s""".$_COOKIE['viewedProducts']  ."""-1"); //colname
$rsViewedProducts->execute();
?>



php:
<?php

while(!$rsViewedProducts->atEnd()) {
?>
<a href="product.php?Product=<?php echo($rsViewedProducts->getColumnVal("ProductName")); ?>" class="b-link-fade b-animate-go"> 
<div class="item4"><img  src="images/products/<?php echo($rsViewedProducts->getColumnVal("ProductImage")); ?>" alt=""  class="responsive-image"></div>   
<div class="b-wrapper">
<h2 class="b-from-left b-animate b-delay03"><?php echo($rsViewedProducts->getColumnVal("ProductName")); ?></h2>
<p class="b-from-right b-animate b-delay03">£<?php echo($rsViewedProducts->getColumnVal("ProductPrice")); ?></p>
</div>
</a>
<?php
$rsViewedProducts
->moveNext();
}
$rsViewedProducts->moveFirst(); //return RS to first record
?>



NOTES: In the Edit Variable box on the MySQLi recordset if I check the box "comma-seperated list" I get a PHP error in browser.

here is th ecode it creates by selecting the checkbox (the value that changes is bindParam("sl", ..........

php:
<?php

$rsViewedProducts 
= new WA_MySQLi_RS("rsViewedProducts",$ecartdb,1);
$rsViewedProducts->setQuery("SELECT * FROM products WHERE ProductName = ?");
$rsViewedProducts->bindParam("sl""".$_COOKIE['viewedProducts']  ."""-1"); //colname
$rsViewedProducts->execute();
?>



When you mentioned about using the IN comparison I did look that up on Google, but was unsuccessful in finding the correct way to do it..

Please help, as nearly there.

Also is this method still ok in using the Product Name in the URL since I would rather do it that way then product ID.

Chris

Sign in to reply to this post

Ray BorduinWebAssist

This is too complex to debug in a forum post. You will need to sign up for premier support so I can work with the files directly.

Sign in to reply to this post

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...