Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 Tips and Tricks - HALL OF FAME
 California PROP65 warnings .asp AND php add-on
Author « Topic »  

dbdave
ECT Moderator

USA
10276 Posts

Posted - 02/28/2019 :  21:40:38  
See below for separate instructions for .asp and .php

DEMO---
You can see it working on my test site here - http://www.floridasurpluswarehouse.com/flsurplus/dev/proddetail.php?prod=keyboard001
That is a link to a product that has a PROP65 warning.
If you load that product into a cart and proceed with a California shipping address, you will see the warning in checkout.

For decades California has had Prop (Proposition) 65 in place. It dates back to the 80's.
This has to do with product warnings and clean water mostly. Over the years, it has been expanded and many chemicals have been added to the list. In 2016 big changes were made that became active in August 2018. This expanded the warnings to (among other places) websites.

There is tons of info out there and it can be difficult to understand the products that might need warnings.
I can tell you that according to the Official website ( https://www.p65warnings.ca.gov/new-proposition-65-warnings ) if you have under 10 employees, you do not need to show warnings.
I do have more than 10 employees at my company, so I personally must understand this and attempt to comply.

There was a good article that came out just prior to the August 2018 enactment here - https://www.techtransactionstoday.com/2018/05/31/your-webpage-is-about-to-violate-the-law-and-other-changes-to-prop-65-warning-requirements/

It's actually scary to think that there are so called bounty hunters out there looking to turn in companies who do not comply.
In the past, with regards to product packaging, it seems these bounty hunters are real.
So even if you do not have 10+ employees, you might consider using this.
Hey, it may give the appearance that you are a large company, driving additional shopper confidence.

Here is an excerpt from the article that pertains to websites.
quote:
The New “Gotcha” – Internet and Catalog Warnings
Historically, for product purchases made over the internet, a company needed to provide only a general broad warning at the bottom of the company website to comply with Prop 65 or have a compliant label on the product being sold (even if not seen by the purchaser). No more.
Now, each product that requires a warning must have that warning “closely associated” with it on the product webpage. OEHHA has provided guidance on how internet retailers can comply with the new regulations. Specifically, website warnings must either be (1) placed on the product’s display page, (2) given via hyperlink using the word “WARNING” placed on the product display page, or (3) displayed, with a tie to the product for which the warning is being given, to the consumer before the purchase is completed (such as having the warning appear when the shopper enters a California zip code into the shipping information fields during the checkout process). A warning does not satisfy Prop 65’s requirements if the purchaser is required to search for it.

What I have done is create a two pronged solution that you can implement that should allow you to comply.
The big piece is a warning on the final checkout page where we will detect that the order is shipping to the state of California and a product you have marked as needing a warning, exists on the order.
IMAGE EXAMPLE
(download a warning image here - https://www.p65warnings.ca.gov/warning-symbol )

The next piece is a warning on the product details page itself. This would be optional, but easy to create.
I have done this in a way that will not be affected by updates.
The steps below need to be followed carefully. It's quite easy to remove the changes, and everything is commented so you can spot the changes in your pages later on.
I have tried to consider the different ways a store may be setup and plan for that. For example if you are not forcing users to supply a shipping address, then the billing address will be used to determine if the order is shipping to California.
I can't be sure how this will work if you are using some payment processors that may bypass some checkout steps such as paypal express.
I can tell you it works fine with paypal standard and when payments are entered on your site.
Please test your checkout thoroughly after implementing this to be sure everything is working as expected.
It's also possible this may have other purposes. You could actually change the state and have a message show up for a different state.

On with it...

BEGIN :::ASP VERSION:::

STEP 1
We will use an existing field on your last checkout page to add a hidden div where we will show the message when ready, via javascript.
There is a message that comes from the languagefile and we will copy that to the includes.asp file with a small addition like so.
(add this entire line, below, to your includes)
xxChkCmp="<div id=""prop65warn""></div>Check totals and proceed to process payment."

The bit in red there is what we have added. If you happen to already have that in your includes (maybe you wanted to edit that text) then just add the part in red.
While you are in your includes file, we need to activate the custom3 field for your products, if you do not already use it.
If you already use it, then do nothing. If you are not using it, then add this to your includes file.
( https://www.ecommercetemplates.com/help/ecommplus/parameters.asp#csslayout )
You will need to have custom3 somewhere in "your" detailpagelayout list there (your list may be different than this one)
quote:
detailpagelayout="navigation, checkoutbutton, productimage, productid, manufacturer, sku, productname, discounts, instock, description, listprice, price, quantity, currency, dateadded, options, custom3, addtocart, previousnext, emailfriend, reviews"
To add the custom field names to the product admin page use
admincustomlabel3="PROP65 "


STEP 2
Open your cart.asp page in your favorite HTML editor. (I like notepad++ )
In the content area of the page, you will have the include line that allows the cart to show on your page <!--#include file="vsadmin/inc/inccart.asp"-->
AFTER THAT - Important, the code will not work unless it comes after that include line.
Add the following
<!-- begin prop 65-->
<% if orderid<>"" then %>
<div id="hiddednprop65" style="display:none;"><img src="images/prop65warn.png" alt="Prop65 Warning" /><span style="font-weight:bold;">PROP65 WARNING<br/>Add your own message or html here</span></div>
<%
Dim sSQL2, rs165, rs265, conn, sessid, prop65id, showthewarn, prodprop65, fndmtch
prodprop65 = ""
fndmtch = ""
Set rs165=Server.CreateObject("ADODB.RecordSet")
Set rs265=Server.CreateObject("ADODB.RecordSet")
Set conn=Server.CreateObject("ADODB.Connection")
conn.open sDSN
on error resume next
sessid=Request.Cookies("ectcartcookie")
sSQL2 = "SELECT cartProdID,cartSessionID FROM cart WHERE cartSessionID='"&sessid&"'"
rs165.open sSQL2,conn,0,1
do while NOT rs165.EOF
prop65id = rs165("cartProdID")
sSQL2="SELECT pID, pCustom3 FROM products WHERE pID ='"&prop65id&"'"
rs265.Open sSQL2,conn,0,1
fndmtch = ucase(rs265("pCustom3"))
if InStr(fndmtch,"PROP65") > 0 then prodprop65 = "yes"
do while NOT rs265.EOF
rs265.MoveNext
loop
rs265.Close
rs165.movenext
loop
rs165.close
set rs265 = nothing
conn.Close
set rs165 = nothing
set conn = nothing
if ordShipState = "" and ordState="California" and prodprop65<>"" then
showthewarn = "yes"
elseif ordShipState = "California" and prodprop65<>"" then
showthewarn = "yes"
else
showthewarn = ""
end if
%>
<script>
var showthewarn = '<%=showthewarn%>';
if (showthewarn >'') {
document.getElementById('prop65warn').innerHTML = document.getElementById('hiddednprop65').innerHTML;
}
</script>
<%end if%>
<!-- end prop 65-->

There are a few notes regarding the code above. There is a section of HTML there that you will edit to create your custom warning.
I can't specifically tell you what your warning might need to say, you should determine that based on your products and the requirements of the state of California. The part in blue there is what you want to edit. Be sure to leave the outer div intact there so the code works.
Next, we are using the custom3 field from your products to tell the code that the order has an item that needs a prop65 warning.
If you are already using it, no worries, I have that covered below in next steps.
Upload that saved file to your server and before moving to next steps, load a shopping cart at your website to be sure your cart page is loading and working ok. You will not see any PROP65 message at this point.

STEP 3
The next step is to add the PROP65 trigger to your products.
The nice thing about using the custom3 field is that you can populate this field quickly with the admin quick entry or via csv download/upload
For now, just open a product in your admin and you should see the custom3 field there.
The code just looks for the word prop65 in there somewhere.
What we will enter there is the following <div id="prop65warn"></div>
This will be hidden from showing on your product detail page and allow the code on the cart page to see that this product needs a warning.
If you are already using the custom3 field, no worries, just add that in front of what you already have there.
<div id="prop65warn"></div>Your existing Custom three info

At this point you should be able to load that product into a shopping cart and proceed to your checkout and enter a shipping address to the state of California, and you should see your warning appear.

That's all there is to it.
*******************************************************************************************

If you want to show a message on your product detail page, follow these instructions

Open your proddetail.asp page in your favorite HTML editor. (I like notepad++ )
In the content area of the page, you will have the include line that allows the product details to show on your page <!--#include file="vsadmin/inc/proddetail.asp"-->
AFTER THAT - Important, the code will not work unless it comes after that include line.
Add the following
<!-- begin prop 65-->
<div id="hiddednprop65" style="display:none;"><img src="images/prop65warn.png" alt="Prop65 Warning" /><span style="font-weight:bold;">PROP65 WARNING<br/>Add your own message or html here</span></div>
<%
Dim sSQL2, rs165, cust3check, prodprop65
cust3check = ""
prodprop65 = ""
Set rs165=Server.CreateObject("ADODB.RecordSet")
Set conn=Server.CreateObject("ADODB.Connection")
conn.open sDSN
on error resume next
sSQL2="SELECT pCustom3 FROM products WHERE pID ='"&prodID&"'"
rs165.Open sSQL2,conn,0,1
cust3check = ucase(rs165("pCustom3"))
if InStr(cust3check,"PROP65") > 0 then prodprop65 = "yes"
rs165.Close
conn.Close
set rs165 = nothing
set conn = nothing
%>
<script>
if (document.getElementById('prop65warn')) {
var showthewarn = '<%=prodprop65%>';
if (showthewarn >'') {
document.getElementById('prop65warn').innerHTML = document.getElementById('hiddednprop65').innerHTML;
}}
</script>
<!-- end prop 65-->

Just like the steps above you will need to customize the html to your liking.
The warning will show on your product detail page in the space where you have defined "custom3" in your includes.

END ASP
*******************************************************************************************************
:::BEGIN PHP VERSION:::


STEP 1
We will use an existing field on your last checkout page to add a hidden div where we will show the message when ready, via javascript.
There is a message that comes from the languagefile and we will copy that to the includes.asp file with a small addition like so.
(add this entire line, below, to your includes)
$GLOBALS['xxChkCmp']='<div id="prop65warn"></div>Check totals and proceed to process payment.';

The bit in red there is what we have added. If you happen to already have that in your includes (maybe you wanted to edit that text) then just add the part in red.
While you are in your includes file, we need to activate the custom3 field for your products, if you do not already use it.
If you already use it, then do nothing. If you are not using it, then add this to your includes file.
( https://www.ecommercetemplates.com/phphelp/ecommplus/parameters.asp#csslayout )
You will need to have custom3 somewhere in "your" detailpagelayout list there (your list may be different than this one)
quote:
$detailpagelayout='navigation,productimage,productname,instock,custom3,description,sku,listprice,price,currency,options,quantity,addtocart,socialmedia,previousnext,reviews';
To add the custom field names to the product admin page use
admincustomlabel3="PROP65 "


STEP 2
Open your cart.php page in your favorite HTML editor. (I like notepad++ )
In the content area of the page, you will have the include line that allows the cart to show on your page <?php include "vsadmin/inc/inccart.php" ?>
AFTER THAT - Important, the code will not work unless it comes after that include line.
Add the following
<!-- begin prop 65-->
<?php if ($orderid) : ?>
<div id="hiddednprop65" style="display:none;"><img src="images/prop65warn.png" alt="Prop65 Warning" /><span style="font-weight:bold;">PROP65 WARNING<br/>Add your own message or html here</span></div>
<?php
$prodprop65 = '';
$fndmtch = '';
$sessid = $_COOKIE["ectcartcookie"] ;
$sSQL2="SELECT cartProdID,cartSessionID FROM cart WHERE cartSessionID='".$sessid."'";
$result=ect_query($sSQL2) or ect_error();
if(ect_num_rows($result)>0){
while($rs=ect_fetch_assoc($result)){
$prop65id = $rs['cartProdID'];
$sSQL2="SELECT pID, pCustom3 FROM products WHERE pID ='".$prop65id."'" ;
$result2=ect_query($sSQL2) or ect_error();
while($rs2=ect_fetch_assoc($result2)){
$fndmtch = strtoupper($rs2['pCustom3']);
$findme = 'PROP65';
$pos = strpos($fndmtch, $findme);
if ($pos !== false) {
$prodprop65 = 'yes';
}}}
ect_free_result($result);
ect_free_result($result2);
}
if (($ordShipState == '') && ($ordState=='California') && ($prodprop65!=='')) {
$showthewarn = 'yes';
} elseif (($ordShipState == 'California') && ($prodprop65!=='')) {
$showthewarn = 'yes';
} else {
$showthewarn = '';
}
?>
<script>
var showthewarn = '<?php print $showthewarn;?>';
console.log ('show the warn is '+showthewarn);
if (showthewarn >'') {
document.getElementById('prop65warn').innerHTML = document.getElementById('hiddednprop65').innerHTML;
}
</script>
<?php endif ?>
<!-- end prop 65-->

There are a few notes regarding the code above. There is a section of HTML there that you will edit to create your custom warning.
I can't specifically tell you what your warning might need to say, you should determine that based on your products and the requirements of the state of California. The part in blue there is what you want to edit. Be sure to leave the outer div intact there so the code works.
Next, we are using the custom3 field from your products to tell the code that the order has an item that needs a prop65 warning.
If you are already using it, no worries, I have that covered below in next steps.
Upload that saved file to your server and before moving to next steps, load a shopping cart at your website to be sure your cart page is loading and working ok. You will not see any PROP65 message at this point.

STEP 3
The next step is to add the PROP65 trigger to your products.
The nice thing about using the custom3 field is that you can populate this field quickly with the admin quick entry or via csv download/upload
For now, just open a product in your admin and you should see the custom3 field there.
The code just looks for the word prop65 in there somewhere.
What we will enter there is the following <div id="prop65warn"></div>
This will be hidden from showing on your product detail page and allow the code on the cart page to see that this product needs a warning.
If you are already using the custom3 field, no worries, just add that in front of what you already have there.
<div id="prop65warn"></div>Your existing Custom three info

At this point you should be able to load that product into a shopping cart and proceed to your checkout and enter a shipping address to the state of California, and you should see your warning appear.

That's all there is to it.
*******************************************************************************************

If you want to show a message on your product detail page, follow these instructions

Open your proddetail.php page in your favorite HTML editor. (I like notepad++ )
In the content area of the page, you will have the include line that allows the product details to show on your page <?php include "vsadmin/inc/incproddetail.php" ?>
AFTER THAT - Important, the code will not work unless it comes after that include line.
Add the following
<!-- begin prop 65-->
<div id="hiddednprop65" style="display:none;"><img src="images/prop65warn.png" alt="Prop65 Warning" /><span style="font-weight:bold;">PROP65 WARNING<br/>Add your own message or html here</span></div>
<?php
$prodprop65 = '';
$custthreecheck = '';
$sSQL2="SELECT pCustom3 FROM products WHERE pID ='".$prodid."'";
$result=ect_query($sSQL2) or ect_error();
while($rs=ect_fetch_assoc($result)){
$custthreecheck = strtoupper($rs['pCustom3']);
$findme = 'PROP65';
$pos = strpos($custthreecheck, $findme);
if ($pos !== false) {
$prodprop65 = 'yes';
}}
ect_free_result($result);
?>
<script>
if (document.getElementById('prop65warn')) {
var showthewarn = '<?php print $prodprop65;?>';
if (showthewarn >'') {
document.getElementById('prop65warn').innerHTML = document.getElementById('hiddednprop65').innerHTML;
}}
</script>
<!-- end prop 65-->

Just like the steps above you will need to customize the html to your liking.
The warning will show on your product detail page in the space where you have defined "custom3" in your includes.


END PHP
*******************************************************************************************************


NOTE - If you need to style that div where the message shows, or add a float maybe, you can use the selector #prop65warn in your css file
example
#prop65warn {float:left;}

There are a number of ways to do this and more ways to trigger the warning, but to me, this seems the most universal for most users.
Let me know if you have questions.
Of course this is not endorsed by, or supported by ect.
But I am willing to answer questions and help as I can.
There are no guarantees that this will work for you, but it should. If it doesn't, I'll give you a full refund.
Did I mention it's free?

If there is interest, I can try a .php version. No promises though.

Thanks,
David

Edited by - dbdave on 05/06/2023 07:59:54

midvalleydrifter001
Ecommerce Template Expert

USA
912 Posts

Posted - 03/01/2019 :  09:44:07  
This is great!! Nice work.

I would LOVE to see it in PHP if possible.

Thanks,

Patrick

dbdave
ECT Moderator

USA
10276 Posts

Posted - 03/01/2019 :  10:18:56  
Hi Patrick, thanks. I have something else I will be working on for a few days, then I will give it a shot.
I think it will be fairly straight forward to convert, so the good news is I should be able to work it out.
If anyone has installed the .asp version, post up to let me know how it's working for you.

I will install it on my live site soon.
As soon as I can determine what all products need it...

kelleymoore
Ecommerce Template Expert

USA
986 Posts

Posted - 03/01/2019 :  12:34:47  
Hey Dave,

This is great! Thank you so much for taking the time to post all of this for the rest of us to use.

I use a LOT of ALT Prod IDs for my site for various product options. So I also need to insert the <div id="prop65warn"></div> into each one of them to get that particular option/product selected to show the warning in the cart. I can do this using the .csv upload feature but I also added the field to my Quick Entry list.

Thanks again, Dave. This is a load off.

Kelley

dbdave
ECT Moderator

USA
10276 Posts

Posted - 03/01/2019 :  18:38:21  
No worries Kelley.
I think it's possible to edit the code to check for a manufacturer, but then if a new manufacturer was added that needed the warning, the code would need to be edited.
The way it is now, you can get along without edits to the code.
Unless ect makes some major change, it's a "set it and forget it" thing.

Let me know if you discover any issues.

David

dbdave
ECT Moderator

USA
10276 Posts

Posted - 03/03/2019 :  08:33:42  
quote:
I would LOVE to see it in PHP if possible.

Thanks,

Patrick


PHP Version has been posted
You can see it working on my test site here - http://www.floridasurpluswarehouse.com/dev/proddetail.php?prod=keyboard001
That is a link to a product that has a PROP65 warning.
If you load that product into a cart and proceed with a California shipping address, you will see the warning in checkout.

Edited by - dbdave on 03/03/2019 08:34:04

midvalleydrifter001
Ecommerce Template Expert

USA
912 Posts

Posted - 03/03/2019 :  11:31:53  
Hi David,

The PHP version works perfectly. Thanks for all your work. It's much appreciated.

LOVE IT !!

Patrick



Edited by - midvalleydrifter001 on 03/03/2019 12:03:16

dbdave
ECT Moderator

USA
10276 Posts

Posted - 03/03/2019 :  12:04:57  
Sorry Patrick, I thought that was native, but you can add a line to includes to add and custom fields (database columns) and those custom fields to the quick entry


quote:

In the admin, there have been requests to have the custom fields available in the quick entry drop down.
Well, the developer was kind enough to add a really great feature in a recent release.
This is the ability to add any custom database columns some of us might have, to that drop down. Well I just tested and it works fine with the ect custom fields available for your products.
Here are the release notes - https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=109004

so for .asp add this to your includes
customquickupdate="pCustom1,pCustom2,pCustom3"

for .php it should be
$customquickupdate="pCustom1,pCustom2,pCustom3";



So try this in your includes

$customquickupdate="pCustom3";

midvalleydrifter001
Ecommerce Template Expert

USA
912 Posts

Posted - 03/03/2019 :  13:32:16  
I figured out how to add the pCustom fields to the includes file.

It works GREAT. Thanks again for all your work.

Patrick

kelleymoore
Ecommerce Template Expert

USA
986 Posts

Posted - 12/09/2019 :  05:45:30  
Hey Dave,

After I updated to the new 7.1.7, the following div tag shows live on the cart.asp page:

xxChkCmp="<div id=""prop65warn""></div>Check totals and proceed to process payment."

It's probably because I added the new parameters:

cartresumeopen=TRUE
custdetailsresumeopen=TRUE

Can't imagine why else. So I have removed that tag and left everything else. Any advice would be greatly appreciated.

Thanks,
Kelley

Vince
Administrator

42466 Posts

Posted - 12/09/2019 :  06:08:07  
Hi Kelley
This was a fix for a Cross Site Scripting issue, but looking at it, maybe the first one is not necessary. If you open inccart.asp in notepad and do a text search for...
htmlspecials(listname)
Then ONLY THE FIRST ONE, change it to just...
listname

Can you let me know if that sorts this out?

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

kelleymoore
Ecommerce Template Expert

USA
986 Posts

Posted - 12/09/2019 :  07:23:02  
Hi Vince,

Yes, sir, that fixed it!

Um, do I need to make note of this to make the modification for future updaters?

Thanks,
Kelley

Edited by - kelleymoore on 12/09/2019 07:40:21

Vince
Administrator

42466 Posts

Posted - 12/09/2019 :  10:43:52  
Hi Kelley
I'll make the changes for this in the updater so you won't need to do this again.

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

midvalleydrifter001
Ecommerce Template Expert

USA
912 Posts

Posted - 12/09/2019 :  16:04:41  
I have that same problem but I'm on PHP

I can't get mine to work.

PHP v7.1.7

Edited by - midvalleydrifter001 on 12/09/2019 16:51:40

kelleymoore
Ecommerce Template Expert

USA
986 Posts

Posted - 12/10/2019 :  05:15:07  
Thanks, Vince.

Vince
Administrator

42466 Posts

Posted - 12/10/2019 :  05:40:31  
If anyone else is having this problem, I've just uploaded new inccart.asp and inccart.php scripts in the updater that will sort this issue out.

Vince

Click Here for Shopping Cart Software
Click Here to sign up for our newsletter
Click Here for the latest updater

midvalleydrifter001
Ecommerce Template Expert

USA
912 Posts

Posted - 12/10/2019 :  15:35:51  
Thanks Vince.

It's working fine now with your edit.

Appreciate it.

Patrick

Mikelli
Ecommerce Template Guru

USA
1613 Posts

Pre-sales questions only
(More Details...)

Posted - 02/09/2022 :  07:10:14  
Hi David,
This script looks like just what I need to make this new sub-domain work. We sell products that some are made of lead. These can not be shipped to: California, Illinois, Maine, Maryland, Minnesota, New Jersey, New York, Washington and Vermont but they can be shipped to the other 41 states.

Here's the question, you have California in your shared code how would I add the other 8 states?


if (($ordShipState == '') && ($ordState=='California') && ($prodprop65!=='')) {
$showthewarn = 'yes';
} elseif (($ordShipState == 'California') && ($prodprop65!=='')) {
$showthewarn = 'yes';
} else {
$showthewarn = '';
}

Michael

dbdave
ECT Moderator

USA
10276 Posts

Posted - 02/09/2022 :  07:47:42  
There are several ways to do this, but basically it involves "conditions" and there are quite a few articles out there on javascript conditional if statements
Maybe this will help. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else

If you can't work it out, I can probably assist in the next few days when I get clear of a few things.

David
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.05 seconds. Snitz Forums 2000