close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Discount not working

Thread began 7/17/2019 3:39 pm by lr_leal239405 | Last modified 7/23/2019 11:37 pm by Ray Borduin | 50 views | 7 replies |

lr_leal239405

Discount not working

Discount not working
My discount is not being triggered: I want it to work as: If quantity of item between 6 and 10, then 5% discount for that item (should apply to each exact item).

I have :

//eCart Rule
function WAEC_eCart1_QuantityDiscount() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) >= 6) && (sizeof($this->Items) <= 10))) {
$totalDiscount += ($this->TotalColumn("TotalPrice") * 0.05);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}

Sign in to reply to this post

lr_leal239405

I noticed in the eCart object editor, for 'Discounts', there is no Condition option for 'Total number of items in the cart with same ID'

Otherwise it works with condition: 'Number of items with a specific column value',

But, I'd have to do so many items (hundreds) with differing discounts for differing amounts.

I hope I'm not confusing you. Sorry and Thanks again.

Sign in to reply to this post

lr_leal239405

I found the answer on my own posted question titled 'eCart object - applying Discounts' from years ago where I asked the same questions (:.

(Ironically it was this date - July 18).

The answer:

you will need to create 2 separate discounts for this, the first one for 5 - 9 items:


Name: 5-9 items
Triggers:
"Subtotal For Any Column"
If the subtotal of column "Quantity" is ">" a value of "0"

AND
"Subtotal For Any Column"
If the subtotal of column "Quantity" is "<=" a value of "9"

Calculation:
"Based on cart subtotal"
cart Subtotal "times" "0.3"


the next one for 10 or more items:

Name: 10 or more items
Triggers:
"Subtotal For Any Column"
If the subtotal of column "Quantity" is ">=" a value of "10"


Calculation:
"Based on cart subtotal"
cart Subtotal "times" "0.5"

Sign in to reply to this post

lr_leal239405

I have it as Condition 'Subtotal for any column' and the three levels of discounts (5% for 6 thru 10, 10% for 11 thru 20 and 15% for over 21), and it works fine, but same issue I'm trying to resolve is, I don't want the discount to apply to another items where there's only one of that item. I'm trying to change it to Calculations 'Based on column subtototal' (thinking that will work), but it keeps reverting to 'Based on the cart subtotal'.

1) Will what I'm trying to do work?
2) Why does it keep reverting back?
3) If it should work, what should the code look like instead of this:

//eCart Rule
function WAEC_eCart1_QuantityDiscount1() {
$totalDiscount = 0;
if (true && (($this->TotalColumn("Quantity") >= 6) && ($this->TotalColumn("Quantity") <= 10))) {
$totalDiscount += ($this->TotalColumn("TotalPrice") * 0.05);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule

Sign in to reply to this post

Ray BorduinWebAssist

I think you are going to have to use a combination of calculations and rules to pull this off.

I think you could add calculations:
qty_discount = (([Quantity]>=5)?([Price]*0.3):0) + (([Quantity]>=10)?([Price]*0.2):0)

Then your calculation for the discount rule would just be the subtotal of the column "qty_discount"

This would give 30% off for 5-9 and 50% off 10 or more.

Sign in to reply to this post

lr_leal239405

ok. I'll try that later. I actually spent the whole day repeating the function below for each ID (180 items x 3 discounts = 540 functions). (Wish I knew how to program better) I did it directly on the eCart1_PHP.php file though. It works, but let me see now if what you sent me will do it. Thanks.

//eCart Rule
function WAEC_eCart1_QuantityDiscount1() {
$totalDiscount = 0;
if (true && (($this->ConditionalTotal("Quantity", "ID", "1") >= 6) && ($this->ConditionalTotal("Quantity", "ID", "1") <= 10))) {
$totalDiscount += (floatval($this->GetInfo("1", "TotalPrice")) * 0.05);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}

Now, my bosses want me to make it, so that thru our Content Manager, they can add the discounts themselves (: ....uugh! I will probably need your help on that later on. It would have to be able to edit the file eCart1_PHP.php.

Sign in to reply to this post

Ray BorduinWebAssist

We can do it from a database table so they can update it from their admin control. I can show you how in a screen sharing session... it shouldn't be too hard to pull off. Just make sure they tell you exactly how they want it to work so we don't have to redo it. How we implement will depend on their exact specifications.

Sign in to reply to this post

lr_leal239405

Thanks. I hadn't seen your reply. I will be starting this soon and will post back.

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