close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

eCart - get total items of specific category

Thread began 9/23/2011 10:02 pm by randy153228 | Last modified 9/27/2011 1:10 pm by randy153228 | 1458 views | 4 replies |

randy153228

eCart - get total items of specific category

I am trying to get the total number of items with a specific category that are currently in the cart to give the client an idea of how many more they need to add in order to receive a discount. How do I do that. I tried modifying a discount rule to do it, but I get PHP errors.

Fatal error: Call to undefined function ConditionalTotal() in /home/createwi/public_html/store/crystals/index.php

$discountSchedule = array(16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,256,272,288,304);
function getDiscount($cartNumber){
if (true && ($cartNumber > 0) && ($cartNumber < $discountSchedule[0])) {
$numberRequired = ($discountSchedule - $cartNumber);
$discountMessage = 'You are just '.$numberRequired.' crystals away from a $16 discount.';
}

}

Then the call from the page.
<?php getDiscount(ConditionalTotal("Quantity", "Category", "1")); ?>

The cart is included at the top of the page.

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy of the page this code is on in a zip archive so I can see the code in context.

Sign in to reply to this post

randy153228

Index file

Attached is the code for the script I am trying to get to work.

Attached Files
index.zip
Sign in to reply to this post

Jason ByrnesWebAssist

this code:
<?php getDiscount(ConditionalTotal("Quantity", "Category", "1")); ?>


should be:
<?php getDiscount(CreateWindow->ConditionalTotal("Quantity", "Category", "1")); ?>

Sign in to reply to this post

randy153228

Originally Said By: Jason Byrnes
  this code:
<?php getDiscount(ConditionalTotal("Quantity", "Category", "1")); ?>


should be:
<?php getDiscount(CreateWindow->ConditionalTotal("Quantity", "Category", "1")); ?>  



Thanks Jason, Worked Perfectly!

I changed the function a bit, but it works exactly like I wanted:
<?php

function getDiscount($cartNumber){
$discountSchedule = array(0,16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,256,272,288,304);
for($i = 0; $i < count($discountSchedule); $i++) {
if (true && ($cartNumber > $discountSchedule[$i]) && ($cartNumber < $discountSchedule[($i + 1)])) {
$numberRequired = floatval($discountSchedule[$i + 1] - $cartNumber);
if($i == 0){
$discount = 'a $16 discount.';
} else {
$discount = 'an additional $16 discount.';
}
$discountMessage = 'You are just '.$numberRequired.' crystals away from '.$discount;
echo $discountMessage;
}
}
}
?>

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