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

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

eCart Binding....maybe?

Thread began 6/16/2009 3:52 pm by Stan | Last modified 6/19/2009 1:05 pm by Ray Borduin | 3819 views | 25 replies |

Stan

eCart Binding....maybe?

I have a product page with an add from recordset button. There are a couple of dynamic selection lists and the quantity. When I "add" part of the data never populates the eCart object. I get quantity and price but not the price from the selected size, just the first price in the selection list. I've had to tweak a bunch of stuff because the "wizard" seems to go brain dead unless I'm starting from a clean fresh project. I guess it must be a problem in the binding maybe? But I look that over and compare it with other projects where everything works and they seem identical. I'm running out of ideas about what to look for. Any thoughts?

Sign in to reply to this post

Ray BorduinWebAssist

It sounds like it has to be the bindings for the add to cart. But it is of course hard to tell without looking at a sample page and maybe the bindings code in question.

Sign in to reply to this post

Stan

This is the product name query:
<option value="<?php echo $row_rsPPitems['ItemID']?>"><?php echo $row_rsPPitems['ItemName']?></option>
When I examine the global form array it has the ItemID instead of the ItemName.

Now that was the code that wizard generated. Did I not do something right? So I changed it to:
<option value="<?php echo $row_rsPPitems['ItemName']?>"><?php echo $row_rsPPitems['ItemName']?></option>

Now the value is coming across.

There is other strange stuff too.

Sign in to reply to this post

Stan

Is it all hand coding to select the correct weight and price based on the user selection for the product size? I can't see how it's going to get set otherwise and it currently just returns the fist row of the table.

Sign in to reply to this post

Ray BorduinWebAssist

It is "hand coding" a SQL statement to return the correct weight and price from your database. Since any database structure is supported, you need to write the query to return the correct weight and price based on the users selection into a Recordset.

You don't need to hand code any php, but you do have to apply a Recordset in Advanced view and probably hand code your SELECT statement to get the value from your database based on your database structure.

Having the ItemID as the option value makes sense, because you would probably use that in the hand coded SQL statement to find the associated weight and price for that item in your database.

Sign in to reply to this post

Stan

The ItemID is actually for the product which is independent from the weight and price. Each product is available in mulitple sizes and the size determines the weight and price. If I left the ItemID as the value then that would be what gets pushed into the cart object.

I understand what I have to do now based on your reply, Thanks. It's just that I had this idea in my head that the original selections I was making when I set up the Add from Recordset would be sufficient to get the information into the Cart. So I guess what the extension does is just provide a skeleton within which a bunch more work has to be done to get the functionality unless you have a very simple store.

In the Advanced View of the Recordset, I don't even see a way to make a select with the "where" equal to the SizeID. And of course the SizeID has to be captured in a variable which is a PHP statement or two. So there would be some SQL and some PHP custom coding, albeit very simple.

Am I missing some way to use the extensions that I haven't tried or am I correct about the tweaks I have to do?

Sign in to reply to this post

Ray BorduinWebAssist

I think you are close to correct.

Try adding a parameter in simple view for the recordset first... then go to advanced view so you can see the syntax and add a more complex sql statement.

Sounds like you would need to filter by two ID's to get the correct size, weight, and price, but it should be possible.

That is correct. eCart "fills the gaps" to allow you to create eCommerce sites. It doesn't reinvent the wheel for what already exists and can work with custom code to add any and all possible features. A strong knowledge of php, Dreamweaver, and mySQL is certainly important if you are trying to stretch the capabilities of the tools.

Sign in to reply to this post

Stan

The two tables, while they have relational keys, are completely independent. I pick the product which is really just a print. Then I pick the size (other table) which determines the price and weight. So this are two separate recordsets. I've been writing SQL since before there was a "MySQL" so this shouldn't be a challenge to write a recordset based on the SizeID.

I pick the size from a drop-down selection. Then I want the price and weight based on that selection. It just doesn't seem like this should be considered one of those "gaps" that have to be filled in eCart. My problem isn't how to do it. I just think I must be missing something here because in my opinion this is a VERY simple store and eCart should do it. So does it do this without additional work SQL/PHP? I just keep thinking I must be brain dead on this or something because I would imagine this to be a very common need in a store. One choice from a selection list and corresponding price and weight all sent to the Cart by just using the extension. Yes or No? It must be yes and I'm missing it,lol.

