close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Discount on Quantity of Individual items

Thread began 5/17/2011 12:53 am by enquiry272230 | Last modified 5/20/2011 7:24 am by Jason Byrnes | 3077 views | 10 replies |

enquiry272230

Discount on Quantity of Individual items

I have a site where I need to set up discounts based on the quantity of individual items in the cart.

I couldn't find a similar situation in the forum.

I have about 240 drill bits of varying styles and sizes, it's not practical to do the individual cart item discounts by ID.

I need it to work as per the following example:

In the cart :-
Over 100 x 1mm drill bits attracts a discount of $2.50 per drill
Less than 100 x 2mm drill bits gets no discount
Over 500 x 3mm drill bits gets $3.50 discount per drill

Allowed Discounts are totaled in the cart.

Basically discounts will kick in and tally where individual drill bits quantities in the cart reach certain points, e.g. 100, 500, 1000, 2000, 3000, etc. (about 6 discount formulas)

I'm OK with setting up the quantities, but at present I can only get it to work on the total quantity of drill bits in the cart, rather than the individual item quantities.
e.g. If I add only 150 x 1mm drill bits, the discount works, but when I add 50 x 2mm drill bits (no discount), the discount is applied to that quantity also, as it's working on total quantity of items in the cart.

If I use the individual item ID's method, there would be 240 X 6 discounts set up.

I hope I have explained this OK.

Sign in to reply to this post

Jason ByrnesWebAssist

you need a column in the cart to set the drill bit size, lets call this column "bitSize". for all 1mm drill bits, set that column to 1 in the add to cart button, for 2mm bits, set the column to 2, etc.

Then when setting the discounts, you can use the Number Of Items With a Specific Value trigger, For Example:

Total Number of items where "bitSize" has a value of "1" is ">" a value of "100"

and in the calculation, use Based on Items with A specific Value, for example:
Total of "Quantity" where "bitSize" has a value of "1" "times" "2.50"

Sign in to reply to this post

enquiry272230

Thanks Jason, but that's the same for this application as using the ID method as far as I can see.

There are four batches of 60 drills, each batch with different characteristics, and so I'm back to the same situation, 240 drills and each batch of 60 with 8 quantity discount formulas.

At present the wizard works using a drill's ID, as that separates each item in the cart for it's own discount calculation.

Here is the current code from the wizard for 2 rules I have set up:

