Anyone done dynamic discounts?
Client requires updateable
discount percentage
discount cutoff date
on EACH product in a group (its an event sale)
I can LEFT JOIN the event and take a percentage and date from the event
this discount needs to be set up by the client
currently it seems everytime you want to have a discount you need to call the webdeveloper to change the cart?
I can easily get the products discount percentage and cutoffdate from a recordset (left join products and event with FK from product to event), when I get the rest of the product details for the cart
And I can create columns in the cart for Discount_Date (date) and Discount_Percentage (number) - then bind to each of the recordset values
And I can create a discount calculation
test - the values are going into the cart - OK
DiscountDate = 2010-12-31
DiscountPercentage = .1
BUT...
If I then do a discount
If Todays date is before (in box) DiscountDate (cart Column variable)
Cart Subtotal * (in box) DiscountPercentage (cart Column variable)
I DON'T get any discount
//eCart Rule
function WAEC_eCart1_Book_BeforeDate_Discount() {
$totalDiscount = 0;
if (true && ((time() <= strtotime("DiscountDate")))) {
$totalDiscount += ($this->TotalColumn("TotalPrice") * DiscountPercentage);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
manually replacing these with a date and a number causes the thing to work
any ideas?
AMEND:
As far as I can see (as a non programmer) Neither of the two variables are put into the formula
correctly
strtotime("DiscountDate") is just seeing the text "DiscountDate"
($this->TotalColumn("TotalPrice") * DiscountPercentage) doesnt see anything in DiscountPercentage
Amend by hand seems to work
would be interested in better 'ecart' way if there was one! (other than entering a manual expression - true etc)
//eCart Rule
function WAEC_eCart1_Book_Before_Date_Discount() {
$totalDiscount = 0;
if (true && ( time() <= strtotime($this->DisplayInfo("DiscountDate")) )) {
$totalDiscount += ($this->TotalColumn("TotalPrice") * ($this->DisplayInfo("DiscountPercentage")));//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule