close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How do I reset an ecart variable

Thread began 7/26/2010 7:33 pm by ahm137468 | Last modified 7/28/2010 6:59 am by Jason Byrnes | 1243 views | 7 replies |

ahm137468

How do I reset an ecart variable

I have some logic where if certain conditions are true, I need to change the value of a variable called ShipCalcMethod in the cart. What is the syntax to do that? I can query it with eCart->DisplayInfo("ShipCalcMethod"), but how do I change it?

Thanks,
Nina Macdonald

Sign in to reply to this post

Jason ByrnesWebAssist

you would do this in a calculation in the cart object, so that the value can be reset on an item by item basis.

you could create a calculation called "resetShipCalcMethod". for examples sake i will reset the ShipCalcMethod if the session variable "reset" equal 1

resetShipCalcMethod abs(isset($_SESSION['reset']) && $_SESSION['reset'] == '1')?[ShipCalcMethod] = '':''

Sign in to reply to this post

ahm137468

I don't think that's quite what I need

Here is my code. This is not in the WA_eCart newProducts_PHP.php file, but earlier.

while (!$newProducts->EOF()) {
if ($newProducts->DisplayInfo("ShipCalcMethod") == "call"){
$quote++;
} elseif ($newProducts->DisplayInfo("ShipCalcMethod") == "fixedF") {
if($mattresses > 0 ) {
if ($newProducts->DisplayInfo("Quantity") <= $mattresses ) {
$newProducts->itemShipCalcMethod ="free";
$mattresses -= $newProducts->DisplayInfo("Quantity");
} else {
$newProducts->ItemShipCalcMethod ="fixed";
}
} else {
$newProducts->ItemShipCalcMethod ="fixed";
}
}
$newProducts->MoveNext();
}

I thought that $newProducts->ItemShipCalcMethod ="fixed"; would re-set the variable for that particular product/ship method, but it doesn't. Is there some syntax I can use to do this on the individual item in the cart.

At the beginning of this, I have already computed how many mattresses are in the order. Any foundation ships free if there is a off-setting mattress.

Sign in to reply to this post

Jason ByrnesWebAssist

you need to do this in a calculation like I outlined previously.

Sign in to reply to this post

ahm137468

Yes, but I don't understand your original post

Are you saying that I can just say [ShipCalcMethod] = "free";

in my code and it will know what product I am on? I don't really need the whole line you gave since I already have my test.

Thanks,

Sign in to reply to this post

Jason ByrnesWebAssist

using just [ShipCalcMethod] = "free" will always set to free no matter what.


using the abs() function, you can use other variables to determine whether the ShipCalcMethod column should or should not be set to free.

the abs function returs true if the equation in perenthisis is true:
abs(equation)?execute if true:execute if false;

abs($var == '3')?[ShipCalcMethod] = 'free':''

this will set ship ShipCalcMethod to free only if $var is equal to 3.

Sign in to reply to this post

ahm137468

Here's what works

I'm not sure you ever grasped that I needed to set the Shipping Method individually for a given product. Perhaps you did and I couldn't understand what you said. However, with your help, I did create a function that resets the value of the variable. Here, for later readers is my function with thanks to DisplayInfo().

function ModifyShipCalcMethod($newMethod) {
if (!$this->IsEmpty() && !$this->EOF()) {
eval("\$this->Items[".$this->DisplayIndex."]->ShipCalcMethod = "."\$newMethod".";");
}
}

I put this function in WA_eCart_Definition_PHP.php
I called it like this

$newProducts->ModifyShipCalcMethod("free"); OR
$newProducts->ModifyShipCalcMethod("fixed");

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, i did grasp that.



Calculations are performed on a per item bases.


glad you found a way to get it 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...