close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

trying to run a sale

Thread began 12/07/2009 12:50 pm by barbara224891 | Last modified 12/10/2009 5:01 pm by Jason Byrnes | 867 views | 4 replies |

barbara224891

trying to run a sale

Hi, I have a site which would like to run a holiday sale. They have 30 or so items with prices that vary. During the sale, they'd like it to be 5 for $35 or 10 for $65 or 20 for $120, regardless of what items make up the 5 or 10 or 20.

I tried to make a discount equal to the cart subtotal in order to get rid of the regular prices and then a charge that had 4 tiers depending on whether total q is less than 5, between 5 and 10, etc.

I must have misspecified the discount, as the cart insists on adding in the old prices in addition to the sale prices. I've made the sale prices inactive until I can get the discount to work (some sale if things cost more, right?).

Here's the code from the cart object page which contains the discount and the 4 tiers:

function WAEC_WA_eCart1_removeregularpricesforsale() {
$totalDiscount = 0;
if (true && (($this->TotalColumn("TotalPrice") > 0))) {
$totalDiscount += (floatval($this->GetInfo("0", "TotalPrice")) * 0);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_eCart1_tier1() {
$totalCharge = 0;
if (false && (($this->TotalColumn("TotalQuantity") < 5))) {
$totalCharge += (($this->TotalColumn("TotalQuantity") * 7.5) + 0);//Result
}
return WA_eCart_FormatNumber($totalCharge, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_eCart1_tier2() {
$totalCharge = 0;
if (false && (($this->TotalColumn("TotalQuantity") >= 5) && (sizeof($this->Items) < 10))) {
$totalCharge += ($this->TotalColumn("TotalQuantity") * 7);//Result
}
return WA_eCart_FormatNumber($totalCharge, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_eCart1_tier3() {
$totalCharge = 0;
if (false && (($this->TotalColumn("TotalQuantity") >= 10) && ($this->TotalColumn("TotalQuantity") < 20))) {
$totalCharge += (($this->TotalColumn("TotalQuantity") * 6.5) + 0);//Result
}
return WA_eCart_FormatNumber($totalCharge, $this->ForceDecimalsC, $this->DecimalPlacesC);
}

I'm also experiencing something concerning in that after every time I try to edit the cart object, I get a message that the cart object file has been edited outside of dreamweaver and I'm asked if I want to reload. But I haven't edited outside of DW, so where's that coming from? I wonder if there could be an issue about what version of ecart I used when I set the site up and what one I'm using now. I seem to be running 4.5.0 now. Not sure what I had when I set the site up, but it's been running a long time.

Any help? I'm attaching the cart object page. Oops, can't do that, as php files can't be uploaded. Have pasted the relevant code above.

Sign in to reply to this post

Jason ByrnesWebAssist

you wont be able to override the Price using a Discount or charge rule, you will need to do that by crating a calculation on the calculation tab.


On the calculation tab create a new calculation named "holidayBasePrice" as:
[Price] = 35

This will set the price for any item added to the cart to $35

The create two charges to increase the price based on the quantity For 10 - 20 and another for 20 or more like you have below.

Sign in to reply to this post

barbara224891

I'm having trouble following your directions. I edited the calculations as follows:

//start node
function ResetCalculations($itmObj) {
$itmObj->TotalWeight = $itmObj->Weight * $itmObj->Quantity;//w
$itmObj->TotalPrice = 7.5* $itmObj->Quantity;//c
$itmObj->FullDetails = $itmObj->Quantity . ' ' . $itmObj->Name . ' (' . $itmObj->ID . ')';//t
$itmObj->TotalQuantity = $itmObj->Quantity;//n
$itmObj->holidayPrice = 7.5;//c
return $itmObj;
}
//end node

This sets the price for every item to the unit price if there is no discount, $7.50. This part is showing up properly in my cart now.

Next, I redid the tiers to calculate a discount based on how many total items are in the cart. These have the effect of lowering the cart title by the discount in unit price times the total quantity of all items in the cart. This is how they look:

//Discounts
$this->Discounts[] = new WA_eCart_Rule(urldecode("tier1"), true, "WAEC_WA_eCart1_tier1");
$this->Discounts[] = new WA_eCart_Rule(urldecode("tier2"), true, "WAEC_WA_eCart1_tier2");
$this->Discounts[] = new WA_eCart_Rule(urldecode("tier3"), true, "WAEC_WA_eCart1_tier3");
//Charges
//Tax
//Shipping
$this->Shipping[] = new WA_eCart_Rule(urldecode("base"), false, "WAEC_WA_eCart1_base");
$this->Shipping[] = new WA_eCart_Rule(urldecode("increment"), false, "WAEC_WA_eCart1_increment");
}
//end node
//start node
//eCart Rule
function WAEC_WA_eCart1_tier1() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) >= 5) && (sizeof($this->Items) < 10))) {
$totalDiscount += ($this->TotalColumn("TotalQuantity") * .5);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_eCart1_tier2() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) >= 10) && (sizeof($this->Items) != 20))) {
$totalDiscount += ($this->TotalColumn("TotalQuantity") * 1.0);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_eCart1_tier3() {
$totalDiscount = 0;
if (true && ((sizeof($this->Items) > 20))) {
$totalDiscount += ($this->TotalColumn("TotalQuantity") * 1.5);//Result
}
return WA_eCart_FormatNumber($totalDiscount, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule

Finally, I add a line in the cart to display the discount, using this binding: <?php echo $WA_eCart1->GetDiscounts(); ?>.

However, the discount does not show up and the total is not affected. I have the tier rules selected as active, but obviously, they are not.

Help, please?

Sign in to reply to this post

barbara224891

OK, I just managed to figure out a work-around. For some reason the discount wasn't showing up in my total, but I remembered that on my initial iteration when I'd been working with charges, they were showing up, so I redid the discount as negative charges and that shows up fine.

So, never mind.

Sign in to reply to this post

Jason ByrnesWebAssist

Ok, glad to hear it is working.

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