close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Is item value in cart?

Thread began 4/26/2011 8:09 am by web_assist_mail157665 | Last modified 4/26/2011 8:46 am by Jason Byrnes | 997 views | 3 replies |

web_assist_mail157665

Is item value in cart?

First off - I've got a working solution - just doesn't seem very elegant and would be nice to find a generic way to do it, as this test comes up a lot.

Client wishes to return user to a specific page, if a certain item (from a particular product category) is removed from the cart (so the only option is to make a purchase from a particular product group)

I join my product_category and products tables together, so each product
has a category, and that category has a 'Required' 1 or 0 flag

<?php echo $row_rs_products_joined_with_categories['CategoryReqFlag']; ?>
which is added to the cart item ProductCategoryReqFlag
at the same time the product is added to the cart

Q:
what is the most elegant way to test for this value

and go to the page that is set up as CONTINUE shopping


so far have this


<?php
$i=0;
$flags=array();
$target=1;
while (!$eCart1->EOF())
{
$flags[$i]=$eCart1->DisplayInfo("ProductCategoryReqFlag");
$i++;
$eCart1->MoveNext();
}
$eCart1->MoveFirst();

if (!in_array($target, $flags))
{
$eCart1->redirStr = "index.php?id_sec=62";
$eCart1->cartAction = "RedirectIfEmpty"; // just putting $eCart1->cartAction = "Continue"; doesn't work?
}
?>







PS - I don't want to test for a specific ID in Cart
think we are looking for a function something like

function InCartVal($ItemProperty) {
******
******
******
}

Sign in to reply to this post

Jason ByrnesWebAssist

to test for a specific column value use:

php:
$yourCartName->ConditionalTotal("Quantity", "ProductCategoryReqFlag", "1")



where "yourCartName" is the name of your ecart object.

this will return the Quantity of items in the cart where the ProductCategoryReqFlag column has a value of 1.

Sign in to reply to this post

web_assist_mail157665

Originally Said By: Jason Byrnes
  to test for a specific column value use:

php:
$yourCartName->ConditionalTotal("Quantity", "ProductCategoryReqFlag", "1")


where "yourCartName" is the name of your ecart object.

this will return the Quantity of items in the cart where the ProductCategoryReqFlag column has a value of 1.  



Thanks Jason

I had a feeling there was a more elegant solution

appreciated

Paul

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

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