PDA

View Full Version : Discount based on options or sets from dropdown


Travis250923
03-07-2009, 09:30 PM
What is the easiest way w/E-cart to provide discounts based on options in say a drop down menu? For example I have an auto part that comes in driver side, passenger side, or both as a set. If they select driver side or passenger side it is the same price but if the choose the set they get a $5 discount.

Ray Borduin
03-09-2009, 07:59 AM
Are you using a database or is the page static?

Would this show as two items in the cart or one item with the price = (2*[price])-5?

There are a variety of ways this could be handled and different options are available depending on the specific development conditions you are working in and the end user experience you expect. The easiest way depends on how many of these discounts are offered and how the surrounding store works.

Travis250923
03-10-2009, 07:27 AM
I'm using a database and trying to dynamically generate the options. I'm trying to get this to show as one product which is where part of the problem is coming in. I can see how to do this if they are separate items via ecart. Basically I'd look for the presence of both in the cart and apply a discount. But what if I don't want two items?

I'm running into a few other snags, unrelated to eCart, such as how to setup the database so I can associate these options with some but not all of the products. I'm looking over the sample database for the shoe store but that doesn't seem to really help me because it looks like all shoes would be given a size and a color. For example product A can be Driver side, passenger side, or both but product B has no options. Any thoughts on this?

Ray Borduin
03-10-2009, 11:49 AM
You would eventually populate the options list with the options id. Then create your own recordset that filters based on the selected option and returns whatever information you need to dynamically change with that option... including price, name, quantity, or whatever else you want that list to control.

There are a variety of ways to do it. One way might be to have an option group table and an options table. The product table would have the option group assocated with it, and the options in that group are then associated to the group. Each product could then have unique options, or share options with other products that have the same option groups.

Travis250923
03-11-2009, 08:23 PM
So I think I understand but my options recordset that I am trying to use to sort the options list is bringing all options twice. I set my database to have an ItemsOptionID colum in my Items table that matches with the ItemsOptionID column in the Options table so I can associate the two.

I then put in three options in the options table with an ItemsOptionID of 1:
-Driver Side
-Passenger Side
-Set

I then set the ItemsOptionID for two individual products to be 1. I attached screenshots of my recordset and how it displays on the test page. Here is what I used on the recordset:

SELECT *
FROM (itemoptions INNER JOIN items ON itemoptions.ItemOptionsID=items.ItemOptionsID)
WHERE itemoptions.ItemOptionsID = items.ItemOptionsID

Thanks again for the help

Ray Borduin
03-12-2009, 07:14 AM
SELECT *
FROM (itemoptions INNER JOIN items ON itemoptions.ItemOptionsID=items.ItemOptionsID)

is all you need... the inner join is the equivalent of the where statement. If it shows twice, that is because you have two itemoptions for that ItemOptionsID, or it is showing more than one ItemID. Make sure to also filter this recordset by the item you are displaying so that you are only showing the options for that item.

Travis250923
03-12-2009, 03:49 PM
it is likely more than one ItemsID as I thought the WHERE statement was filtering based on ItemID. How do I associate the options drop down with the specific item they are for? I think this is a little beyond me but you never know what you need to know until a client asks for it.

Oh and this is on the products page as created through the eCart getting started guide.

Travis250923
03-12-2009, 08:21 PM
So I was originally trying to apply these options to the product page but decided it would be better/easier to try it on the product details page because now I know the exact item I want the options for. My items recordset (rsItems) is filtered by the URL ID and if I can get my options recordset (rsOptions) to filter by the ItemOptionsID in the items recordset that would be great. I tried this:

SELECT *
FROM itemoptions
WHERE ItemOptionsID = MMColParam

MMColParam has a default value of -1 and a Runtime value of $row_rsItems['ItemOptionsID'].

When I test this I get nothing for my options.

Ray Borduin
03-13-2009, 07:26 AM
How are you testing.... when you test it in DW, it uses the default value, so -1 would be expected to return no results.

Ray Borduin
03-13-2009, 07:29 AM
Also the runtime value you probably can't just set to a recordset field like that... unfortunately the DW code won't work like this.

Try setting it to a $_POST, $_GET, or $_SESSION value and just set the value above the recordset manually by hand coding so for example you could set the runtime value to $_GET['TEMPIDFORRS'] and add the code on top of the page:

<?php
$_GET['TEMPIDFORRS'] = $row_rsItems['ItemOptionsID'];
?>

Ray Borduin
03-13-2009, 07:30 AM
Also of course make sure the rsItems recordset appears before the added code, so the code should be added between the two recordsets with the rsItems recordset on top.

Travis250923
03-13-2009, 09:44 AM
Ray you're a genius. Using the $_Get worked to sort it down on the details page. Of course it also helps when I test using a product that I have assigned an ItemOptionsID to. I also applied a ShowIf region to hide if the options recordset is empty so I only get options displayed now if the item has options assigned to it. Works pretty slick.

Now I'll go back to working on my original reason for posting and hopefully I can sort out the options within eCart without to much trouble. Does anyone know if the archived technotes "eCart Calculations, Discount and Charge Rules" is still valid for the current version of eCart? I only ask because it is under the "Archived Documentation" section which hints to me it may be outdated.

Ray Borduin
03-13-2009, 10:13 AM
Everything is still valid for the most part. User interfaces have been updated and some things that were done manually may now be easier. The content is still generally good.