Sign in to reply to this post

Ray BorduinWebAssist

I'm not sure what you are missing... Let's take the cart out of it for now.

You want to populate a list in dreamweaver with the results from a table (options) then you want to submit that form and filter a recordset to return the result they chose (filtered by the list selection) so that you can get the weight and price.

With or without eCart that process is the same... and if you are able to get that data you can then bind it to the shopping cart.

Sounds like you can do everything from the Recordset simple view since you are filtering with just one value.

Let me walk you through it with numbered steps so you can tell me where you are getting stuck. I'll ignore whether you have a shopping cart or not because it is irrelevant.

1) Create a recordset that contains all of the available options
2) Add a list to the page to display those options as part of a form
3) Create another recordset (I often use the same one with complex SQL but it is more simple to just do another) that is filtered by the selection in the option list and returns the associated price and weight

Are you able to accomplish those steps? As you can see they use only existing DW functionality and require no hand coding... probably not even the advanced view of the recordset just the simple one.

Once those steps are accomplished... update you add to cart and bind the price and weight fields to the recodset you created in step 3 above.

Sign in to reply to this post

Stan

1 to 3 done. 3 is maybe where I'm stuck. Here is the form code:
<form name="BPeCart_1_ATC_0" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
<input type="text" name="BPeCart_1_Quantity_Add" value="1" size="4" >

<select name="BPeCart_1_Size_Add">
<?php
do {
?>
<option value="<?php echo $row_rsPPsize['ItemSizeName']?>"> <?php echo $row_rsPPsize['ItemSizeName']?> </option>
<?php
} while ($row_rsPPsize = mysql_fetch_assoc($rsPPsize));
$rows = mysql_num_rows($rsPPsize);
if($rows > 0) {
mysql_data_seek($rsPPsize, 0);
$row_rsPPsize = mysql_fetch_assoc($rsPPsize);
}
?>
</select>

<input type="hidden" name="BPeCart_1_ID_Add" value="<?php echo $row_rsPPselected["SizeID"]; ?>" />
<input type="hidden" name="BPeCart_1_Weight_Add" value="<?php echo $row_rsPPselected['ItemSizeWeight']; ?>" >
<input type="hidden" name="BPeCart_1_Price_Add" value="<?php echo $row_rsPPselected['ItemSizePrice']; ?>" >

<select name="BPeCart_1_Description_Add">
<?php
do {
?>
<option value="<?php echo $row_rsPPitems['ItemName']?>"><?php echo $row_rsPPitems['ItemName']?></option>
<?php
}
while ($row_rsPPitems = mysql_fetch_assoc($rsPPitems));
$rows = mysql_num_rows($rsPPitems);
if($rows > 0)
{
mysql_data_seek($rsPPitems, 0);
$row_rsPPitems = mysql_fetch_assoc($rsPPitems);
}
?>
</select>
<input type="image" src="WA_eCart/Images/Pacifica/Btn4_EN_addtocart.gif" border="0" value="Add to Cart" name="BPeCart_1_ATC">
<pre>
<?php if ($_POST)
{print_r($_POST);}?>
</pre>
</form>
***********************************

And here is the recordset for the selected:

$colname_rsPPselected = "-1";
if (isset($_POST['ItemSizeName'])) {
$colname_rsPPselected = (get_magic_quotes_gpc()) ? $_POST['ItemSizeName'] : addslashes($_POST['ItemSizeName']);
}
mysql_select_db($database_connBP, $connBP);
$query_rsPPselected = sprintf("SELECT SizeID, ItemSizeName, ItemSizePrice, ItemSizeWeight FROM itemsize WHERE ItemSizeName = %s", GetSQLValueString($colname_rsPPselected, "text"));
$rsPPselected = mysql_query($query_rsPPselected, $connBP) or die(mysql_error());
$row_rsPPselected = mysql_fetch_assoc($rsPPselected);
$totalRows_rsPPselected = mysql_num_rows($rsPPselected);
************************************

I don't seem to be getting a selection. My print_r has no value for the ID, weight and price even though the value for ItemSizeName is correct. Also if I test the recordset entering the value for ItemSizeName by hand it returns the correct row.

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