View Full Version : Adding More Columns in eCart Object?
My site has many pages and I am faced with the fact that I need to add a few more columns to the eCart Object. I'm building a coupon discount that is based on the category of the item but I don't currently have that built in. The problem, of course, if I do this and upload it, none of my pages will work and I'll have a mess on my hands. Consequently, what I need to do, before uploading the cart definitions, is go into each page and fire up the eEcart behavior in each page.
********************************************
NOTICE: I wish this part (above) could be built into an include so by updating one you update all...
********************************************
1. Is there an easier way of doing this without having to go into each page and fire up the eCart behavior?
2. Can I just add a couple more generic columns that aren't linked to anything so I don't have to do this all over when the case arises?
Ray Borduin
04-08-2009, 11:54 AM
You only have to update the add to cart buttons to add content to those columns. I don't see how having placeholders would help... if you add a column you will need to update the add to cart server behavior to specify the contents.
You only have to update the add to cart buttons to add content to those columns. I don't see how having placeholders would help... if you add a column you will need to update the add to cart server behavior to specify the contents.
I don't think I understand your response.
Perhaps restating will confirm my intention...or not...
In order to do the discount on category, I need to store the category id somewhere/product. I could do a plain old session variable but it wouldn't be tied to each row product added.
So, when I open the ecart window, I see the "General, Columns, Calculations, Discounts, Charges, Taxes" tabs. When I go to "Columns" I see a list of items like "Price, Name, Id, weight..." that are added/line when a product is added. I need to add one more "Column" here called "Category" that will record the category of each product and only those products will get a discount of 25%.
My past experience tells me that if you change the Columns by adding one more, and if you post the "WA_eCart_Definition_VB.asp" and "name_eCart_VB.asp" that get updated when you change anything in the ecart, the site dies and you get a major error.
The only way I know to do this is to go into each page and update the (as you said) the add to cart page and I'm wondering if this is the only way. I have a lot of pages and I want to avoid this.
Is this clear?
----------------
By the way, what would the rule look like?
I know it would be something like the following but what would it look like if I ONLY want it to apply to items that are in that category and not in others?
25% off if category is (categoryID)
Ray Borduin
04-08-2009, 12:53 PM
If you don't have an active session the only thing that needs to be updated is the add to cart buttons. Since you are adding a column you would want to update those anyway to insert the correct category ID... maybe we keep going over eachother's head but it seems this would be necessary even if no errors occured without it.
You're right, I would have to update each "Add To Cart" item on the site.
Any ideas on what the "expression " would look like for this? I don't think the regular options offer what I need for this.
Or, do you think this would fit into the normal scope of WebAssist's tools.
Ray Borduin
04-09-2009, 12:19 PM
I'm afraid I don't understand the question.
Sorry, let me try again.
Let's say I have 3 categories of products
01, 02, and 03
I want to have a coupon apply a discount on products in group 03 at checkout time.
What would be the best way to do this in WA?
Ray Borduin
04-13-2009, 03:21 PM
1) What Server language? (I'll answer in php)
Most likely you would add a column to your cart for the category.
Then you would add a calculation like:
TotalDiscount = (([category] == '03')?([TotalPrice] * 0.25):0)
Then add a discount that is equal to the total of the TotalDiscount column in the discount tab.
ASP vbscript
how different would the calculation be?
Ray Borduin
04-14-2009, 08:27 AM
TotalDiscount = (Abs([category] = '03')*([TotalPrice] * 0.25))
whit368229
06-04-2010, 10:02 AM
Using PS2, eCart 5, php and UPS shipping:
I too have 3 categories. CategoryID 1 and CategoryID 3 are products, CategoryID 2 is replacement parts. The parts vary in size, so we'd like to ship 1-4 parts in one box @ $9.95/box. We'd like to offer flat rate UPS shipping for CategoryID 2. The shipping rules would look like:
CategoryID 2 >=1
AND
CategoryID 2 <=4
Flat rate $9.95
CategoryID 2 >=5
CategoryID 2 <=8
Flat rate $19.00 ...etc.
but I'm banging my head on how to get the CategoryID into the cart? I'm sure it's easier than I'm making it...
Ray Borduin
06-07-2010, 08:16 AM
Just add a column to the cart for CategoryID and then update your add to cart server behavior to specify the value.
Then create a calculation:
ReplacementParts = abs([CategoryID] == 2)*[Quantity]
Then add a shipping rule:
If total of ReplacementParts > 0
Flat Rate Charge: (ceil($this->TotalColumn("ReplacementParts")/4) * 9.95)
whit368229
06-16-2010, 12:50 PM
Thanks for your reply! I tried what you suggested, but missed something somewhere. Here's what I did:
1) I opened Products_Detail.php page
2) I added a column (ProductCategoryID) to the cart.
3) Added a Calculation: PartsShipping=abs([ProductCategoryID] == 2) * [Quantity]
4) Created a rule: FlatRateParts (see below)
5) Created a new recordset (rsCatID):
SELECT products.ProductCategoryID
FROM products
6) From the Bindings tab, I drug ProductCategoryID (from rsCatID) onto my Products_Detail.php page within the addFields div:
<div id="addFields" <?php echo(($row_WADAProducts["NumLeft"] > 0 || $row_WADAProducts["ProductUnlimited"] != 0)?'':'style="display:none"'); ?> >
<input type="hidden" name="WA_Store_Cart_1_ID_Add" id="WA_Store_Cart_1_ID_Add" value="<?php echo $row_WADAProducts["ProductID"]; ?>" />
<?php echo $row_rsCatID['ProductCategoryID']; ?>
<h2 id="ProductPrice">$<?php echo number_format($row_WADAProducts["ProductPrice"], 2); ?></h2>
<input type="image" src="Images/btn_addtocart.png" border="0" value="Add to Cart" name="WA_Store_Cart_1_ATC" align="absmiddle" />
<label>Qty:</label>
<input type="text" name="WA_Store_Cart_1_Quantity_Add" value="1" size="2" align="absmiddle" />
</div>
7) OPened the add to cart server behavior and added a value to ProductCategoryID:
<?php echo $row_rsCatID['ProductCategoryID']; ?>
On my WA_Store_Cart_PHP.php page:
//Shipping
$this->Shipping[] = new WA_eCart_Rule(urldecode("FlatRateParts"), true, "WAEC_WA_Store_Cart_FlatRateParts");
$this->Shipping[] = new WA_eCart_Rule(urldecode("UPS%20Shipping"), true, "WAEC_WA_Store_Cart_UPSShipping");
}
//end node
On my WA_Store_Cart_PHP.php page the rule looks like this:
//eCart Rule
function WAEC_WA_Store_Cart_FlatRateParts() {
$totalShipping = 0;
if (true && (($this->ConditionalTotal("Quantity", "PartsShipping", "2") > 0) && (( (ceil($this->TotalColumn("PartsShipping")/4) * 9.95) )))) {
$totalShipping += 9.95;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//eCart Rule
function WAEC_WA_Store_Cart_UPSShipping() {
$totalShipping = 0;
if (true && (("UPS"=="UPS")&&(isset($_SESSION["WA_Store_Cart_UPS_Quote"]))&&(floatval($_SESSION["WA_Store_Cart_UPS_Quote"]) != 0))) {
$totalShipping += floatval($_SESSION["WA_Store_Cart_UPS_Quote"]) + 0;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//end node
On my WA_Store_Cart_PHP.php page the calcs look like this:
//calculations
$this->TotalWeight = $this->Weight * $this->Quantity;//w
$this->TotalPrice = $this->Price * $this->Quantity;//c
$this->FullDetails = $this->Quantity . ' ' . $this->Name . ' (' . $this->ID . ')';//t
$this->PartsShipping = abs($this->ProductCategoryID == 2) * $this->Quantity;//t
I uploaded updated files for testing. On Products_Detail.php, I added three ProductCategoryID=2 products to the cart and checked out. Standard UPS rates applied, not my rules. Also, category 1 appears on the page instead of Cat 2?
What did I miss?
Ray Borduin
06-24-2010, 12:34 PM
It sounds like it should work. I have opened up an incident so that one of our support engineers can work with you directly to debug what is going wrong.
whit368229
07-12-2010, 07:26 PM
OK, where was I.... the price, category and quantity are now slightly different, but the rule should basically the same. The goal is to add flat rate shipping based on CategoryID when 1-10 CategoryID 4 items are added to the cart, the total shipping for those Cat4 items = $9.50.
My calculation: PaperShipping = abs([CategoryID] == 4) * [Quantity]
I have the (slightly modified from your example) rule set up on my WA_Store_Cart_PHP.php as:
//eCart Rule
function WAEC_WA_Store_Cart_Paper() {
$totalShipping = 0;
if (true && (($this->ConditionalTotal("Quantity", "CategoryID", "4") > 0))) {
$totalShipping += ($this->TotalColumn("PaperShipping") / 10) * 9.50;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
IF I add 10 items to the cart, all is well with a $9.50 ($0.95 x 10) flat rate charge, but if I add 5 items to the cart, the flat rate = $4.75 ($0.95 x 5).
Thanks for getting me this far!
Ray Borduin
07-16-2010, 07:42 AM
Please update your support ticket with contact information and I will call you in order to help you debug the problem.
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.