close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

How do I capture a column that's added to Cart in an array?

Thread began 5/31/2019 10:50 am by lr_leal239405 | Last modified 1/20/2020 10:44 am by Ray Borduin | 1880 views | 22 replies |

lr_leal239405

How do I capture a column that's added to Cart in an array?

I a'm trying to capture what's in the cart column (I added a column (hidden value in add to cart) for 'Product Category'. I want to use those values for products added to the cart to bring up some forms (with questions) based on whether that category is in the cart. I have something like:

<?php
$eCart1_CatID = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"];
if ((in_array("1", $eCart1_CatID ))) {
echo "#fldsetcs { display:block; }";
}
if ((in_array("2", $eCart1_CatID ))) {
echo "#fldsetcs { display:block; }";
}
if ((in_array("3", $eCart1_CatID ))) {
echo "#fldsetssh { display:block; }";
echo "#specsssh { display:block; }";
}
if ((in_array("4", $eCart1_CatID ))) {
echo "#fldsetws { display:block; }";
echo "#Specswrinklestop { display:block; }";
}
if ((in_array("5", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specstrimchopper { display:block; }";
}
if ((in_array("6", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specsstandardtrim { display:block; }";
}
if ((in_array("7", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specsstandardtrim { display:block; }";
}
if ((in_array("8", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specsstandardtrim { display:block; }";
}
if ((in_array("0", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specstrimchopper { display:block; }";
}
if ((in_array("10", $eCart1_CatID ))) {
echo "#fldsetcs { display:block; }";
}
if ((in_array("11", $eCart1_CatID ))) {
echo "#fldsetcs { display:block; }";
}
if ((in_array("12", $eCart1_CatID ))) {
echo "#fldsetir { display:block; }";
echo "#specsir { display:block; }";
}
if ((in_array("13", $eCart1_CatID ))) {
echo "#fldsetcs { display:block; }";
}
if ((in_array("14", $eCart1_CatID ))) {
echo "#fldsetaw { display:block; }";
echo "#specsadjustapull { display:block; }";
}
if ((in_array("15", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specsfoxrunnertrim { display:block; }";
}
if ((in_array("16", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specsfoxrunnertrim { display:block; }";
}
if ((in_array("17", $eCart1_CatID ))) {
echo "#fldsetft { display:block; }";
echo "#specsstandardtrim { display:block; }";
}
if ((in_array("18", $eCart1_CatID ))) {
echo "#fldsetbr { display:block; }";
echo "#specsbr { display:block; }";
}
?>

But I want that first line to be: $eCart1_CatID[] = $eCart1->DisplayInfo("eCartCatID");

That line only captures the first value.. I need to capture all the values of that eCart column.

How to?

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

You should be able to use an IF statement like:

php:
<?php

if ($eCart1->ConditionalTotal("Quantity""eCartCatID""1")) {
  echo 
"#fldsetcs { display:block; }";
}
?>



The ConditionalTotal function will return the sum of the first column where the second column equals the third value. So the if statement above will be the Total Quantity where eCartCatID equals 1.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

Wow! as usual - That Works ! thanks a million!!!

Sign in to reply to this post

lr_leal239405

I'm struggling with something similar: How do I get all the items from $eCart1 where the Category equals 1 (and so on).

something like
$cartitems[] = ("SELECT * FROM $eCart1 WHERE eCartCatID = 1");

I'm trying to limit the display of all that is in the cart to only those whose category is 1.

Currently I have all cart products displaying:

<?php

echo "Products Related: ";
while (!$eCart1->EOF()) {
?>

<ul>
<li class="itemname" class="eC_ItemName">
<?php
echo $eCart1->DisplayInfo("Name");
?></li></ul>
<?php
$eCart1->MoveNext();
}
$eCart1->MoveFirst();
?>



I tried this but errors out:

<?php
$eCart2 = $eCart1->DisplayInfo("eCartCatID");
$Recordset1 = new WA_MySQLi_RS("Recordset1",$convacc_cx,1);
$Recordset1->setQuery("SELECT Product_Name, Cat_ID FROM eCart_products WHERE Cat_ID = $eCart2");
$Recordset1->execute();
//$cartitems[] = ("SELECT * FROM $eCart1 WHERE eCartCatID = 1");
echo "Products Related: ";
while (!$eCart1->EOF()) {
?>
<?php while (!$Recordset1->EOF()) { ?>
<ul>
<li class="itemname" class="eC_ItemName">
<?php
echo $Recordset1->DisplayInfo("Name");
?></li></ul>
<?php
$Recordset1->MoveNext();
}
$Recordset1->MoveFirst();
?>


<?php
$eCart1->MoveNext();
}
$eCart1->MoveFirst();
?>

Sign in to reply to this post

Ray BorduinWebAssist

I think you might want something like:

php:
<?php

echo "Products Related: ";
$shown = array();
?>
<?php
while (!$eCart1->EOF()) {
?>
<?php
  
if (!in_array($eCart1->DisplayInfo("eCartCatID"), $shown)) {
    
$shown[] = $eCart1->DisplayInfo("eCartCatID");
?>
<?php
$Recordset1 
= new WA_MySQLi_RS("Recordset1",$convacc_cx,1);
$Recordset1->setQuery("SELECT Product_Name, Cat_ID FROM eCart_products WHERE Cat_ID = " $eCart1->DisplayInfo("eCartCatID"));
$Recordset1->execute();
?>
<?php 
while (!$Recordset1->atEnd()) { ?>
<ul>
<li class="itemname" class="eC_ItemName">
<?php
echo $Recordset1->getColumnVal("Name");
?></li></ul>
<?php
$Recordset1
->MoveNext();
}
$Recordset1->MoveFirst();
?>
<?php
  
}
?>
<?php
$eCart1
->MoveNext();
}
$eCart1->MoveFirst();
?>
Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

still trying. I'm getting wrong index (1st one in row to meet criteria) and it's displaying all still.

Sign in to reply to this post

Ray BorduinWebAssist

Can I get steps to reproduce... what page should I start at? What should I add to the cart? How can I get to the error you are seeing?

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

addtocart , then Checkout button. On the next page is what I'm trying to fix.

You have to add something from the first products. ( It's the 'Core Support' category). Then, something the bottom 'Brakes' (or any other that is different.. When you expand with the input checkbox, you'll see what I'm talking about.

Products Related: <- it lists all the products in the cart instead of the one(s) pertaining to the category only.

The file is now an include and it's called 'relatedproducts.php'. That's where I have the code for that.

(You'll see an error pop up also that I got after I added UPS shipping on the cart page. But that's another topic).

Notice: Undefined index: eCart1_UPS_Quote in /home/jvdydf5kad9w/public_html/WA_eCart/eCart1_PHP.php on line 87

Sign in to reply to this post

Ray BorduinWebAssist

I can't seem to figure out how to add something to the cart. Do I have to register and log in first? Please provide login information for me to use.

Then post step by step instructions. Like:
1) Go to the home page
2) Click on this link
3) Click on that button ... etc.

Your first step is:
You have to add something from the first products. ( It's the 'Core Support' category). Then, something the bottom 'Brakes' (or any other that is different.. When you expand with the input checkbox, you'll see what I'm talking about.

but I don't know how to do that.

Sign in to reply to this post
Did this help? Tips are appreciated...

lr_leal239405

Oops, you're right. I updated the link above, which is: http://www..com/eCart/

That is the products shopping cart. Sorry. (I was missing the 'eCart/). The FTP has all those files. (starting with index.php)

Sign in to reply to this post
loading

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