close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Find if dynamic value exists in cart

Thread began 3/13/2015 3:22 am by enquiry272230 | Last modified 3/17/2015 12:11 pm by Jason Byrnes | 459 views | 6 replies |

enquiry272230

Find if dynamic value exists in cart

HI,

I am presenting a popup page with some items to add to the cart that are reduced in price based on the particular item the customer has first added to the cart.

E.G. The customer adds a couch to the cart and because of that he gets a popup with reduced prices on some recommended cushions that he can then add to the cart also.

The problem I have is that the customer could add the reduced price item to the cart from the popup and then delete the original that enabled the reduced price items in the first place.

So therefore, I wish to hide the delete checkbox for the original item as long as an associated reduced price item is in the cart. (Based on the presence of a special "RecID" field I have set up in the cart to associate the original item's ID with the reduced price item.

The customer will be offered more than one reduced price item per Original Item.

The method I have set up so far that works for one reduced price item only in the cart is:

**********************
<td class="eC_FormItem">
<?php if (($eCart1->DisplayInfo("ID")) != ($eCart1->ConditionalTotal("RecID"))) { ?>

<input type="checkbox" value="<?php echo $eCart1->DisplayInfo("ID"); ?>" name="eCart1_Delete_<?php echo $eCart1->DisplayInfo("WAUID"); ?>" />
<?php } ?>
</td>
***********************
RecID is the field in the reduced price item Add To Cart Button that contains the ID of the original item, so the cart needs to be scanned to see if the RecID matching the original item ID is in the cart..

The customer can delete the original item if he deletes the reduced price item first, because then the delete checkbox will again be visible.

The above code works well but fails when an additional reduced price item is added, because $eCart1->ConditionalTotal("RecID") sums the RecID items in the cart.

Say the original item ID is 6, and each "reduced price item" added has a RecID value of 6.
If two "reduced price items" are added, the RecID sums to 12 and so fails.

So is there an eCart operator that can scan the RecID fields in the cart to find if a value exists without summing them.

I thought I might find something that works similarly to ($eCart1->InCart("6") == true) to enable finding a dynamic value in a cart field.

I hope I have explained this well enough.

I thank you in advance for your time.

Sign in to reply to this post

Jason ByrnesWebAssist

you can find the number of items where RecID = 6 using conditional total:

<?php echo $eCart1->ConditionalTotal("Quantity", "RecID", "6"); ?>

so you could set the if statement to hide the delete button as:

if($eCart1->ConditionalTotal("Quantity", "RecID", "6") > 1) {


in other words,
If the quantity of items in the cart where the RecID column has a value of 6 is Greater than 1...

Sign in to reply to this post

enquiry272230

Hi Jason,

Yes I saw that solution in another post. I wasnit sure if I could get it to work.

In - if($eCart1->ConditionalTotal("Quantity", "RecID", "6") > 1) {

Where the "6" is needs to be a variable value from the eCart1 item ID, like - ($eCart1->DisplayInfo("ID")

Not sure how to code this or even if it can be done.

5 Minutes later:

Just tried

if($eCart1->ConditionalTotal("Quantity", "RecID", "" . $eCart1->DisplayInfo("ID") . "") > 1) {

and it looks like it will work. I just have to have it evaluate as false instead of true. I'm learning!!
Just tried

Sign in to reply to this post

enquiry272230

This is what works for me. The empty curly brackets seem superfluous, you may know a better way to code it to hide that delete box if true :

<?php if ($eCart1->ConditionalTotal("Quantity", "RecID", "" . $eCart1->DisplayInfo("ID") . "") >= 1) { } else {
?>
<input type="checkbox" value="<?php echo $eCart1->DisplayInfo("ID"); ?>" name="eCart1_Delete_<?php echo $eCart1->DisplayInfo("WAUID"); ?>" />
<?php } ?>

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

the empty curly brackets are for the true condition.

so you are saying if Quantity of items Where RecID is Greater Than or Equal to $eCart1->DisplayInfo("ID") : Do Nothing
Else: Show the checkbook.


perhaps you what to be using less than:
<?php if ($eCart1->ConditionalTotal("Quantity", "RecID", "" . $eCart1->DisplayInfo("ID") . "") < 1) {
?>
<input type="checkbox" value="<?php echo $eCart1->DisplayInfo("ID"); ?>" name="eCart1_Delete_<?php echo $eCart1->DisplayInfo("WAUID"); ?>" />
<?php } ?>

Sign in to reply to this post

enquiry272230

Thanks Jason, that's a better way if I don't want to display anything in the true condition.

Excellent advice, thank you for your valuable assistance with this.

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