//Discounts
$this->Discounts[] = new WA_eCart_Rule(urldecode("SterileShortAOConnect"), true, "WAEC_CingleCart_SterileShortAOConnect");
$this->Discounts[] = new WA_eCart_Rule(urldecode("SterileLongAOConnect"), true, "WAEC_CingleCart_SterileLongAOConnect");
//Charges
//Tax
$this->Tax[] = new WA_eCart_Rule(urldecode("GST"), true, "WAEC_CingleCart_GST");
//Shipping
}
//end node
//start node
//eCart Rule
function WAEC_CingleCart_SterileShortAOConnect() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && ($this->ConditionalTotal("Quantity", "ID", "20") >= 100) && ($this->ConditionalTotal("Quantity", "ID", "20") < 499) && ($this->ConditionalTotal("Quantity", "PriceCategory", "1") > 0))) {
$totalDiscount += ($this->ConditionalTotal("Quantity", "ID", "20") * 2.5);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_CingleCart_SterileLongAOConnect() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 0) && ($this->ConditionalTotal("Quantity", "ID", "26") >= 100) && ($this->ConditionalTotal("Quantity", "ID", "26") < 499) && ($this->ConditionalTotal("Quantity", "PriceCategory", "2") > 0))) {
$totalDiscount += ($this->ConditionalTotal("Quantity", "ID", "26") * 3.30);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule

If I could get the code to automatically source the ID of a drill bit from the item in the cart, (ID's are 20 & 26 in the above code) it would work OK.
Is this possible ??

Or is there a better method that I am not seeing?

Sign in to reply to this post

Jason ByrnesWebAssist

does the same quantity discount apply to every item?

does every item in the store use the same quantity break point?

If so then you could set a calculation, using the abs() function to set the discount amount, then use the calculation in the discount tab.

For example, on the calculation tab, create a new calculation as:
TotalItemDiscount:
((abs([Quantity] >= 100 && [Quantity] < 500)?2.50:0) + (abs([Quantity] >= 500 && [Quantity] < 1000)?3.50:0) + (abs([Quantity] >= 1000 && [Quantity] < 2000)?4.50:0)) * [Quantity]

then define the discount on the discount tab as:
Trigger: Number of unique items in the cart

Calculation: Based on multiple of column subtotal

Subtotal of column "TotalItemDiscount" "times" "1" "plus" "0"

Sign in to reply to this post

enquiry272230

Thanks, Ill try this.
However, there are four different calculation tables to use, with varying discount amounts, so hopefully I can set up four different calculations.

Sign in to reply to this post

enquiry272230

This method does not work because I have four different discount schedules.

I have added a price code to each item when added to the cart, which will determine the discount schedule to be used for that particular item.

e.g.
1mm sterile short has a base price of $16.00 and it's discount schedule code is 1
1.5mm sterile short has a base price of $16.00 and it's discount schedule code is 1
1mm sterile long has a base price of $17.00 and it's discount schedule code is 2
1.75mm sterile long has a base price of $17.00 and it's discount schedule code is 2

The break points are the same, but the discount amounts vary based on the drill type and it's price code.

Sign in to reply to this post

Jason ByrnesWebAssist

ok, well, I'm trying the best I can with the info you are providing.


What is the purpose of the discount schedule code? I dont understand this.

Please provide as much detail as you can for how this is supposed to work, i cant give an answer to the question if you are not including all of the information.

Sign in to reply to this post

enquiry272230

Sorry about the lack of data, I'll try to outline the clients requirement more clearly without too much unnecessary data.

There are 200 different medical drill bits of four different types.

Namely - Sterile Short, Sterile Long, Non-Sterile Short, Non-Sterile Long

Each type has 60 bits sized from 1mm to 6mm (1mm, 1.1mm, 1.2mm, 1.3mm, etc. )

The drills are priced by type, the four types have discount schedules based on the same quantity break point but with different discount prices per break point.

Quantity discounts are provided per individual drill bit order quantity, based on a particular drill bit size, quantity and type as added to the cart, not on the total order value or total items quantity in the cart.

e.g.
A typical order might be:
1.6mm diameter | Type 1: Sterile Short | Quantity 200 | Base Price $21.40 | Total $4280.00
1.8mm diameter | Type 1: Sterile Short | Quantity 800 | Base Price $21.40 | Total $17,120.00
1.2mm diameter | Type 2: Sterile Long | Quantity 90 | Base Price $23.00 | Total $2070.00
2.2mm diameter | Type 3: Non-Sterile Short | Quantity 2200 | Base Price $17.00 | Total $37,400.00
1.2mm diameter | Type 4: Non-Sterile Long | Quantity 600 | Base Price $17.00 | Total $10,200.00
Sub Total of Order $71,070.00

Schedule of Discounts and Quantity Break Points Per Drill:
Drill Type 1:
1 to <100 - $0.00, >=100 to <500 - $2.50, >=500 to <1000 - $3.90, >=1000 to <4000 - $5.00, etc.......
Drill Type 2:
1 to <100 - $0.00, >=100 to <500 - $3.30, >=500 to <1000 - $5.00, >=1000 to <4000 - $6.00, etc.......
Drill Type 3:
1 to <100 - $0.00, >=100 to <500 - $1.50, >=500 to <1000 - $2.50, >=1000 to <4000 - $3.00, etc.......
Drill Type 4:
1 to <100 - $0.00, >=100 to <500 - $1.50, >=500 to <1000 - $3.00, >=1000 to <4000 - $3.30, etc.......

So based on the discount schedule above, the discounts in the cart will be:
Type 1: 200 @ $2.50 = $500
Type 1: 800 @ $3.90 = $3120.00
Type 2: 90 @ $0.00 = $0.00
Type 3: 2200 @ $3.00 = $6600.00
Type 4: 600 @ $3.00 = $1800.00

Total Discounts $12,020.00

In the drill bit database (items), as well as diameter, name, base price, etc., I have placed a "type" integer for each drill so that the the correct discount can be applied based on quantity and type. Namely "PriceCategory" (see previous code example)

I can see that the existing system, as indicated earlier, works where the Drill Bit "ID" is specified in the discount and calculation formulas, however it is impractical to write a discount formula for each drill bit ID.
(See attached screen capture)

This is where I thought that perhaps the ID for the discount and calculation formula could be obtained from the Session data in cart.php, belonging to the individual cart addition, as I see by using "PHP show session data", that the "ID" and "PriceCategory" of each cart addition is there. (Session Data based on ID pasted below & attached cart image.)

I really appreciate your help on this, I can usually figure things out but this has me stumped. As you will have guessed, I am not trained coder.

I hope the above information is sufficient to ascertain if this can be achieved successfully with your eCart.

Session Data FYI:
Array ( [VisitorID] => 2 [VisitorFirstName] => Bob [VisitorLastName] => Smith [VisitorUserName] => Customer [VisitorPassword] => 3cust21 [userLevel] => 2 [CingleCart_Items] => 20|WAECART|Short AO Connect|WAECART|1.0mm x 50mm|WAECART||WAECART|0|WAECART|200|WAECART|21.4|WAECART|1|WAECART|10050455AOS|WAECART|Sterile|WAECART|1|WAECART|0|WAECART|4280|WAECART|200 Short AO Connect (20)|WAECART|500|WAECART|660&#65533;26|WAECART|Long AO Connect|WAECART|1.0mm x 110mm|WAECART||WAECART|0|WAECART|120|WAECART|23|WAECART|1|WAECART|10110455AOS|WAECART|Sterile|WAECART|2|WAECART|0|WAECART|2760|WAECART|120 Long AO Connect (26)|WAECART|300|WAECART|396 [WAEC_ContinueRedirect] => /CingleBit/order2.php?ItemCatID=4 )

Sign in to reply to this post

Jason ByrnesWebAssist

Ok, thanks, this gives me enough to go on.

add new columns to the cart object for each of the discount amount:

discountA
discountB
discountC
discountD

in the add to cart button, give these columns the discount amount for that items type, so for type 1:
discountA = 2.50
discountB = 3.90
discountC = 5.00
discountD = 6.00


for type 2:
discountA = 3.30
discountB = 5.00,
discountC = 6.00
discountD = 8.00

etc....


then create the TotalItemDiscount calculation as:
((abs([Quantity] >= 100 && [Quantity] < 500)?[discountA]:0) + (abs([Quantity] >= 500 && [Quantity] < 1000)?[discountB]:0) + (abs([Quantity] >= 1000 && [Quantity] < 2000)?[discountC]:0) + (abs([Quantity] >= 2000 && [Quantity] < 4000)?[discountD]:0)) * [Quantity]

then define the discount on the discount tab as:
Trigger: Number of unique items in the cart

Calculation: Based on multiple of column subtotal

Subtotal of column "TotalItemDiscount" "times" "1" "plus" "0"

Sign in to reply to this post

enquiry272230

Thanks for that, looks good. I should also be able to source the discount amounts from an update-able database so the client can vary the amounts from time to time.
Thanks again.

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