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

Adding a $1 or $2 to the price via the SIZE Dropdown

Thread began 2/19/2010 9:02 am by dave315749 | Last modified 4/05/2010 5:14 pm by Eric Mittman | 1119 views | 9 replies |

dave315749

Adding a $1 or $2 to the price via the SIZE Dropdown

How do I set up my product page so that when someone selects a xxl it adds $1.50 to the price when added to the cart.

Its all in a database and so the size field looks like

small, medium, large, x-large

Is there a easy way i can just put

small, medium, large, (+1.50 ) x-large

And then somehow ecart will know to add 1.50 ?

What is the best way to do this?

Sign in to reply to this post

Eric Mittman

Do you have the values associated with the sizes in your db? If so you could create a new recordset to select the sizes from this table. This recordset will be used to populate a select list in your add to cart form for the size. For the value use the id of the size nad for the label use the size name.

Once this is in place you will want to add another size recordset that is just like the first one but it will be filtered on the posted value of the size select list, it will post the value that the user selected.

You can then use the bindings of this second size recordset in your add to cart server behavior to add the amount to your size amount column, and the name to your name amount column. You could also just add the price to the items price rather than having a separate column for the sizes price.

This is an overview and you will need to be able to craft the recordsets and setup the select list and add to cart server behavior. If you have any questions about this please post back with specific questions starting with the first steps. It is a good idea to work on this one part at a time rather than trying to understand and implement it all at once.

Sign in to reply to this post

dave315749

Thats the only way of doing it? Because I Dont have a sepertate table set up for the sizes, because i would like keep it simple for the client,

Is there anyway to set it up as explained by my first post? so that the client could add certain amounts for certain shirts or sizes or special attributes?

Sign in to reply to this post

Eric Mittman

That is just one way to do it if you have the size data in a separate table. You can do it much more simply directly in the code by checking on the size the user selected, then adding 1.50 to the price.

The code would need to go in your add to cart server behavior that is on the page and the specific code will depend on th name and value of your size select list, here is an example of what it might look like:

php:
$ATC_itemPrice = floatval("2");// column binding for the price from the add to cart

if(isset($_POST['size']) && $_POST['size'] == 'xxl') $ATC_itemPrice += floatval("1.50");



If you post back with your add to cart page that has the size select list on it I could show you a more specific example.

Sign in to reply to this post

dave315749

Code

Sometimes they put "XXL (30 - 34)" So can the code say when it "includes" the text "XXL" instead of = ?

here is the code to the add to card, it doesn't work this way.


// WA eCart AddToCart
if (isset($_POST["wearyourin_1_ATC"]) || isset($_POST["wearyourin_1_ATC_x"])) {
$ATC_itemID = $_POST["wearyourin_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "cart.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_pdetail) && $totalRows_pdetail > 0) {
$row_pdetail = WAEC_findRecordMySQL($pdetail, "id", $ATC_itemID);
if ($row_pdetail) {
$ATC_itemName = "".$row_pdetail['title'] ."";// column binding
$ATC_itemDescription = "".$row_pdetail['shortd'] ."";// column binding
$ATC_itemWeight = floatval("".$row_pdetail['weight'] ."");// column binding
$ATC_itemQuantity = "".$_POST["wearyourin_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_pdetail['retail_price'] ."");// column binding
if(isset($_POST['wearyourin_1_Size_Add']) && $_POST['wearyourin_1_Size_Add'] == 'XXL') $ATC_itemPrice += floatval("1.50");
$ATC_itemPicture = "".$row_pdetail['image_thumb'] ."";// column binding
$ATC_itemColor = "".$row_pdetail['colors'] ."";// column binding
$ATC_itemSize = "".$_POST["wearyourin_1_Size_Add"] ."";// column binding
$ATC_itemwholesaleprice = "".$row_pdetail['wholesale_price'] ."";// column binding
$ATC_itemstocknumber = "".$row_pdetail['stock_number'] ."";// column binding
mysql_data_seek($pdetail, 0);
$row_pdetail = mysql_fetch_assoc($pdetail);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$wearyourin->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemPicture, $ATC_itemColor, $ATC_itemSize, $ATC_itemwholesaleprice, $ATC_itemstocknumber);
if ($ATC_RedirectAfter != "" && $wearyourin->redirStr == "") {
$wearyourin->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>

Sign in to reply to this post

Eric Mittman

You could adjust the line that is adding the extra price to account for this like so:

php:
$ATC_itemPrice = floatval("2");// column binding for the price from the add to cart 

if(isset($_POST['size']) && strpos($_POST['size'], 'xxl') !== false) $ATC_itemPrice += floatval("1.50");



I just added a strpos check for the xxl value within the posted element, if the xxl string is present in the posted value then it will add 1.50 to the price.

Sign in to reply to this post

dave315749

Works perfectly

Works perfectly! Thank you very much!

Sign in to reply to this post

Eric Mittman

Glad to hear that. Let us know if you have any other questions.

Sign in to reply to this post

dave315749

Doesnt work when wholesaler is logged in.

You guys has helped me set up a wholesale log in , so when the wholesaler is logged in it gives them a different price and sets the trueprice of the item to the wholesale price.

When a wholesaler is logged in this calculation does not work to add 1 dollar for a xxl shirt.

What do you need to see to be able to fix this?

Sign in to reply to this post

Eric Mittman

Please post back and describe a little about how the whole seller price is determined. Please also include a copy of your add to cart page and any alternate page that the whole seller would see. I can take a look to see if I can spot any problems.

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