Hi Ray
Here is the code for eCart1_PHP.php.
<?php
require_once("WA_eCart_Definition_PHP.php");
class eCart1_Definition extends WA_eCartDefinition {
function eCart1_Definition($CartName, $PersistanceType, $CurrencyPrefix, $ForceDecimalsC, $DecimalPlacesC, $CurrencyAlign, $WeightSuffix, $ForceDecimalsW, $DecimalPlacesW, $WeightAlign, $NumberDisplay) {
$this->WA_eCartDefinition($CartName, $PersistanceType, $CurrencyPrefix, $ForceDecimalsC, $DecimalPlacesC, $CurrencyAlign, $WeightSuffix, $ForceDecimalsW, $DecimalPlacesW, $WeightAlign, $NumberDisplay);
}
//start node
function ResetCalculations($itmObj) {
$itmObj->TotalWeight = $itmObj->Weight * $itmObj->Quantity;//w
$itmObj->TotalPrice = $itmObj->Price * $itmObj->Quantity;//c
$itmObj->FullDetails = $itmObj->Quantity . ' ' . $itmObj->Name . ' (' . $itmObj->ID . ')';//t
return $itmObj;
}
//end node
//start node
function ItemIndex($itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance) {
for ($n=0; $n<sizeof($this->Items); $n++) {
if ($this->Items[$n]) {
if ((strcmp($this->Items[$n]->ID, $itemID) === 0) AND (strcmp($this->Items[$n]->Fragrance, $itemFragrance) === 0)) {
return $n;
}
}
}
return -1;
}
//end node
//start node
function AddToCart($AddIfIn, $RedirectIfIn, $itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance) {
if (get_magic_quotes_gpc()) {
$itemName = stripslashes($itemName);
$itemDescription = stripslashes($itemDescription);
$itemFragrance = stripslashes($itemFragrance);
}
$inCartID = $this->ItemIndex($itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance);
$itemQuantity = floatval($itemQuantity);
if ($inCartID >= 0) {
if ($AddIfIn == 0) {
$this->Items[$inCartID]->Quantity = floatval($this->Items[$inCartID]->Quantity) + $itemQuantity;
if ($this->Items[$inCartID]->Quantity < 0) {
$this->Items[$inCartID]->Quantity = 0;
}
if ($this->Items[$inCartID]->Quantity == 0) {
$this->DeleteFromCart($inCartID, true);
}
else {
$this->Items[$inCartID] = $this->ResetCalculations($this->Items[$inCartID]);
}
}
if ($AddIfIn == 2 && $itemQuantity > 0) {
$this->Items[] = new eCart1_ItemDefinition($itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance);
}
if ($AddIfIn == 4 && $itemQuantity > 0) {
$this->DeleteFromCart($inCartID, true);
$this->Items[] = new eCart1_ItemDefinition($itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance);
}
if ($RedirectIfIn != "") {
$this->redirStr = $RedirectIfIn;
}
}
else {
if ($itemQuantity > 0) {
$this->Items[] = new eCart1_ItemDefinition($itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance);
}
}
$this->ResetAll();
$this->SaveCart();
}
//end node
//start node
function DefineRules() {
$this->Discounts = array();
$this->Charges = array();
$this->Tax = array();
$this->Shipping = array();
$this->ShippingIsTaxed = false;
//Discounts
//Charges
//Tax
//Shipping
$this->Shipping[] = new WA_eCart_Rule(urldecode("Flat%20Rate"), true, "WAEC_eCart1_FlatRate");
}
//end node
//start node
//eCart Rule
function WAEC_eCart1_FlatRate() {
$totalShipping = 0;
if (true && (($this->InCart("1") == true))) {
$totalShipping += 7;//Result
}
return WA_eCart_FormatNumber($totalShipping, $this->ForceDecimalsC, $this->DecimalPlacesC);
}
//eCart Rule
//end node
//start node
function UpdateCart() {
for ($n=0; $n<sizeof($this->Items); $n++) {
$itemDelete = (isset($_POST[$this->CartName."_Delete_".$n]))?$_POST[$this->CartName."_Delete_".$n]:null;
$resetCalcs = false;
$itemID = null;
if (isset($_POST[$this->CartName."_ID_hid_".$n])) {
$itemID = floatval($_POST[$this->CartName."_ID_hid_".$n]);
}
if (isset($_POST[$this->CartName."_ID_list_".$n])) {
$itemID = floatval($_POST[$this->CartName."_ID_list_".$n]);
}
if (isset($_POST[$this->CartName."_ID_".$n])) {
$itemID = floatval($_POST[$this->CartName."_ID_".$n]);
}
if (isset($_POST[$this->CartName."_ID_check_".$n])) {
$itemID = floatval($_POST[$this->CartName."_ID_check_".$n]);
}
$itemName = null;
if (isset($_POST[$this->CartName."_Name_hid_".$n])) {
$itemName = $_POST[$this->CartName."_Name_hid_".$n];
}
if (isset($_POST[$this->CartName."_Name_list_".$n])) {
$itemName = $_POST[$this->CartName."_Name_list_".$n];
}
if (isset($_POST[$this->CartName."_Name_".$n])) {
$itemName = $_POST[$this->CartName."_Name_".$n];
}
if (isset($_POST[$this->CartName."_Name_check_".$n])) {
$itemName = $_POST[$this->CartName."_Name_check_".$n];
}
$itemDescription = null;
if (isset($_POST[$this->CartName."_Description_hid_".$n])) {
$itemDescription = $_POST[$this->CartName."_Description_hid_".$n];
}
if (isset($_POST[$this->CartName."_Description_list_".$n])) {
$itemDescription = $_POST[$this->CartName."_Description_list_".$n];
}
if (isset($_POST[$this->CartName."_Description_".$n])) {
$itemDescription = $_POST[$this->CartName."_Description_".$n];
}
if (isset($_POST[$this->CartName."_Description_check_".$n])) {
$itemDescription = $_POST[$this->CartName."_Description_check_".$n];
}
$itemWeight = null;
if (isset($_POST[$this->CartName."_Weight_hid_".$n])) {
$itemWeight = floatval($_POST[$this->CartName."_Weight_hid_".$n]);
}
if (isset($_POST[$this->CartName."_Weight_list_".$n])) {
$itemWeight = floatval($_POST[$this->CartName."_Weight_list_".$n]);
}
if (isset($_POST[$this->CartName."_Weight_".$n])) {
$itemWeight = floatval($_POST[$this->CartName."_Weight_".$n]);
}
if (isset($_POST[$this->CartName."_Weight_check_".$n])) {
$itemWeight = floatval($_POST[$this->CartName."_Weight_check_".$n]);
}
$itemQuantity = null;
if (isset($_POST[$this->CartName."_Quantity_hid_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_hid_".$n]);
}
if (isset($_POST[$this->CartName."_Quantity_list_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_list_".$n]);
}
if (isset($_POST[$this->CartName."_Quantity_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_".$n]);
}
if (isset($_POST[$this->CartName."_Quantity_check_".$n])) {
$itemQuantity = floatval($_POST[$this->CartName."_Quantity_check_".$n]);
}
$itemPrice = null;
if (isset($_POST[$this->CartName."_Price_hid_".$n])) {
$itemPrice = floatval($_POST[$this->CartName."_Price_hid_".$n]);
}
if (isset($_POST[$this->CartName."_Price_list_".$n])) {
$itemPrice = floatval($_POST[$this->CartName."_Price_list_".$n]);
}
if (isset($_POST[$this->CartName."_Price_".$n])) {
$itemPrice = floatval($_POST[$this->CartName."_Price_".$n]);
}
if (isset($_POST[$this->CartName."_Price_check_".$n])) {
$itemPrice = floatval($_POST[$this->CartName."_Price_check_".$n]);
}
$itemFragrance = null;
if (isset($_POST[$this->CartName."_Fragrance_hid_".$n])) {
$itemFragrance = $_POST[$this->CartName."_Fragrance_hid_".$n];
}
if (isset($_POST[$this->CartName."_Fragrance_list_".$n])) {
$itemFragrance = $_POST[$this->CartName."_Fragrance_list_".$n];
}
if (isset($_POST[$this->CartName."_Fragrance_".$n])) {
$itemFragrance = $_POST[$this->CartName."_Fragrance_".$n];
}
if (isset($_POST[$this->CartName."_Fragrance_check_".$n])) {
$itemFragrance = $_POST[$this->CartName."_Fragrance_check_".$n];
}
if (isset($itemID)) {
$this->Items[$n]->ID = $itemID;
$resetCalcs = true;
}
if (isset($itemName)) {
$this->Items[$n]->Name = $itemName;
$resetCalcs = true;
}
if (isset($itemDescription)) {
$this->Items[$n]->Description = $itemDescription;
$resetCalcs = true;
}
if (isset($itemWeight)) {
$this->Items[$n]->Weight = $itemWeight;
$resetCalcs = true;
}
if (isset($itemQuantity)) {
$this->Items[$n]->Quantity = $itemQuantity;
$resetCalcs = true;
}
if (isset($itemPrice)) {
$this->Items[$n]->Price = $itemPrice;
$resetCalcs = true;
}
if (isset($itemFragrance)) {
$this->Items[$n]->Fragrance = $itemFragrance;
$resetCalcs = true;
}
if (is_numeric($itemQuantity)) {
if ($itemQuantity < 0) {
$itemQuantity = 0;
}
if ($itemQuantity == 0) {
$this->DeleteFromCart($n, false);
$resetCalcs = false;
}
else {
if ($this->Items[$n]->Quantity != $itemQuantity) {
$this->Items[$n]->Quantity = floatval($itemQuantity);
$resetCalcs = true;
}
}
}
if (isset($itemDelete) && $itemDelete != "") {
$this->DeleteFromCart($n, false);
$resetCalcs = false;
}
if ($resetCalcs) {
$this->Items[$n] = $this->ResetCalculations($this->Items[$n]);
}
}
$this->ReIndexContent();
$this->ResetAll();
$this->SaveCart();
}
//end node
}
?>
<?php
// eCart Language Pack [En]
$eCart1 = new eCart1_Definition("eCart1", 0, "$", true, 2, 0, "oz", true, 2, 1, 0);
$eCart1->cartAction = "";
$eCart1->redirStr = "";
?>
<?php
class eCart1_ItemDefinition {
var $ID;
var $Name;
var $Description;
var $Weight;
var $Quantity;
var $Price;
var $Fragrance;
var $TotalWeight;
var $TotalPrice;
var $FullDetails;
//define
function eCart1_ItemDefinition($itemID, $itemName, $itemDescription, $itemWeight, $itemQuantity, $itemPrice, $itemFragrance) {
//columns
$this->ID = $itemID;//n√
$this->Name = $itemName;//t
$this->Description = $itemDescription;//t
$this->Weight = $itemWeight;//w
$this->Quantity = $itemQuantity;//n
$this->Price = $itemPrice;//c
$this->Fragrance = $itemFragrance;//t√
//calculations
$this->TotalWeight = $this->Weight * $this->Quantity;//w
$this->TotalPrice = $this->Price * $this->Quantity;//c
$this->FullDetails = $this->Quantity . ' ' . $this->Name . ' (' . $this->ID . ')';//t
}
}
?>
Can you help me edit the code as I can't use ecart until I get the activation issue sorted.
Many thanks
Phil