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

How to check against stock level variable when updating quantities in cart view

Thread began 6/24/2014 6:59 am by jon211112 | Last modified 7/01/2014 12:54 pm by Jason Byrnes | 1373 views | 7 replies |

jon211112

How to check against stock level variable when updating quantities in cart view

I am incorporating stock control into an eCart site and it's working fine when adding an item but I need to insert some checking code when the cart is updated if the quantity is changed. I need a steer as to where I should put any code. I could add a column to the cart items to hold the stock level so I can then compare that to the quantity in the cart, or I could do a query to check it, but I don't know where any of that code should go.

Can you point me in the right direction?

Many thanks

Jon

Sign in to reply to this post

Jason ByrnesWebAssist

in the cart object, add a column for the available quantity, and save the available quantity in the add to cart button

you can then create a calculation in the cart object to force the quantity to be the available quantity is they try to order more than are available:

abs([Quantity] > [AvailableQuatity])?[Quantity] = [AvailableQuatity];''
Sign in to reply to this post

jon211112

Thanks Jason, that looks exactly what I need. Quick question, though. Where should I put that code snippet? I'm in the cart.php script which has the standard updatable cart displayed.

Cheers

Jon

Sign in to reply to this post

Jason ByrnesWebAssist

create a new calculation in the cart object using the code snippet above.

the calculation code code snippet assumes the availbal quantity column is named AvailableQuatity

Sign in to reply to this post

jon211112

Thanks again Jason.

The snippet you've given was giving me the white screen so I've had a look in eCart1_PHP.php and found the two place where that is inserted and have manually edited them to show this:

if($itmObj->Quantity > $itmObj->StockLevel) {
$itmObj->Quantity = $itmObj->StockLevel;
}

(my column for stock is StockLevel)

and this is now working. However, it is screwing up the Cart Object dialogue so I would be keen to do it properly. Are you able to suggest what the problem could be?

Thanks again

Jon

Sign in to reply to this post

Jason ByrnesWebAssist

What was the code originally? i would need to know what the code was before you edited it to be able to tell what was wrong.

Sign in to reply to this post

jon211112

Hi Jason

I put in what you gave me in this thread:

abs([Quantity] > [AvailableQuatity])?[Quantity] = [AvailableQuatity];''

I changed it to:

abs([Quantity] > [StockLevel])?[Quantity] = [StockLevel];''

and also tried:

abs([Quantity] > [StockLevel])?[Quantity] = [StockLevel]

and:

abs([Quantity] > [StockLevel])?[Quantity] = [StockLevel];

but always giving the white screen.

Hope that helps.

Cheers

Jon

Sign in to reply to this post

Jason ByrnesWebAssist

I see, it shouldn't be a semi colon, but a full colon:
abs([Quantity] > [StockLevel])?[Quantity] = [StockLevel]:''

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